Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Web, API & dataMiddleOccasionalSecurity

How would you distinguish authentication failures from authorization failures in testing?

Answer

Authentication proves identity; authorization decides what that identity may access. Test absent, expired and malformed credentials separately from valid users attempting forbidden actions, including object-level access to another user's data. A missing or invalid credential should draw a 401 challenge per the API's contract; a valid, authenticated identity attempting a forbidden action must still be denied — commonly with 403 Forbidden, or with 404 Not Found when the API deliberately conceals whether the resource even exists to that identity, which RFC 9110 explicitly permits. The security invariant to test is denial without inappropriate leakage, not one universally mandated status code.

Strong answer includes

  • identity versus permission
  • negative cases
  • denial without leakage is the invariant — 403 or a concealing 404 both satisfy it, not one mandated code

Practical example

Testing a banking API, a request with no token or an expired token should return 401 Unauthorized — that's an authentication failure. A request from a logged-in regular user trying to access GET /accounts/9999/statement, where 9999 belongs to a different customer, should be denied per the API's contract — typically 403 Forbidden, or 404 Not Found if the API is designed to hide that the resource exists at all — and it's a broken object-level access control (BOLA) issue if the API returns the data instead.

Sources

OWASP Web Security Testing GuideOWASP · Web application security test coverage