CVE-2026-54164: CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') in api-platform core
## Summary The API Platform serializer's `AbstractItemNormalizer` does not validate the resource type returned when resolving relation IRIs, allowing type confusion where a resource of an unintended type can be silently assigned to a relation property. ## Impact An attacker who can submit write requests (POST/PUT/PATCH) to an API Platform endpoint with writable relations can supply a relation IRI pointing to a resource of a different type than the relation's declared class. Because `getResourceFromIri()` does not pass an `$operation` to `IriConverter::getResourceFromIri()`, the `is_a` type guard at `IriConverter.php:86` is skipped. For untyped relation properties (legacy `@var`-only style), the wrong-typed object is silently assigned, corrupting invariants and potentially feeding downstream logic that assumes the declared type (CWE-843). For typed properties (modern PHP 8.x), the substitution is blocked by Symfony's PropertyAccessor with an `InvalidTypeException`. ## Affected versions - `api-platform/core` `< 4.1.30` - `api-platform/core` `>= 4.2.0, < 4.2.26` - `api-platform/core` `>= 4.3.0, < 4.3.12` Older major series (`2.x`, `3.x`) ship the same vulnerable code path and are end-of-life; no fix is planned. ## Patched versions - `4.1.30` - `4.2.26` - `4.3.12` ## Fix An `is_a` guard is added inside `AbstractItemNormalizer::getResourceFromIri()` (and the equivalent inline call sites on 4.1) so that a mismatched IRI throws `InvalidArgumentException`, mirroring the operation-aware check the `IriConverter` already performs when an operation is supplied. This forces a `400 Bad Request` response for cross-type IRIs instead of a silent assignment. ## Workarounds Declare a PHP type on every writable relation property (e.g. `public ?Foo $relation = null;` instead of `@var Foo $relation`). Symfony's `PropertyAccessor` will then reject a mismatched object with `InvalidTypeException`. This does not cover collections of mixed-type interfaces; upgrading to a patched version is the only complete fix. ## Proof of concept A functional test posts a `Bar` IRI to a `Foo`-declared relation on an untyped property. Without the fix the server responds with `HTTP 201` and the Bar IRI appears in the response payload. With the fix the server responds with `HTTP 400` (`Invalid IRI "/bars/1"`). Full PoC: `tests/Functional/Security/TypeConfusionRelationIriTest.php` in the patched branches. ## References - `src/Serializer/AbstractItemNormalizer.php` — vulnerable relation IRI load - `src/Symfony/Routing/IriConverter.php` — conditional `is_a` guard (operation-aware path) ## Credit Reported by @alexandre-daubois.
AI Analysis
Technical Summary
The API Platform serializer's AbstractItemNormalizer does not validate the resource type returned when resolving relation IRIs, allowing type confusion (CWE-843). An attacker able to submit write requests to endpoints with writable relations can supply a relation IRI pointing to a resource of a different type than declared. Because getResourceFromIri() lacks an operation parameter, the is_a type guard in IriConverter is skipped, allowing silent assignment of wrong-typed objects to untyped relation properties. This corrupts invariants and may cause downstream logic errors. Typed PHP 8.x properties prevent this by throwing InvalidTypeException. The vulnerability affects api-platform/core versions <4.1.30, >=4.2.0 <4.2.26, and >=4.3.0 <4.3.12. Older major versions 2.x and 3.x are also vulnerable but end-of-life with no planned fix. The patch adds an is_a guard in AbstractItemNormalizer::getResourceFromIri() to throw InvalidArgumentException on mismatched IRIs, resulting in a 400 Bad Request response instead of silent assignment. Workarounds include declaring PHP types on writable relation properties to leverage Symfony's PropertyAccessor type checks, but upgrading to a patched version is the only complete fix.
Potential Impact
An attacker with permission to submit write requests (POST/PUT/PATCH) to API Platform endpoints with writable relations can cause type confusion by assigning a resource of an unintended type to a relation property. This can silently corrupt application invariants and potentially cause incorrect behavior in downstream logic that assumes the declared type. The vulnerability does not impact confidentiality or availability directly but can lead to integrity issues. Typed properties in PHP 8.x mitigate the issue by throwing exceptions, but untyped properties remain vulnerable. There are no known exploits in the wild.
Mitigation Recommendations
A fix is available in api-platform/core versions 4.1.30, 4.2.26, and 4.3.12 that adds a type guard to reject mismatched IRIs with a 400 Bad Request error. Users should upgrade to one of these patched versions to fully remediate the vulnerability. As a partial workaround, declaring explicit PHP types on all writable relation properties will cause Symfony's PropertyAccessor to reject mismatched types with an InvalidTypeException, but this does not cover collections of mixed-type interfaces. Older major versions 2.x and 3.x are end-of-life and have no planned fixes, so upgrading is strongly recommended.
CVE-2026-54164: CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') in api-platform core
Description
## Summary The API Platform serializer's `AbstractItemNormalizer` does not validate the resource type returned when resolving relation IRIs, allowing type confusion where a resource of an unintended type can be silently assigned to a relation property. ## Impact An attacker who can submit write requests (POST/PUT/PATCH) to an API Platform endpoint with writable relations can supply a relation IRI pointing to a resource of a different type than the relation's declared class. Because `getResourceFromIri()` does not pass an `$operation` to `IriConverter::getResourceFromIri()`, the `is_a` type guard at `IriConverter.php:86` is skipped. For untyped relation properties (legacy `@var`-only style), the wrong-typed object is silently assigned, corrupting invariants and potentially feeding downstream logic that assumes the declared type (CWE-843). For typed properties (modern PHP 8.x), the substitution is blocked by Symfony's PropertyAccessor with an `InvalidTypeException`. ## Affected versions - `api-platform/core` `< 4.1.30` - `api-platform/core` `>= 4.2.0, < 4.2.26` - `api-platform/core` `>= 4.3.0, < 4.3.12` Older major series (`2.x`, `3.x`) ship the same vulnerable code path and are end-of-life; no fix is planned. ## Patched versions - `4.1.30` - `4.2.26` - `4.3.12` ## Fix An `is_a` guard is added inside `AbstractItemNormalizer::getResourceFromIri()` (and the equivalent inline call sites on 4.1) so that a mismatched IRI throws `InvalidArgumentException`, mirroring the operation-aware check the `IriConverter` already performs when an operation is supplied. This forces a `400 Bad Request` response for cross-type IRIs instead of a silent assignment. ## Workarounds Declare a PHP type on every writable relation property (e.g. `public ?Foo $relation = null;` instead of `@var Foo $relation`). Symfony's `PropertyAccessor` will then reject a mismatched object with `InvalidTypeException`. This does not cover collections of mixed-type interfaces; upgrading to a patched version is the only complete fix. ## Proof of concept A functional test posts a `Bar` IRI to a `Foo`-declared relation on an untyped property. Without the fix the server responds with `HTTP 201` and the Bar IRI appears in the response payload. With the fix the server responds with `HTTP 400` (`Invalid IRI "/bars/1"`). Full PoC: `tests/Functional/Security/TypeConfusionRelationIriTest.php` in the patched branches. ## References - `src/Serializer/AbstractItemNormalizer.php` — vulnerable relation IRI load - `src/Symfony/Routing/IriConverter.php` — conditional `is_a` guard (operation-aware path) ## Credit Reported by @alexandre-daubois.
CVSS v3.1
Score 6.5medium
Affected software
pkg:github/api-platform/coreRun on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The API Platform serializer's AbstractItemNormalizer does not validate the resource type returned when resolving relation IRIs, allowing type confusion (CWE-843). An attacker able to submit write requests to endpoints with writable relations can supply a relation IRI pointing to a resource of a different type than declared. Because getResourceFromIri() lacks an operation parameter, the is_a type guard in IriConverter is skipped, allowing silent assignment of wrong-typed objects to untyped relation properties. This corrupts invariants and may cause downstream logic errors. Typed PHP 8.x properties prevent this by throwing InvalidTypeException. The vulnerability affects api-platform/core versions <4.1.30, >=4.2.0 <4.2.26, and >=4.3.0 <4.3.12. Older major versions 2.x and 3.x are also vulnerable but end-of-life with no planned fix. The patch adds an is_a guard in AbstractItemNormalizer::getResourceFromIri() to throw InvalidArgumentException on mismatched IRIs, resulting in a 400 Bad Request response instead of silent assignment. Workarounds include declaring PHP types on writable relation properties to leverage Symfony's PropertyAccessor type checks, but upgrading to a patched version is the only complete fix.
Potential Impact
An attacker with permission to submit write requests (POST/PUT/PATCH) to API Platform endpoints with writable relations can cause type confusion by assigning a resource of an unintended type to a relation property. This can silently corrupt application invariants and potentially cause incorrect behavior in downstream logic that assumes the declared type. The vulnerability does not impact confidentiality or availability directly but can lead to integrity issues. Typed properties in PHP 8.x mitigate the issue by throwing exceptions, but untyped properties remain vulnerable. There are no known exploits in the wild.
Mitigation Recommendations
A fix is available in api-platform/core versions 4.1.30, 4.2.26, and 4.3.12 that adds a type guard to reject mismatched IRIs with a 400 Bad Request error. Users should upgrade to one of these patched versions to fully remediate the vulnerability. As a partial workaround, declaring explicit PHP types on all writable relation properties will cause Symfony's PropertyAccessor to reject mismatched types with an InvalidTypeException, but this does not cover collections of mixed-type interfaces. Older major versions 2.x and 3.x are end-of-life and have no planned fixes, so upgrading is strongly recommended.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-06-11T21:46:52.380Z
- Cvss Version
- 3.1
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a456fd127e9c79719097e66
Added to database: 07/01/2026, 19:51:45 UTC
Last enriched: 08/08/2026, 15:38:43 UTC
Last updated: 08/14/2026, 00:41:13 UTC
Views: 91
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.