Skip to content
Antoine Le LouëtIndependent senior developer (Home)
Back to the Journal

Advice3 min read

AI-generated login: hiding a button does not protect an API

A local lab checks access for the owner, another account and an anonymous user before and after a server-side check.

The hidden button leaves the API accessible; after a server-side check, responses are 401, 403 or 200 according to identity and ownership.
The server must check rights to the resource even when the interface hides the action.

The check must exist on the route

The screen can hide a button from a user while leaving the corresponding route accessible. The lab deliberately constructs this defect with a fictional document owned by Alice. Bob should not be able to read it. In the initial state, however, Bob's direct request receives a 200 response.

The scenario is not the result of an application-generator audit. It explains a security boundary to verify regardless of the code's origin. Requests were executed only against the local server created for this article.

Separate identity from rights to the object

Authentication establishes an identity through the chosen mechanism. Authorisation decides whether that identity can perform that action on that resource. In this example, logging into an account does not grant access to another owner's document.

The example replaces authentication with an x-demo-user header to isolate the authorisation decision. This header is forgeable and must not be reused as a login mechanism. A real application must obtain identity from a session or token verified on the server.

A minimal matrix actually executed

Text · observed results
Ressource : doc-a, propriétaire : alice
Avant contrôle : bob -> 200, défaut volontaire
Après contrôle :
  anonyme -> 401
  bob, autre propriétaire -> 403
  alice, propriétaire -> 200
JavaScript · educational decision example
const status = !user ? 401
  : user !== document.owner ? 403
  : 200;

The script checks these statuses with assertions and closes the server after the experiment. It includes no real secret. In some API contracts, a 404 response for an inaccessible resource can avoid revealing its existence; define that choice and check it consistently.

The route checks for an identity, then document ownership. In the fictional matrix, absence receives 401, Bob receives 403 and Alice, the owner, receives 200.
Reading the lab matrix: the check belongs to the API route. Identity is simulated to isolate authorisation; roles and other actions are not represented.

Extend checks to the actions actually offered

  • Check reading, editing and deletion, not just the main screen.
  • Check client-supplied resource identifiers and rights on every request.
  • Provide for administration roles with an explicit scope.
  • Test missing identity and another owner's account using fictional data.

OWASP ASVS provides a framework of security requirements. This lab covers only one simplified decision and is not a complete review. It tests neither session creation, renewal, rights revocation nor database-level isolation.

When requesting work from an agent, attach the authorisation matrix and expected denial tests. A convincing login screen never removes the need to replay these requests in the authorised environment.

Sources and useful links

Share on LinkedIn (new tab)

Keep reading
All articles in this category