You don't need to imagine this. That's exactly how many consumer safes work.
I bought a safe from Costco (USA) that had a Securam lock on it. I had a police officer friend causally mention that if they needed access, they'd call the safe company and get the backdoor code. I was a little shocked by this, so I emailed Securam. They said that actual use of such codes is at the discretion of the manufacturer that uses their locks, and they referred me to the safe manufacturer.
I emailed the manufacturer, and the customer support agent confirmed what my cop friend said. So I asked what security protocols the manufacturer had in place to authenticate callers and verify they were actual police, and also how they validated the warrant or court order used to get the info. The CS person didn't understand the idea that someone might be pretending to be an officer, nor that even a real officer might be making an unlawful request. She said that if an officer calls and asks, they give them the code. I asked the agent to send me a copy of their policy on this. A day later I got an angry response from the CS lead saying denying what the CS agent said, claiming that they don't have backdoor codes, and don't give them out to officers.