Laravel: Sanctum guard can resolve the lowest-ID user when evaluated inside an eager-loaded Eloquent relation definition
Package Affected versions Patched versions Description Impact When an authenticated user is first resolved while Eloquent is initializing an eager-loaded relation, Eloquent's relation constraints are
Package
laravel/framework (Composer)Affected versions
< 12.73.0Patched versions
12.73.0Description
Impact
When an authenticated user is first resolved while Eloquent is initializing an eager-loaded relation, Eloquent's relation constraints are temporarily disabled. A lazy key-constrained lookup made during that window, such as Sanctum's token owner lookup, runs without its key restriction. The guard can then return the lowest-ID user (often an administrator) instead of the token's owner. This affects applications that call the guard inside a relation definition used with eager loading, for example in optional-authentication routes. A low-privilege token could then read that user's data, and the wrong user remains cached for the rest of the request. Routes where authentication middleware resolves the user first were not affected in testing.
Patches
The fix for the 12.x branch has been merged in laravel/framework#62483, which keeps constraints enabled when nested relation attributes are resolved during eager-load relation initialization.
Workarounds
Avoid resolving the authenticated user inside relation definitions. Resolve the user ID beforehand and pass it explicitly through an eager-load constraint closure.
References
- GHSA-vfxr-r8f8-gfmp
- https://nvd.nist.gov/vuln/detail/CVE-2026-142636
- laravel/framework#62483
- laravel/framework@6ea0fda
- https://github.com/laravel/framework/releases/tag/v12.73.0
Severity
Moderate CVSS overall score This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS). / 10CVSS v3 base metrics
Attack vector Network Attack complexity High Privileges required Low User interaction None Scope Unchanged Confidentiality High Integrity High Availability None CVSS v3 base metrics Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability. Attack complexity: More severe for the least complex attacks. Privileges required: More severe if no privileges are required. User interaction: More severe when no user interaction is required. Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope. Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user. Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user. Availability: More severe when the loss of impacted component availability is highest. CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:NEPSS score
Weaknesses
Weakness CWE-863Incorrect Authorization
The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. Learn more on MITRE.CVE ID
CVE-2026-142636GHSA ID
GHSA-vfxr-r8f8-gfmpSource code
laravel/frameworkCredits
-
AzhariRamadhan Reporter
Uh oh!
There was an error while loading. Please reload this page.
See something to contribute? Suggest improvements for this vulnerability.