Welcome to Mordor
We’ve all been there, assigned to that project where code is a total mess.
It is literally Mordor, orcs are coming from everywhere (aka bugs), each time you kill one of them, a dozen more appear out from nowhere to come after you. It is not possible to change anything without unexpected regressions and weird side effects.
The stronghold strategy
What I usually do in this case is what I call the “stronghold strategy”.
Pick a place that’s crawling with badass orcs, burn the place to the ground and build your fortress right here (it means rewriting one of the most buggy and strategic components of the app from scratch).
It’s only the first move of a probably bigger refactoring (and maybe more fortresses to build), but in my experience it’s much more effective than engaging multiple battles (and getting your ass kicked) all around the place.