Skip to main content
Menu
Advisories

Policy-protected properties leak across users via the attribute cache

GHSA-CWHH-732Q-P35CPublished Updated GitHub

Description

AbstractItemNormalizer::isCacheKeySafe() decides whether a resource's allowed-property list can be cached and reused, but it checks only getSecurity() and never getPolicy(). A property guarded solely by #[ApiProperty(policy: ...)] is still access-checked per object by canAccessAttribute() (which reads getSecurity() ?? getPolicy()), yet its class is treated as cache-safe, so the first object's decision is cached and reused for later objects and later requests. A user can then read another user's policy-protected field. isCacheKeySafe() was added to fix GHSA-pjhx-3c3w-9v23 for security, and never covered policy.

Proof of concept

Reproduced on api-platform/core 5.0.3 from Packagist, through the published ApiPlatform\Hal\Serializer\ItemNormalizer. A resource has a property guarded only by policy whose checker grants it to the owner alone. The owner serializes their own item and the property is included. A second viewer who owns nothing then serializes the same item through the same normalizer instance (a long-running worker: Octane, RoadRunner, Swoole, or a persistent Symfony kernel), and gets the owner's value back.

owner   /accounts/1  -> {"id":1,"name":"Alice","ssn":"SSN-111-ALICE"}   (owner, allowed)
viewer  /accounts/1  -> {"id":1,"name":"Alice","ssn":"SSN-111-ALICE"}   (not owner, leaked)

The checker is consulted once for /accounts/1, not twice. Switch the property from policy to security and isCacheKeySafe() returns false, the cache is skipped, and the second viewer correctly gets no ssn. Same object-dependent check, enforced identically, gated differently.

Impact

A viewer reads a property their own policy forbids, because an earlier request cached an authorized viewer's decision for that resource class. In the Laravel bridge policy is the only way to guard a property, so any Laravel app doing so on a long-running worker is affected under default config. The fix is to have isCacheKeySafe() also return false when getPolicy() is set.

Affected versions

References

GitHub · api-platform/core