SAASMENT

Security skill · Find and fix

Authorization and IDOR review.

Review an application for broken authorization, including insecure direct object references (IDOR), missing function-level checks, tenant isolation gaps, and mass assignment, using a role-by-resource matrix and two-account tests, then fix with centralized server-side checks. Use when auditing APIs or multi-tenant apps for broken access control (CWE-639, CWE-862, CWE-863).

Download .zipInstall via MCPFind and fixMIT
  • Code review

Facts

Category
Find and fix
License
MIT
Tags
  • Code review
Version
1.0.0
Last updated
2026-12-02
Folder
authz-idor-review/
MCP resource
skill://authz-idor-review/SKILL.md
Files
  • SKILL.md
  • LICENSE
  • references/authz-matrix.md
Standards

Original Saasment content. Saasment is in early access; this skill does not require joining it.

Install via MCP or as files

Connect your client to https://www.saasment.com/api/mcp (see client setup) and call get_skill:

{
  "name": "get_skill",
  "arguments": {
    "slug": "authz-idor-review"
  }
}

Or download the .zip and unpack it into your agent's skills directory:

Terminal, from your project root (user-level: ~/.cursor/skills)

mkdir -p .cursor/skills
curl -fsSL https://www.saasment.com/ai-security/skills/authz-idor-review/download.zip -o /tmp/authz-idor-review.zip
unzip -o /tmp/authz-idor-review.zip -d .cursor/skills
# result: .cursor/skills/authz-idor-review/SKILL.md

Review SKILL.md before enabling a skill. Skills are instructions your agent will follow.

SKILL.md

---
name: authz-idor-review
description: Review an application for broken authorization, including insecure direct object references (IDOR), missing function-level checks, tenant isolation gaps, and mass assignment, using a role-by-resource matrix and two-account tests, then fix with centralized server-side checks. Use when auditing APIs or multi-tenant apps for broken access control (CWE-639, CWE-862, CWE-863).
license: MIT
metadata:
  author: Saasment
  version: "1.0.0"
  category: both
  tags: "code-review"
---

# Authorization and IDOR review (find and fix)

License: MIT. Copyright (c) 2026 Saasment. Source: https://www.saasment.com/ai-security/skills/authz-idor-review

Broken access control means a signed-in (or anonymous) user can read or change data or call functions they should not. An IDOR is the common form: an endpoint takes an identifier such as `/orders/1234` and returns the record without checking that the caller owns it. Scanners find this poorly because the request is valid; you need to know what each role should be allowed to do. This skill builds that picture and tests it.

## When to use

- You are auditing an API, web app, or admin panel, especially one with multiple tenants or roles.
- You review code that loads records by an id from the request.
- You are fixing a reported access-control bug and want to prevent the class.

## Safe by default

- Only test applications you own or are authorized to test. Use a staging environment with test accounts you created.
- Use two or more of your own test accounts (different users, tenants, and roles). Never access, modify, or delete other real users' data to prove a flaw. One synthetic record per account is enough.
- Use read-only requests first. For write endpoints, use disposable records you created.
- Keep request rates low and stop when you have confirmed the issue.

## Procedure

1. **Inventory resources and actions.** List every object type (user, order, document, project, invoice, API key, file) and every action (create, read, update, delete, list, export, share, admin operations). Collect all routes, GraphQL operations, RPC methods, background jobs, and file or object-storage URLs.
2. **Define the intended policy.** Build a matrix: rows are roles (anonymous, user, tenant admin, support, platform admin), columns are resource and action, and cells say allowed or not, and under what ownership condition (own record, same tenant, any). See `references/authz-matrix.md`. Confirm unclear cells with the product owner.
3. **Review code for check placement.** For each handler, find where authentication and authorization happen. Flag handlers that:
   - Load a record by id without scoping the query to the caller (user or tenant).
   - Check authorization in the UI or in a client-side route guard only.
   - Check the role but not ownership (function-level check without object-level check).
   - Trust fields from the request body for ownership or role (for example `userId`, `tenantId`, `isAdmin`), including through mass assignment of whole objects to a model.
   - Use predictable or sequential ids with no check (the id format does not replace authorization).
   - Skip checks on secondary paths: bulk endpoints, exports, search, GraphQL nested fields, websockets, webhooks, and background jobs.
4. **Test with two accounts.** For every object endpoint: create an object as account A, then request it as account B (same tenant and different tenant), as an anonymous user, and as a lower-privileged role. Repeat for read, update, delete, and list. Also test swapping ids in body and query parameters, in addition to the path. Record each unexpected success.
5. **Test function-level access.** As a normal user, call admin-only endpoints directly, and try changing the HTTP method (for example `GET` versus `POST`, `PUT`, `DELETE`).
6. **Fix at a central point:**
   - Enforce authorization on the server in one shared layer (middleware, policy objects, or database row-level security), so handlers cannot forget it.
   - Scope every query by the authenticated principal: `WHERE id = ? AND tenant_id = ?`. Return `404` for objects the caller cannot see to avoid confirming that ids exist, where that suits the product.
   - Take ownership and role from the session or token, never from request fields. Use explicit allowlists of fields that clients may set (DTOs or strong parameters).
   - Default deny: new routes require an explicit policy.
   - Use unguessable identifiers (UUIDv4 or random tokens) in addition to checks, not instead of them.
   - Apply the same checks to files and signed URLs: scope them to the user and give them short expiry.
