Skip to content

fix(auth): reject non-list authorization_details shapes - #243

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/auth-authorization-details-list-shape
Sep 9, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/auth-authorization-details-list-shape

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Follow-up to #242, addressing the two Greptile review comments.

P1 (security): non-list shapes could grant access

A JSON object decodes to an associative PHP array, which passes is_array(). So a map used where RFC 9396 requires a list was still traversed:

  • {"named": {"type": "project", "identifiers": ["p1"]}} — a map of entries at the top level — was accepted as an entry collection and granted p1.
  • {"identifiers": {"alias": "p1"}} — a map-valued field — matched through in_array().

That contradicted the documented "non-list input contributes nothing" contract and could turn a malformed authorization claim into an access grant.

Fix: require list shape with array_is_list() at both levels — the entry collection and each field. Regression cases cover an associative entry collection and an associative field; both now grant nothing, while a valid list-shaped claim still does.

P2 (docs): document the new helper

Added an RFC 9396 section to docs/oauth2.md covering usage, the list-shape guarantee, and the opt-in wildcard semantics, per the package's guidance to document new OAuth2 helpers there rather than in docs/jwt.md.

Tests

bin/monorepo test auth passes (260). bin/monorepo check auth (pint, phpstan, rector) and bin/monorepo validate are clean.

A JSON object decodes to an associative PHP array that passes is_array(), so a
map used where RFC 9396 requires a list was still traversed: a map of entries at
the top level, or a map-valued field, could grant a value. That contradicted the
"non-list input contributes nothing" contract and could turn a malformed claim
into an access grant.

Require list shape at both levels — the entry collection and each field — via
array_is_list(), with regression coverage for associative inputs at each level.

Also documents the helper and its wildcard semantics in docs/oauth2.md, per the
package's guidance to document new OAuth2 helpers there.
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge with no actionable correctness, security, documentation, or test-quality issues identified.

Summary

  • Rejects associative top-level collections and associative value fields so malformed claims cannot grant access.
  • Adds behavioral regression coverage for both malformed shapes.
  • Documents list-shape validation, strict comparisons, common fields, and opt-in wildcard semantics.

@ChiragAgg5k
ChiragAgg5k merged commit 3cf0682 into main Sep 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants