# GHSA-XMQ6-3C6Q-FR8M: api-platform/core authorization bypass

- Database: GitHub
- Severity: CVSS 5.9 (Medium)
- Published: 2026-11-16
- Modified: 2026-11-16

## Affected versions

- api-platform/core (Packagist): from 4.1.0, through 5.0.7
- api-platform/state (Packagist): from 4.1.0, through 5.0.7
- api-platform/symfony (Packagist): from 4.1.0, through 5.0.7

## Description

### Summary

In long-running runtimes (FrankenPHP worker mode, the default of the API Platform distribution, RoadRunner, Swoole), three state providers write the values of the current request into the `Link` and `Parameter` objects of the operation metadata that stays in memory for the whole life of the worker. Later requests are then checked, validated or filtered with another request's values:

- **A.** `Link` security can be evaluated with the identifier of another request (authorization bypass).
- **B.** URI variable validation is frozen by the first request of the worker: one anonymous request makes the operation answer 422 to every user, or the constraints are never checked again.
- **C.** An anonymous user can relax a query parameter filter, so that the IRI resolution of later requests discloses hidden resources (a draft's content returned in a comment it was never allowed to reference).

PHP-FPM is not affected. The vulnerable code is present on the 4.1, 4.2, 4.3, 4.4 and 5.0 branches and on `main`; reproduced on 5.0.7. Packages: `api-platform/core`, and the split packages `api-platform/state` and `api-platform/symfony`.

Suggested severity: High, CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L (8.6) for issue C.

### Details

## Root cause

In a long-running process, `CachedResourceMetadataCollectionFactory::$localCache` keeps the resource metadata for the whole life of the worker. The `Operation` a request gets from `_api_operation` holds the same `Link` (URI variable) and `Parameter` objects for every request. `Operation::with*()` clones the operation, but not the `Link` and `Parameter` objects it holds.

Three providers write the value of the current request into those shared objects with `Parameter::setValue()`:

- `SecurityParameterProvider` (`src/State/Provider/SecurityParameterProvider.php`, lines 57-62 on 5.0.7) and `ParameterValidatorProvider` (`src/Symfony/Validator/State/ParameterValidatorProvider.php`, lines 59-64) write the URI variable value into the cached `Link`, **only if it is still empty**:

  ```php
  foreach ($operation->getUriVariables() ?? [] as $key => $uriVariable) {
      if ($uriVariable->getValue() instanceof ParameterNotFound) {
          $uriVariable->setValue($uriVariables[$key] ?? new ParameterNotFound());
      }
      $parameters->add($key, $uriVariable->withKey($key));
  }
  ```

  The first request of the worker sets the value; every later request is checked and validated against it.

- `ParameterProvider` (`src/State/Provider/ParameterProvider.php`, line 102) writes each query or header parameter value into the cached `Parameter`. The value is rewritten on each request that goes through `ParameterProvider`, but it stays in the worker after the request, and it is written before `SecurityParameterProvider` runs. `IriConverter::getResourceFromIri()` (`src/Symfony/Routing/IriConverter.php`, line 131) dispatches the route's item operation to the state provider directly, without `ParameterProvider`, and `ParameterExtension::applyToItem()` (Doctrine ORM) then applies the value left by a previous request.

## Patches

Tested on 5.0.7: with them, every scenario of the proof of concept gives the same result in worker and classic mode, and the filters keep working (`?title=Dune` returns one item, a non-matching item still gives 404).

A and B: clone before writing the value.

```diff
--- a/src/State/Provider/SecurityParameterProvider.php
+++ b/src/State/Provider/SecurityParameterProvider.php
@@
         if ($operation instanceof HttpOperation) {
             foreach ($operation->getUriVariables() ?? [] as $key => $uriVariable) {
+                // withKey() clones: never write the value of this request into the Link of the cached metadata
+                $uriVariable = $uriVariable->withKey($key);
                 if ($uriVariable->getValue() instanceof ParameterNotFound) {
                     $uriVariable->setValue($uriVariables[$key] ?? new ParameterNotFound());
                 }
 
-                $parameters->add($key, $uriVariable->withKey($key));
+                $parameters->add($key, $uriVariable);
             }
         }
```

The same change in `src/Symfony/Validator/State/ParameterValidatorProvider.php`.

C: `ParameterProvider` clones the `Parameters` collection and each `Parameter` before writing values, and continues with `$operation->withParameters()`. A defensive complement would be for `IriConverter::getResourceFromIri()` (or `ParameterExtension` on that path) to apply only the parameter defaults, never a value from another request.

## Workarounds

- A: do not combine `security` with a custom parameter `provider` on a `Link`, or make the provider return `$operation->withUriVariables()` with the cloned `Link`.
- B: replace `Link` `constraints` with route `requirements`.
- C: restrict property-level parameters to the collection operation (`operations: [GetCollection::class]`), and enforce visibility with a Doctrine extension or a voter rather than a parameter `default`.
- All: run the API under PHP-FPM, or restart the workers after each request (`max_requests` 1), until a fixed version is installed.

### Proof of concept

Three standalone Symfony 8.1 / API Platform 5.0.7 applications, each with two FrankenPHP 1.12.7 containers (worker mode with one thread, and classic mode), SQLite, `APP_ENV=prod`, and a `reproduce.sh` that starts each scenario on a fresh worker and prints both modes. I can share the archive, or push it to a temporary private fork.

## A. Link security evaluated with another request's value

```php
#[ApiResource(operations: [
    new Get(uriVariables: ['id' => new Link(fromClass: Report::class, identifiers: ['id'], security: 'id == 1', provider: AuditLinkProvider::class)]),
])]
class Report { /* id, content */ }

final class AuditLinkProvider implements ParameterProviderInterface
{
    public function provide(Parameter $parameter, array $parameters = [], array $context = []): ?Operation
    {
        // logging, decoding... returns null
        return null;
    }
}
```

```
worker : GET /api/reports/1 -> 200 | GET /api/reports/2 -> 200 "confidential report"
classic: GET /api/reports/1 -> 200 | GET /api/reports/2 -> 403 Access Denied.
```

Control: the same `Link` with `security` and no custom provider (`handlePathParameters()` adds `ReadLinkParameterProvider`, which puts a clone back into the operation) gives 200 then 403 in both modes.

## B. URI variable validation frozen by the first request

```php
new Get(uriVariables: ['id' => new Link(fromClass: Book::class, identifiers: ['id'], constraints: [new Assert\Positive()])])
```

```
fresh worker, first request invalid:
worker : GET /api/books/-5 -> 422 | GET /api/books/1 -> 422 | GET /api/books/2 -> 422   (until the worker restarts)
classic: GET /api/books/-5 -> 422 | GET /api/books/1 -> 200 | GET /api/books/2 -> 200

fresh worker, first request valid:
worker : GET /api/books/1 -> 200 | GET /api/books/-5 -> 404   (constraint not checked)
classic: GET /api/books/1 -> 200 | GET /api/books/-5 -> 422
```

## C. A query parameter value relaxes the IRI resolution of later requests

```php
#[ApiResource(operations: [new GetCollection(), new Get()], normalizationContext: ['groups' => ['article:read']])]
class Article
{
    // id, title, body (groups article:read and comment:read)

    #[QueryParameter(
        filter: new ExactFilter(),
        nativeType: new BuiltinType(TypeIdentifier::BOOL),
        castToNativeType: true,
        castToArray: false,
        default: true,
        security: "published == true or is_granted('ROLE_EDITOR')",
        securityMessage: 'Only editors can list drafts.',
    )]
    #[ORM\Column]
    public bool $published = false;
}

#[ApiResource(operations: [new Get(), new Post()],
    normalizationContext: ['groups' => ['comment:read']], denormalizationContext: ['groups' => ['comment:write']])]
class Comment
{
    #[ORM\ManyToOne] #[Groups(['comment:read', 'comment:write'])] public ?Article $article = null;
    #[Groups(['comment:read', 'comment:write'])] public string $body = '';
}
```

Article 1 is published, article 2 is a draft. An anonymous attacker alone, on a fresh worker:

```
a. POST /api/comments {"article": "/api/articles/2"}  -> 400 Item not found for "/api/articles/2".   (classic: 400)
b. GET /api/articles/1?published=false               -> 404 Not Found                              (classic: 404)
c. POST /api/comments {"article": "/api/articles/2"}  -> 201, the response embeds the draft's title and body   (classic: 400)
d. GET /api/comments/1                                -> 200, the draft content is readable by everyone        (classic: 404)
```

Step b fails, but `ParameterProvider` has already written `false` into the cached `Parameter` before `SecurityParameterProvider` denies `GET /api/articles/2?published=false` (403) or the read returns 404. Every later IRI resolution of `/api/articles/{id}` in that worker uses `published = false`, until a request on the same operation goes through `ParameterProvider` again.

Without a relaxing value, the same mechanism turns into errors for other users: after `GET /api/books/1?title=Hyperion` (the `PartialSearchFilter` of the official demo), another user's `POST /api/bookmarks {"book": "/api/books/2"}` gets `400 Item not found`, until a request without the parameter resets it.

### Impact

Applications running API Platform 4.1 to 5.0.7 in a long-running runtime that keeps the kernel between requests: FrankenPHP worker mode (the default of the API Platform distribution), RoadRunner, Swoole. PHP-FPM is not affected.

- **A. Authorization bypass (CWE-863).** Any `Link` with `security` and a custom parameter `provider` (the mechanism recommended in #8491) that returns `null`. The attacker first requests, on a fresh worker, a resource they may read, which freezes the value the security expression is evaluated with, then requests a forbidden one. Suggested vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L (7.6). PR:L when, as usual, the security expression grants each user their own resources: the attacker needs an account that may read at least one resource of that operation. PR:N (8.6) when some resource of the operation is readable anonymously, as in the proof of concept (`id == 1`).
- **B. Denial of service, or validation bypass.** Any `Link` with `constraints`, with no other condition. One anonymous request after a deployment or a worker recycle (`max_requests`) makes the operation answer 422 to every user of that worker; a valid first request disables the constraints instead. Suggested vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (7.5).
- **C. Disclosure of hidden resources, and integrity (CWE-488).** A property-level query or header parameter whose `default` restricts results and another value relaxes them, and a write that resolves the resource from an IRI and returns it. An anonymous attacker alone reads hidden resources and attaches data to them; the parameter `security` does not protect, because the attacker's own denied request already changed the cached value. Direct reads stay protected. Suggested vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L (8.6). Without a relaxing value, any property-level parameter (such as the `title` search of the official demo) makes other users' writes fail with `400 Item not found`.

Found while auditing API Platform with igor-php (https://github.com/igor-php/igor-php), a static analyzer for FrankenPHP worker mode, then confirmed by reading the code and by the reproductions.

## References

- https://github.com/api-platform/core/security/advisories/GHSA-xmq6-3c6q-fr8m

Page: https://cve.now/GHSA-XMQ6-3C6Q-FR8M

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
