CVE-2025-31481: Api platform/graphql GraphQL Query Operations Security Can Vulnerability

HIGH
Advisory Identifier: GHSA-cg3c-245w-728m
CVSS 7.5
CWE-863
Published
Advisory Summary

CVE-2025-31481 is a HIGH (CVSS 7.5) graphql query operations security can vulnerability (CWE-863: Incorrect Authorization) affecting Api platform/graphql libraries in the Packagist ecosystem. The issue involves graphql query operations security can be bypassed. Remediation is available by upgrading affected packages to version 4.0.22, 3.4.17, 4.1.5.

CVE-2025-31481 at a Glance

CVE Identifier CVE-2025-31481
GHSA Identifier GHSA-cg3c-245w-728m
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-863: Incorrect Authorization
Affected Product Api platform/graphql
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2025-31481

To remediate this vulnerability, upgrade all affected Api platform/graphql dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

api-platform/graphql fixed: 4.0.22
Upgrade api-platform/graphql to 4.0.22
api-platform/core fixed: 4.0.22
Upgrade api-platform/core to 4.0.22
api-platform/graphql fixed: 3.4.17
Upgrade api-platform/graphql to 3.4.17
api-platform/core fixed: 3.4.17
Upgrade api-platform/core to 3.4.17
api-platform/graphql fixed: 4.1.5
Upgrade api-platform/graphql to 4.1.5
api-platform/core fixed: 4.1.5
Upgrade api-platform/core to 4.1.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for api-platform/graphql

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-31481, inspect your project dependencies for Api platform/graphql:

inspect dependencies for api-platform/graphql

Analyze the terminal output to locate any version of Api platform/graphql in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.22), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-863: Incorrect Authorization, where 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. In Api platform/graphql, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary Using the Relay special `node` type you can bypass the configured security on an operation. ### Details Here is an example of how to apply security configurations for the GraphQL operations: ```php #[ApiResource( security: "is_granted('ROLE_USER')", operations: [ /* ... */ ], graphQlOperations: [ new Query(security: "is_granted('ROLE_USER')"), //... ], )] class Book { /* ... */ } ``` This indeed checks `is_granted('ROLE_USER')` as expected for a GraphQL query like the following: ```php ‌query { book(id: "/books/1") { title } } ``` But the security check can be bypassed by using the `node` field (that is available by default) on the root query type like that: ```php ‌query { node(id: "/books/1") { ... on Book { title } } } ``` This does not execute any security checks and can therefore be used to access any entity without restrictions by everyone that has access to the API. ### Impact Everyone using GraphQl with the `security` attribute. Not sure whereas this works with custom resolvers nor if this also applies on mutation. Patched at https://github.com/api-platform/core/commit/60747cc8c2fb855798c923b5537888f8d0969568

CVE-2025-31481 Affected Api platform/graphql Versions

6 component(s)
Fixed Versions:
4.0.223.4.174.1.5
Product / Package Ecosystem Affected Versions Fixed Version
api-platform/graphql
Packagist
≥ 4.0.0-alpha.1
< 4.0.22
4.0.22
api-platform/core
Packagist
≥ 4.0.0-alpha.1
< 4.0.22
4.0.22
api-platform/graphql
Packagist
< 3.4.17
3.4.17
api-platform/core
Packagist
< 3.4.17
3.4.17
api-platform/graphql
Packagist
≥ 4.1.0-alpha.1
< 4.1.5
4.1.5
api-platform/core
Packagist
≥ 4.1.0-alpha.1
< 4.1.5
4.1.5

References

Frequently Asked Questions

What is CVE-2025-31481?
CVE-2025-31481 is a security vulnerability in Api platform/graphql involving GraphQL query operations security can be bypassed under CWE-863: Incorrect Authorization.
Which Api platform/graphql versions are affected?
Affected versions include releases prior to 4.0.22, 3.4.17, 4.1.5 across affected packages: api-platform/graphql, api-platform/core.
What version fixes CVE-2025-31481?
Upgrading to 4.0.22, 3.4.17, 4.1.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is api-platform/graphql affected?
Yes, api-platform/graphql is affected in releases prior to 4.0.22, 3.4.17, 4.1.5. Upgrade your dependency to 4.0.22, 3.4.17, 4.1.5 or later.
Is api-platform/core affected?
Yes, api-platform/core is affected in releases prior to 4.0.22, 3.4.17, 4.1.5. Upgrade your dependency to 4.0.22, 3.4.17, 4.1.5 or later.
What is the CVSS score of CVE-2025-31481?
CVE-2025-31481 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2025-31481?
CVE-2025-31481 is classified under CWE-863: Incorrect 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.).
How can I check Packagist dependencies for CVE-2025-31481?
Run the dependency tree command: 'inspect dependencies for api-platform/graphql'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cg3c-245w-728m",
  "modified" : "2025-08-29T21:07:09Z",
  "published" : "2025-04-04T14:07:20Z",
  "aliases" : [ "CVE-2025-31481" ],
  "summary" : "GraphQL query operations security can be bypassed",
  "details" : "### Summary\n\nUsing the Relay special `node` type you can bypass the configured security on an operation.\n\n### Details\n\nHere is an example of how to apply security configurations for the GraphQL operations:\n\n```php\n#[ApiResource(\n    security: \"is_granted('ROLE_USER')\",\n    operations: [ /* ... */ ],\n    graphQlOperations: [\n        new Query(security: \"is_granted('ROLE_USER')\"),\n        //...\n    ],\n)]\nclass Book { /* ... */ }\n```\n\nThis indeed checks `is_granted('ROLE_USER')` as expected for a GraphQL query like the following:\n\n```php\n‌query {\n    book(id: \"/books/1\") {\n        title\n    }\n}\n```\n\nBut the security check can be bypassed by using the `node` field (that is available by default) on the root query type like that:\n\n```php\n‌query {\n    node(id: \"/books/1\") {\n        ... on Book {\n            title\n        }\n    }\n}\n```\n\nThis does not execute any security checks and can therefore be used to access any entity without restrictions by everyone that has access to the API.\n\n### Impact\n\nEveryone using GraphQl with the `security` attribute. Not sure whereas this works with custom resolvers nor if this also applies on mutation.\n\nPatched at https://github.com/api-platform/core/commit/60747cc8c2fb855798c923b5537888f8d0969568",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "api-platform/graphql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0-alpha.1"
      }, {
        "fixed" : "4.0.22"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "api-platform/core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0-alpha.1"
      }, {
        "fixed" : "4.0.22"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "api-platform/graphql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.4.17"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "api-platform/core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.4.17"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "api-platform/graphql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.1.0-alpha.1"
      }, {
        "fixed" : "4.1.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "api-platform/core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.1.0-alpha.1"
      }, {
        "fixed" : "4.1.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/api-platform/core/security/advisories/GHSA-cg3c-245w-728m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-31481"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/api-platform/core/commit/55712452b4f630978537bdb2a07dc958202336bb"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/api-platform/core/commit/60747cc8c2fb855798c923b5537888f8d0969568"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/api-platform/core/CVE-2025-31481.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/api-platform/graphql/CVE-2025-31481.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/api-platform/core"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/api-platform/core/releases/tag/v3.4.17"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/api-platform/core/releases/tag/v4.1.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-863" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-04-04T14:07:20Z",
    "nvd_published_at" : "2025-04-03T20:15:25Z"
  }
}