Say it's 2 a.m. and an order is stuck between "paid" and "shipped". The payment went through, the warehouse never got the message, and the customer has emailed twice. Someone on call remembers there's a script that can push an order to the next state. It lives on a teammate's laptop. Nobody's sure what else it touches, there's no log of who ran it last, and the teammate is asleep.
That script started life as a one-off fix and slowly turned into a second, unofficial way to run the system. This post is about the alternative: emergency paths you design on purpose, that people can see, use safely and review the next morning.
Every production system needs a way out
Real systems leave the happy path all the time. A payment provider goes down. A migration writes bad data. A workflow gets stuck because an event never arrived. A release needs to be turned off faster than a rollback can ship. Pretending none of that happens doesn't make the system safer. It means that when it does happen, people improvise with whatever access they have.
So the useful question is how to build those paths, since you'll need them either way. Here's the difference in one table:
| Question | Escape hatch | Back door |
|---|---|---|
| Who knows it exists | The whole on-call rotation, from the runbook | Whoever wrote it, plus whoever they told |
| Who can use it | A named role, with a permission check | Anyone with the script or the database password |
| What it can change | One narrow action on one kind of record | Whatever the credentials allow |
| What it leaves behind | An audit event with actor, reason, scope and ticket | Maybe a chat message, if someone remembered |
| When it was last tested | On a schedule, in a drill | The last time it was needed, in production |
A hidden script isn't safer because few people know about it. A bounded admin action with a permission check, a log and an alert usually is, because the team can see it and reason about it.
Five questions before you build one
A safe hatch starts from a specific failure, never from "it might be handy to have admin access". Before writing it, answer:
- What failure does it handle? "Order stuck after payment because the warehouse event was lost" is a good answer. "Fixing orders" is too broad.
- Who can use it, and how do they get that right?
- Exactly what can it change? One field on one record is easy to review. Free-form SQL isn't.
- What has to be true before using it? A ticket, a second person's approval, a confirmed check that the normal path really failed?
- What happens afterward? Who gets notified, and how is the use reviewed?
If those questions feel heavy, that's a useful signal. The action carries real power, and it deserves the same care as any feature that touches money or data.
Here's what the answers can look like in code. The helpers (canUseHatch, orders, audit, alerts) stand in for your own permission check, data layer, audit store and alerting:
type HatchRequest = {
actor: string;
reason: string;
ticket: string;
orderId: string;
};
async function forceAdvanceOrder(req: HatchRequest) {
if (!req.reason.trim() || !req.ticket) throw new Error('Reason and ticket are required');
if (!(await canUseHatch(req.actor, 'order.force-advance'))) throw new Error('Not allowed');
const before = await orders.get(req.orderId);
const after = await orders.advance(req.orderId, { manual: true });
await audit.write({
action: 'order.force-advance',
actor: req.actor,
reason: req.reason,
ticket: req.ticket,
target: req.orderId,
from: before.status,
to: after.status,
at: new Date().toISOString(),
});
await alerts.notify('ops-hatches', `${req.actor} force-advanced ${req.orderId}: ${req.reason}`);
}
It does one thing to one order, refuses to run without a reason and a ticket, checks a specific permission, and records before and after. In real code, write the audit row in the same transaction as the change so one can't exist without the other. The OWASP logging guide asks for exactly these fields: logs should record "when, where, who and what" for each event, and use of administrative privileges or a break-glass account is on its list of events worth logging (OWASP Logging Cheat Sheet).
Make hatches reversible where you can. If an operator can grant access, there should be an equally easy revoke. If a workflow can be pushed forward by hand, the event should say who pushed it and why. If data gets repaired, the repair should leave a trace that support, engineering and a future auditor can all follow.
How the big players handle break-glass access
Large organizations have written this down, and their rules transfer well to smaller teams.
Google's Building Secure and Reliable Systems (chapter 5, "Design for Least Privilege") lists guidelines for breakglass mechanisms: access "should be highly restricted", all uses "should be closely monitored", and the mechanism "should be tested regularly by the team(s) responsible for production services." The same chapter mentions that Google usually pushes breakglass reviews down to the team level, where peers are better placed to spot misuse.
Microsoft's guidance for emergency admin accounts in Entra ID is even more concrete (Manage emergency access admin accounts). Keep at least two emergency accounts. Alert on every sign-in. After every use, review whether it was a drill, a real emergency or misuse. Validate that the accounts still work at least every 90 days.
Notice what both of them do. The emergency path is allowed, and it's watched and rehearsed. A hatch that's never tested tends to fail on the night you need it, because a password expired or a dependency changed.
Kill switches are the friendlier cousin. Pete Hodgson's Feature Toggles article describes ops toggles that let operators disable or degrade a feature in production, and notes that long-lived ones work like "a manually-managed Circuit Breaker." On the Zalo PC team we ship risky changes default-off behind a kill switch or remote config, which means turning something off is a config change instead of a 2 a.m. hotfix. If you want the rollout side of this, Feature Flags for Safer Deployments covers it.
The customer still sees the result
Most hatches are internal tools, but customers feel their effects. A manual payment fix, an entitlement correction or an unblocked order can leave the customer looking at contradictory screens: an order marked shipped with a payment still pending, or access granted in one app and missing in another. Run the hatch through the same state rules the normal flow uses, so every screen tells the same story. And decide up front whether the customer gets a notification, so support isn't guessing.
The 2 a.m. test
One question works well in design review: if this path gets used at 2 a.m., what will we know the next morning? If the honest answer is "whatever people remember plus some chat history", the hatch isn't ready. If the answer includes an event with the actor, reason, scope and ticket, plus an alert someone saw, the team can learn from it.
Then close the loop. Every use of a hatch is a small signal that the normal flow has a gap. If the same hatch gets used every week, the fix belongs in the product, and the hatch should go back to being rare.
Try this week
- List every way your team can bypass the normal flow: scripts, admin endpoints, direct database access, shared accounts.
- For each one, ask the 2 a.m. question. Anything without an audit trail goes to the top of the list.
- Pick the riskiest and wrap it: one narrow action, a permission check, a required reason and an alert.
- Put a drill on the calendar to test your emergency access before you need it.