Skip to content

LearnWeb and API

API function-level authorization testing

Brief

Most APIs check ownership on the object URL and forget the other ways an object leaves the system: search results, exports, notifications and bulk calls. This companion to the IDOR page builds a matrix of every function against every role, then follows each object through those indirect paths with two test accounts.

Stage
Escalation
Reviewed
On this page
  1. Check first
  2. How do I build and test a role and function matrix?
  3. Does search return objects the caller cannot open?
  4. Do exports and background jobs apply the caller's permissions?
  5. Do notifications and feeds keep flowing after access is removed?
  6. Do bulk endpoints check every item?
  7. The defender sees
  8. Done when
  9. Not covered
  10. Tools
  11. Related research
  12. Reviewed

All commands

Situation
The API's OpenAPI description or route list, test accounts for each role (viewer, member, admin) in our own test organization, a second test organization with its own accounts, and test objects on each side carrying a marker string. Every write names an object created for the test, every marker is a harmless string, and only the APIs the scope letter names are tested. The object URL checks themselves are on the IDOR testing page and are not repeated here.
Goal
A role and function matrix with the expected and actual result in each cell, and one line per indirect path (search, export, notification, bulk) saying whether it applied the caller's permissions.
Outputs
Captured on 4 Nov 2026 against the Atarus Bench Web and API lab fixture, edition web-api-0.2, running on loopback, with one origin playing every host, renamed to the example domains and printed as https (the lab ran plain http). The removal at 15:00 and the edit after it are stamped by the fixture's lab clock.

Check first

  • The OpenAPI description, so the function list comes from the client rather than from guessing.
  • What each role is meant to do, as a table from the client, so every cell has an expected answer.
  • Functions that return many objects: search, list with filters, export, report, activity feed, notification inbox.
  • Functions that take many ids: bulk update, bulk delete, batch get, move, merge.
  • Background jobs, which run later and often under a service identity instead of the caller's.

Steps

How do I build and test a role and function matrix?

jq -r '.paths | to_entries[] | .key as $p | .value | keys[] | select(. == "get") | $p' openapi.json \
  | grep -vF '{' > reads.txt
for role in viewer member admin; do
  tok_var="TOKEN_$(echo "$role" | tr a-z A-Z)"
  while read -r path; do
    printf '%s %s %s\n' "$role" "$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer ${!tok_var}" "https://api.example.com$path")" "$path"
  done < reads.txt
done | awk '$2 == 200 && $3 ~ /admin|audit|billing|export/'

Expected output

member 200 /v2/admin/audit-log   # <- a member reads the audit log the role table reserves for admins
admin 200 /v2/admin/audit-log
admin 200 /v2/billing/invoices

Reads without path parameters run for every role; the paths with ids are tested by hand on our own objects. The filter matches the path column only, since a pattern over the whole line would also match the role name admin. Write functions are not looped: we call each one once, as each role that should not have it, against a test object, and read the object back. One write worth its own call is an invite with a role field, sent by a member asking for admin, because it reaches an admin function through a member's door.

Negative result. Every cell matches the client's role table, and the member's invite request is refused or created with the member's own role.

Fix. Attach a required permission to every route in one place, deny any route with none, and test the role table in CI by calling each route as each role.

Does search return objects the caller cannot open?

curl -s "https://api.example.com/v2/search?q=atzmk-b-91c" -H "Authorization: Bearer $TESTER_A_TOKEN" | jq -c '{total, ids: [.items[].id]}'

Expected output

{"total":1,"ids":[]}   # <- the item is filtered out, but the count confirms it exists in the other organization

atzmk-b-91c is a marker in a test project tester-b created in the other organization. Search indexes are often built outside the permission model, so check the items, the totals, the facets and the highlighted snippets.

Negative result. A total of zero and no facet or snippet that mentions the marker.

Fix. Filter the search query by the caller's permissions before counting, not after, so totals and facets are computed on what the caller may see.

Do exports and background jobs apply the caller's permissions?

job=$(curl -s -X POST https://api.example.com/v2/exports -H "Authorization: Bearer $TOKEN_VIEWER" \
  -H 'Content-Type: application/json' -d '{"type":"projects"}' | jq -r .id)
sleep 30
curl -s "https://api.example.com/v2/exports/$job/download" -H "Authorization: Bearer $TOKEN_VIEWER" | tail -n +2 | wc -l
curl -s https://api.example.com/v2/projects -H "Authorization: Bearer $TOKEN_VIEWER" | jq '.items | length'
curl -s -o /dev/null -w '%{http_code}\n' "https://api.example.com/v2/exports/$job/download" -H "Authorization: Bearer $TESTER_B_TOKEN"

Expected output

      14   # <- the export holds fourteen projects
6
200   # <- and tester-b in the other organization can download it by job id

The viewer sees six projects in the list and fourteen in the export, so the job ran with more than the viewer's rights (BSD wc pads its count with spaces; GNU wc prints 14). Then tester-b fetches the job by id. We count rows and never open the file beyond our own test projects.

Negative result. The same count in export and list, and a 404 for tester-b.

Fix. Run export jobs as the requesting user with that user's filters stored on the job, check ownership on the download, and expire the file.

Do notifications and feeds keep flowing after access is removed?

curl -s https://api.example.com/v2/notifications -H "Authorization: Bearer $TOKEN_MEMBER" \
  | jq -r '.items[] | select(.created_at > "2026-10-28T15:00:00Z") | .summary'

Expected output

Project "authz-test-p2" updated: "atzmk-p2-77d"   # <- received after the member was removed from the project at 15:00

An admin test account removes the member from a test project at 15:00, then edits the project to add a marker. The member's inbox, email digest and webhook are checked for it.

Negative result. Nothing about the project after removal, in the inbox, email or webhook.

Fix. Check permissions when each notification is sent, not when the subscription was made, and delete subscriptions when access is removed.

Do bulk endpoints check every item?

curl -s -X POST https://api.example.com/v2/tasks/bulk-update -H "Authorization: Bearer $TESTER_A_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"ids":["task_test_a_101","task_test_b_901"],"set":{"label":"authz-marker"}}' | jq -c .

Expected output

{"updated":2,"failed":[]}   # <- tester-b's task changed through a list that started with tester-a's own

Bulk handlers often check the first id or the caller's general role and then apply the change to the list. task_test_b_901 is a test task in the other organization; we read it back as tester-b, then remove the label.

Negative result. "updated":1 with the second id in failed, or the whole request refused.

Fix. Load the objects with the caller's tenant in the query and update only what that query returns, so ids the caller does not own match nothing.

The defender sees

Requests from ordinary test accounts, so status codes say little. The useful signals are in application logs: a role calling a function outside its table, an export whose row count differs from the caller's list count, a download by an account other than the requester, and a bulk call whose ids span organizations. If none of those is logged, the request ids in our matrix let the client check what they would have seen.

Done when

Every read function has been called by every role, every write function by the roles that should not have it against test objects only, the marker searched for across organizations, an export compared with the list view per role, notifications checked after removal, and each bulk endpoint sent one mixed request.

Not covered

Single object ID swaps, method tampering and mass assignment (see IDOR testing), GraphQL (see GraphQL authorization), and injection.