You shipped a hardened v2 and left the original route wired up. Attackers read your comments too, and the legacy path skips every check you added.
What goes wrong
A deprecation comment is documentation. It is not a control. The old route still accepts the same request shape and runs the original handler, and that handler never got the ownership and state checks that went into the replacement. Anyone who can reach the service can call it.
The reason this survives review is that the new code looks correct. Reviewers approve the new handler and move on. Nobody diffs it against the old one to notice the legacy route still resolves. Routing tables almost never get audited, so a retired path can answer requests for years.
The pattern
// v2 added ownership and state checks
post("/link/v2", handleLinkV2)
// old route, marked "do not use" in a comment
post("/link", handleLinkLegacy)
function handleLinkLegacy(req):
// no ownership check, no state check
return store.link(req.source, req.target)// one handler, one set of checks
post("/link", handleLink)
function handleLink(req):
requireOwner(req.caller, req.source)
requireLinkable(req.target)
return store.link(req.source, req.target)
// old path deleted; it now returns 404Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.
Why it matters to you
The gap stays invisible until someone hits the old URL. Traffic dashboards show new-endpoint usage climbing and the legacy path near zero, which reads as safe to leave alone. That quiet route is exactly what an attacker probes for. Every method you replace for security reasons is a liability for as long as the original stays callable.
Check your own code
- Grep your router for every path that maps to a handler you have replaced, and confirm the old ones are gone.
- Diff a deprecated handler against its successor and list every check the new one gained.
- Add an integration test that asserts retired routes return 404 or 410.
- Treat every "deprecated" comment as a to-do, never as a control.