7. **Add tests.** Encode the matrix as automated tests that run each role against each endpoint and assert the expected status code. A failing cell is a regression.
8. **Add logging.** Log denied access attempts (user, route, object id) without sensitive content, and alert on bursts of denials across many ids.

## Verification

- Re-run the two-account tests from steps 4 and 5. Expected: cross-account and cross-tenant requests return `403` or `404` and change nothing; allowed requests still succeed.
- Run the matrix-driven test suite and confirm it passes. Temporarily remove a check on a scratch branch to confirm the suite fails.
- Search the codebase for direct record loads by id (`findById`, `get(pk=`, `WHERE id =`) and confirm each goes through the scoped helper.
- Confirm that list, search, export, and nested GraphQL fields apply the same scoping.

## Reporting

For each finding: endpoint, role and object tested, expected versus actual result, root cause, fix, test added. Include the final matrix.

## References

- CWE-639 (Authorization Bypass Through User-Controlled Key): https://cwe.mitre.org/data/definitions/639.html
- CWE-862 (Missing Authorization): https://cwe.mitre.org/data/definitions/862.html
- CWE-863 (Incorrect Authorization): https://cwe.mitre.org/data/definitions/863.html
- OWASP Authorization Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html
- Companion skills: `sql-injection-find-and-fix`, `agent-tool-permission-review`.

Helper files

LICENSE
MIT License

Copyright (c) 2026 Saasment

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
references/authz-matrix.md
# Authorization matrix template

License: MIT. Copyright (c) 2026 Saasment.

Fill in one table per resource. Use these cell values: `deny`, `own` (only records the caller owns), `tenant` (any record in the caller's tenant), `all`.

## Example: Invoice

| Role | List | Read | Create | Update | Delete | Export |
| --- | --- | --- | --- | --- | --- | --- |
| Anonymous | deny | deny | deny | deny | deny | deny |
| User | own | own | own | own | deny | own |
| Tenant admin | tenant | tenant | tenant | tenant | tenant | tenant |
| Support | tenant (read only, audited) | tenant | deny | deny | deny | deny |
| Platform admin | all | all | all | all | all | all |

## Test record sheet

| Test id | Actor | Target (owner and tenant) | Operation | Expected | Actual | Result |
| --- | --- | --- | --- | --- | --- | --- |
| IDOR-001 | User B, tenant 1 | Invoice owned by User A, tenant 1 | GET /invoices/{id} | 404 | | |
| IDOR-002 | User C, tenant 2 | Invoice owned by User A, tenant 1 | PUT /invoices/{id} | 404 | | |
| FUNC-001 | User A | Admin report | GET /admin/reports | 403 | | |
| MASS-001 | User A | Own profile | PATCH /me with `{"role":"admin"}` | field ignored or 400 | | |

## Code review checklist per handler

- [ ] Authentication enforced before any work
- [ ] Authorization decision made on the server
- [ ] Record lookup scoped to caller or tenant in the query itself
- [ ] Ownership and role taken from the session or token, not the request body
- [ ] Writable fields come from an allowlist
- [ ] Same policy applied to list, search, export, bulk, and nested fields
- [ ] Denied attempts logged without sensitive data

## Search terms to find unscoped lookups

```text
findById(, findOne({ id, get_object_or_404(, objects.get(pk=, .find(params[:id]), SELECT ... WHERE id =
req.body.userId, req.body.tenantId, req.body.role, params.permit!, @RequestBody entity bound directly to a model
```

Related

Companion skills

Questions

How do I install the Authorization and IDOR review skill?

Download https://www.saasment.com/ai-security/skills/authz-idor-review/download.zip and unzip it into your agent's skills directory (for example .cursor/skills, .claude/skills, .agents/skills, or .github/skills) so that authz-idor-review/SKILL.md exists. Or connect to https://www.saasment.com/api/mcp and call the get_skill tool with the slug authz-idor-review.

What license is the Authorization and IDOR review skill under?

It is original Saasment content under the MIT license, stated in the SKILL.md frontmatter and in the LICENSE file in the skill folder.

Is it safe to run this skill?

A skill is a set of instructions your agent follows, so read SKILL.md first. It tells the agent to test only systems you own or are authorized to test, to use test environments and synthetic data, and to avoid destructive probes. Downloading it does not run any code on your machine.

← All security skills

Try the platform.

Open the demo workspace with mock data. No login. Register from the banner when you want early access. No security team. No call.

Try the platform