You have to keep the train moving. That keeps the cash coming in. You can't stop the train.
So, you have to take what you have and somehow -- that's what you are being paid for and hopefully you have the chops -- manoeuvre the beast into a better state. This is fscking hard, especially when you have to get the darn thing under test. And it's invariably massively undervalued by most biz management teams.
You can _always_ extract value from operative but shitty code, even if you have to stick your head around the U-bend and pull it back with your teeth. If you don't know that yet, then you've more to learn.
Also, when the real value within the app is a simple product, breaking it out and re-engineering based on what you've learnt takes about roughly the same time as it does to walk through the code line-by-line and add in valuable tests.
Refactoring legacy code by multiple vendors is always a risky proposition (and much much harder to sell to clients who want a deadline for delivery).
If you give in to them too many times and end up with buggy code where trivial changes take a month, but has all the features that are needed where do you think the blame will fall? I can guarantee you it isn't going to be the business side.
The goal shouldn't be for the CTO to be the business side's technical henchman. It should be to look after the technical side of things. If a rewrite is the best decision technically (without considering the business), then that's what the CTO should advocate, but they need to be willing to work with the business side to find a solution that works for both sides.
Engineers are the only ones who can advocate for pristine code without tradeoffs, and I would argue that great engineers care enough about the business to not do that. Really great engineers just build the pristine code in the same amount of time regular engineers would have taken to get a simple version almost-working.
I actually like the idea of "technical henchman", though!
This has been key in my experience. I'll build a feature that is flexible, clean, well factored, and completely documented in the same time it requires someone else to make a half working mess.
CTO's as I'd like to understand them bring the bar as high as they can within business constraints. Doing any less is accepting mediocrity. Is that something you'd want in an executive leadership role?
That decision was acceptable because of the complete lack of any technical experience in house (100% outsourced, multiple vendors) who had very different patterns of development. Couple this with no tests, no process and no patterns, you're stuck trying to work against something that's unpredictable.
The way forward then is to hire a team (even if it's just one guy) internally who can have ownership of code. Then instituting good practice and a sensible method of rebuild and rediscovery. Obviously this hinges on having enough runway to get into it properly.
tl;dr: sometimes it's ok to scrap it all and start again when your goal isn't about preserving code but instead is about building a better product and technical culture inside a company.
Getting downvotes - I wanted to add something: There's a real risk of making problems worse when you don't have any ability to stop and change. Working with existing code is great but when you have existing customers running into bugs on a daily basis, and fixing them would change the business logic that others are relying on, you either choose to build more technical debt or you swallow it and start again. Obviously this depends on runway, position, etc.
There are many times when companies go through their proto and raise seed only to find that their original hypotheses aren't working, and to change requires a significant re-architecture. Bolting this on to existing codebases can end up with code so complex that it won't stay up, and you end up spending six months in pure fire-fighting ops mode to keep the thing alive. Knowing when to recognize this and acting accordingly is the right approach, even if that sometimes means calling it a day on the existing code and starting again.