Returning 404 instead of 403
When a Relationship Manager requests a customer outside their own book, the API returns 404 Not Found — not 403 Forbidden.
403 is the intuitive answer and it is the wrong one. “Forbidden” confirms the record exists. An attacker walking CUST-1001, CUST-1002, CUST-1003 learns the entire customer ID space from the difference between the two responses, without ever reading a record. Returning 404 for both “doesn't exist” and “not yours” makes those cases indistinguishable and the enumeration worthless.
There is a second layer. Next.js has shipped middleware-authorization-bypass advisories, so authorization is never left to the edge proxy alone — every route handler re-checks. The pure predicates live in their own module, with no framework imports, so they can be unit-tested away from any request plumbing.








