Refactoring old codebases into something nice to work on is comfy though. It’s basically what I do in the startup world I just use less niche languages.
Although I’d suspect there isn’t a lot of refactoring going on in some of those code bases you describe.
I think this is a healthy and productive career path. If you can identify when a dead codebase is about to become fertile, and how to clear the debris to support new development, you can make a lot of money, have a lot of fun, gain a lot of respect, receive a lot of autonomy.
You just don't want to be the person tasked with work that's only done because some contact got signed. Identifying the difference is hard.
Although I’d suspect there isn’t a lot of refactoring going on in some of those code bases you describe.