📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Why might an API return 404 instead of 403 when a user requests another customer's resource, and what are the trade-offs?

Junior Theory Intermediate

🎯 Key points

  • 403 confirms existence and enables id enumeration
  • 404 hides existence: safer default for customer-owned data (Privacy Act)
  • Enforce via resource-based authorisation or queries scoped to the caller's claims
  • Keep 403 for missing scopes/roles where existence isn't secret
  • Log the real reason with a trace id; return the trace id for support
  • Non-sequential ids as defence in depth

⏱ 30-second answer

Returning 403 confirms the resource exists, which lets an attacker enumerate ids (for example other customers' order numbers). Returning 404 hides existence, the safer default for customer-owned data and in line with Privacy Act obligations. Implement it in the authorisation layer: resource-based authorisation (IAuthorizationService with a requirement checking ownership, plus scopes or claims from the JWT) or queries filtered by the caller's customer id, so another customer's record simply isn't found. The trade-off is usability: legitimate users and support staff get a less helpful error, so log the real reason server-side with the trace id and return that trace id in the ProblemDetails body. Keep 403 where existence isn't secret, such as a missing scope on an admin endpoint.

🔍 What the interviewer is checking

Checks awareness of resource enumeration and information leakage

↩ Usually asked after

More in HTTP Fundamentals

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me