Scope-Limited Token Function Check
Verify that token scopes match the operations they permit, so a read-only or narrow scope never silently unlocks privileged functions
Use when: the API supports scoped tokens, OAuth scopes or machine-service credentials that callers may hold at reduced width
Avoid when: authorization works purely on sessions and roles without any scope dimension to model
Procedure
- List all scopes the product issues, then outline which operations each scope should permit per the documentation.
- Issue narrow tokens for your own account or machine-credentials and compare observed permitted set against expectations.
- For read-only credentials, replay them against every mutating operation you can reach and record the outcomes.
- Check scope-to-route-granularity: whether a scope gates an entire path family or the whole backend surface.
- Look for operations that accept a scope-limited credential but behave in ways the scope family never advertised.
- Build a scope-by-permission matrix so a reviewer can see which pairings are intended, redundant or unguarded.
Signals
- A read-only narrow credential invokes an operation that writes or dispatches something the documentation never mentioned.
- One scope serves every operation in a path family, so revoking a specific width requires revoking a much broader grant.
- Operations ignore the scope dimension entirely, so scope is descriptive echo rather than a real authorization actor.
- Two scopes claim separation in the docs but a single token with one of them links both families' resources.
Patterns
1. Scope bin
scope=read:orders -> GET ok, POST /api/orders/status-change 200 -> read-only violated
2. Granularity row
scopes apply at: route(3) path-family(5) resource(12) -> family-middle operations avoid per-scope checks
3. Result row
scope=read:orders routes=23 writes-permitted=2 ops=status-change,export
Pitfalls
- Testing with the owner's full-privileged service-token and calling that a scope test, which proves nothing.
- Missing machine-to-machine flows where a scope check exists only at ingress and not at the operation.
- Forgetting refresh-token behavior, where a refreshed narrower credential can quietly widen its scope family.
Done when
- Every issued scope family has been tested against operations both inside and outside its documented width.
- A written scope x permission matrix is available and matches the observed outcomes before any report goes out.