# GHSA-35F3-VW58-447M: GraphQL: a mutation denied by securityPostDenormalize (or failing validation) is persisted by a later mutation in the same request

- Database: GitHub
- Severity: CVSS 6.5 (Medium)
- Published: 2026-11-06
- Modified: 2026-11-06

## Affected versions

- api-platform/core (Packagist): fixed in 4.4.7
- api-platform/core (Packagist): from 5.0.0, fixed in 5.0.6
- api-platform/graphql (Packagist): fixed in 4.4.7
- api-platform/graphql (Packagist): from 5.0.0, fixed in 5.0.6
- api-platform/symfony (Packagist): fixed in 4.4.7
- api-platform/symfony (Packagist): from 5.0.0, fixed in 5.0.6

## Description

## Affected product
- Ecosystem: Composer
- Packages: `api-platform/core`; for split installations `api-platform/graphql` together with `api-platform/doctrine-orm` / `api-platform/doctrine-common`
- Affected versions: verified on **4.3.21, 4.4.6 and 5.0.5**. Older versions are probably affected (same pipeline), but this is not verified.
- Patched versions: none known

## Severity (reporter's estimate)
- Medium–High. CVSS 3.1 `AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N` (6.5).
- The attacker needs an account that may run *some* flushing mutation, which is any authenticated user in most applications.
- CWE-863 (Incorrect Authorization), CWE-696 (Incorrect Behavior Order)

## Description

A GraphQL request may contain one mutation operation with several root fields. Per the GraphQL spec they run serially in the same HTTP request, so all of them share one Doctrine object manager.

For an update mutation, API Platform loads the managed entity, denormalizes the input **onto that managed entity** (`OBJECT_TO_POPULATE`, `ApiPlatform\GraphQl\State\Provider\DenormalizeProvider:47` in 4.4.6), and only then runs `securityPostDenormalize` (`ApiPlatform\Symfony\Security\State\AccessCheckerProvider`, which throws `AccessDeniedHttpException` at l.112) and validation.

When that mutation is denied or invalid, its field resolves to an error, but the entity stays managed and dirty. The next root field's processor calls `flush()` on the same manager (`ApiPlatform\Doctrine\Common\State\PersistProcessor:137`), which writes the denied or invalid changes to the database.

This breaks the guarantee that `securityPostDenormalize` (and `securityPostValidation`, and validation) prevent the write. In #8429 (closed on 2026-09-28) the conclusion was that "a real HTTP client never hits this, because every request gets its own object manager". That premise holds for REST, but not for GraphQL documents with several mutation root fields: one HTTP request, one object manager, several mutations.

Batched JSON-array requests are not affected. They are rejected with "GraphQL query is not valid." (400) by `EntrypointAction::parseData()`.

## Reproduction (standalone, no application code besides two entities)

Fresh `symfony/skeleton` 8.1, `api-platform/symfony` + `doctrine-orm` + `graphql` (all split packages on the same version), `symfony/security-bundle`, `symfony/validator`, SQLite, `api_platform.graphql.enabled: true`, no authentication (anonymous `NullToken`).

```php
#[ORM\Entity]
#[ApiResource(operations: [], graphQlOperations: [
    new Query(),
    new Mutation(name: 'update', securityPostDenormalize: "is_granted('ROLE_ADMIN')"),
])]
class Note { #[ORM\Id, ORM\GeneratedValue, ORM\Column] private ?int $id = null; #[ORM\Column] private string $title = ''; /* getters/setters */ }

#[ORM\Entity]
#[ApiResource(operations: [], graphQlOperations: [new Query(), new Mutation(name: 'create'), new Mutation(name: 'update')])]
class Log { #[ORM\Id, ORM\GeneratedValue, ORM\Column] private ?int $id = null; #[ORM\Column] #[Assert\Length(max: 10)] private string $message = ''; /* getters/setters */ }
```

Seed `Note#1` (`title = "original"`) and `Log#1` (`message = "original"`). Each request below is sent on a fresh kernel.

```graphql
# 1) denied update alone
mutation { a: updateNote(input: {id: "/api/notes/1", title: "changed"}) { note { id } } }
# 2) the same, followed by an unrelated mutation the caller may run
mutation {
  a: updateNote(input: {id: "/api/notes/1", title: "changed"}) { note { id } }
  b: createLog(input: {message: "ok"}) { log { id } }
}
# 3) validation variant
mutation {
  a: updateLog(input: {id: "/api/logs/1", message: "far too long message"}) { log { id } }
  b: createLog(input: {message: "ok"}) { log { id } }
}
```

Observed (identical on 4.3.21, 4.4.6 and 5.0.5):

| request | response | database afterwards |
| --- | --- | --- |
| 1 | `a`: "Access Denied." (403) | `note.title = original` |
| 2 | `a`: "Access Denied." (403), `b`: created | **`note.title = changed`** |
| 3 | `a`: "message: This value is too long…" (422), `b`: created | **`log#1.message = far too long message`** |
| 2 with `securityPostValidation` instead of `securityPostDenormalize` | `a`: "Access Denied." (403), `b`: created | **changed** |
| 2 with the root fields in reverse order (`b` first) | `a`: 403 | `original` (nothing flushes after `a`) |

Expected: requests 2 and 3 behave like request 1. A field that resolves to an access-denied or validation error must not result in a write.

## Impact
- Any `securityPostDenormalize` / `securityPostValidation` rule on a GraphQL mutation can be bypassed by an authenticated user who appends any flushing mutation they are allowed to run.
- Constraint validation on GraphQL mutations can be bypassed the same way, so invalid data is persisted.
- Operations protected only by `security` (evaluated before denormalization) are not affected, because the entity is not modified before the denial.

## Suggested fix (for the maintainers to judge)
1. Do not leave a denormalized managed object behind when a GraphQL mutation fails after denormalization. For example, when the provider/processor chain of a mutation throws, refresh or detach the object that was populated, together with the objects populated through nested writable relations.
2. Alternatively, denormalize mutations into a copy and apply the result to the managed object only after `securityPostDenormalize`, validation and `securityPostValidation` have passed.
3. At minimum, document the risk and ship an opt-in validation rule that limits mutation operations to a single root field (see Workaround).

## Workaround
Reject mutation operations with more than one root field with a GraphQL validation rule, for example a rule that collects the root response keys of `mutation` operations (expanding fragments, ignoring `__typename`) and reports an error when there is more than one. Register it by decorating `api_platform.graphql.executor` and passing `[...DocumentValidator::allRules(), new SingleRootFieldMutation()]` as `$validationRules`.

Validation errors abort the whole document before execution, so none of the fields runs. Single mutations, queries with several root fields and introspection are unaffected. Where possible, prefer `security` over `securityPostDenormalize`.

## References

- https://github.com/api-platform/core/security/advisories/GHSA-35f3-vw58-447m

Page: https://cve.now/GHSA-35F3-VW58-447M

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