Broken function-level authorization: admin actions any user can call
Why hiding an admin menu does not protect the admin endpoint, how to map routes against roles from an OpenAPI file, and how central authorization policies with deny-by-default tests close the gap.
Diagram
A route the UI never shows a normal user
Step 1 of 4
Discovery
The JavaScript bundle and the OpenAPI file list every route, including admin ones.
$ jq -r '.paths | keys[]' openapi.json | grep admin
/api/admin/users
/api/admin/users/{id}/disable
/api/admin/exportThe example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Method confusion
- What fails
- GET is protected but PUT or DELETE on the same path is not.
- Who is affected
- Owners of the records the unprotected method changes.
- What you would notice
- Authorization middleware keyed on path alone.
- What you change
- Key policies on method plus path and test each method.
Route drift
- What fails
- New routes ship without a policy entry.
- Who is affected
- Whatever the new route touches.
- What you would notice
- No test that walks the route table.
- What you change
- Fail CI when a registered route has no policy.
A role matrix from the spec
Export the route list from the OpenAPI file or the framework, list the roles, and call each route with a token for each role in a test environment. The result is a table of expected and actual status codes. Any cell where a lower role gets 2xx on a higher role’s route is a finding.
route anon user support admin
GET /api/admin/users 401 403 200 200
POST /api/admin/users/{id}/disable 401 200! 200 200
GET /api/admin/export 401 403 403 200Keeping it closed
Generate that matrix in an integration test. A route added without a policy fails the build, and the matrix doubles as documentation for reviewers.
Check yourself
Recognition and the fix. Nothing here is a procedure.
A normal user gets 200 from POST /api/admin/users/88/disable. What was missing?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.
- 01IDOR in exports and batch endpointsA list of ids is still a list of objects.
- 02Nested object authorizationA check on the parent record does not authorize every child id inside the request.
- 03Mass assignment: when request bodies write fields they should notHow binding a whole JSON body to a model lets callers set roles, prices, or owners, how to spot it in Rails, Django, Express, and Spring code, and why explicit write schemas are the fix.