{"id":"GHSA-cg3c-245w-728m","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\u200cquery {\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\u200cquery {\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","aliases":["CVE-2025-31481"],"modified":"2025-08-29T21:35:33.406512Z","published":"2025-04-04T14:07:20Z","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"},"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"}],"affected":[{"package":{"name":"api-platform/graphql","ecosystem":"Packagist","purl":"pkg:composer/api-platform/graphql"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0.0-alpha.1"},{"fixed":"4.0.22"}]}],"versions":["v4.0.0","v4.0.0-alpha.1","v4.0.0-alpha.2","v4.0.0-alpha.3","v4.0.0-alpha.4","v4.0.0-alpha.5","v4.0.0-alpha.6","v4.0.0-alpha.7","v4.0.0-beta.1","v4.0.0-beta.2","v4.0.1","v4.0.10","v4.0.11","v4.0.12","v4.0.13","v4.0.14","v4.0.15","v4.0.16","v4.0.17","v4.0.18","v4.0.19","v4.0.2","v4.0.20","v4.0.21","v4.0.3","v4.0.4","v4.0.5","v4.0.6","v4.0.7","v4.0.8","v4.0.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-cg3c-245w-728m/GHSA-cg3c-245w-728m.json"}},{"package":{"name":"api-platform/core","ecosystem":"Packagist","purl":"pkg:composer/api-platform/core"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0.0-alpha.1"},{"fixed":"4.0.22"}]}],"versions":["v4.0.0","v4.0.0-alpha.1","v4.0.0-alpha.2","v4.0.0-alpha.3","v4.0.0-alpha.4","v4.0.0-alpha.5","v4.0.0-alpha.6","v4.0.0-alpha.7","v4.0.0-beta.1","v4.0.0-beta.2","v4.0.1","v4.0.10","v4.0.11","v4.0.12","v4.0.13","v4.0.14","v4.0.15","v4.0.16","v4.0.17","v4.0.18","v4.0.19","v4.0.2","v4.0.20","v4.0.21","v4.0.3","v4.0.4","v4.0.5","v4.0.6","v4.0.7","v4.0.8","v4.0.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-cg3c-245w-728m/GHSA-cg3c-245w-728m.json"}},{"package":{"name":"api-platform/graphql","ecosystem":"Packagist","purl":"pkg:composer/api-platform/graphql"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"3.4.17"}]}],"versions":["v3.2.0-beta.1","v3.2.1","v3.2.10","v3.2.11","v3.2.12","v3.2.2","v3.2.25","v3.2.3","v3.2.4","v3.2.5","v3.2.6","v3.2.7","v3.2.8","v3.2.9","v3.3.0-alpha.1","v3.3.0-beta.1","v3.3.11","v3.3.13","v3.3.14","v3.3.15","v3.3.3","v3.3.4","v3.3.6","v3.3.7","v3.3.8","v3.3.9","v3.4.0","v3.4.0-alpha.1","v3.4.0-alpha.2","v3.4.0-alpha.3","v3.4.0-alpha.4","v3.4.0-alpha.5","v3.4.0-alpha.6","v3.4.0-alpha.7","v3.4.0-beta.1","v3.4.1","v3.4.10","v3.4.11","v3.4.13","v3.4.14","v3.4.15","v3.4.16","v3.4.2","v3.4.3","v3.4.4","v3.4.5","v3.4.6","v3.4.7","v3.4.8","v3.4.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-cg3c-245w-728m/GHSA-cg3c-245w-728m.json"}},{"package":{"name":"api-platform/core","ecosystem":"Packagist","purl":"pkg:composer/api-platform/core"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"3.4.17"}]}],"versions":["v1.0.0","v1.0.0-beta","v1.0.0-beta.2","v1.0.0-beta.3","v1.0.1","v1.1.0","v1.1.0-beta.1","v1.1.0-beta.2","v1.1.1","v2.0.0","v2.0.0-alpha.1","v2.0.0-alpha.2","v2.0.0-beta.1","v2.0.0-beta.2","v2.0.0-beta.3","v2.0.0-rc.1","v2.0.0-rc.2","v2.0.0-rc.3","v2.0.0-rc.4","v2.0.0-rc.5","v2.0.0-rc.6","v2.0.1","v2.0.10","v2.0.11","v2.0.2","v2.0.3","v2.0.4","v2.0.5","v2.0.6","v2.0.7","v2.0.8","v2.0.9","v2.1.0","v2.1.0-beta.1","v2.1.0-beta.2","v2.1.1","v2.1.2","v2.1.3","v2.1.4","v2.1.5","v2.1.6","v2.2.0","v2.2.0-beta.1","v2.2.0-beta.2","v2.2.1","v2.2.10","v2.2.2","v2.2.3","v2.2.4","v2.2.5","v2.2.6","v2.2.7","v2.2.8","v2.2.9","v2.3.0","v2.3.0-beta.1","v2.3.1","v2.3.2","v2.3.3","v2.3.4","v2.3.5","v2.3.6","v2.4.0","v2.4.0-beta.1","v2.4.0-beta.2","v2.4.1","v2.4.2","v2.4.3","v2.4.4","v2.4.5","v2.4.6","v2.4.7","v2.5.0","v2.5.0-beta.1","v2.5.0-beta.2","v2.5.1","v2.5.10","v2.5.2","v2.5.3","v2.5.4","v2.5.5","v2.5.6","v2.5.7","v2.5.8","v2.5.9","v2.6.0","v2.6.0-alpha.1","v2.6.0-beta.1","v2.6.1","v2.6.2","v2.6.3","v2.6.3-alpha.1","v2.6.3.alpha","v2.6.4","v2.6.5","v2.6.6","v2.6.7","v2.6.8","v2.7.0","v2.7.0-alpha.1","v2.7.0-alpha.2","v2.7.0-alpha.3","v2.7.0-alpha.4","v2.7.0-alpha.5","v2.7.0-alpha.6","v2.7.0-alpha.7","v2.7.0-beta.1","v2.7.0-beta.2","v2.7.0-beta.3","v2.7.0-beta.4","v2.7.0-beta.5","v2.7.0-rc.1","v2.7.0-rc.2","v2.7.1","v2.7.10","v2.7.11","v2.7.12","v2.7.13","v2.7.14","v2.7.15","v2.7.16","v2.7.17","v2.7.18","v2.7.2","v2.7.3","v2.7.4","v2.7.5","v2.7.6","v2.7.7","v2.7.8","v2.7.9","v3.0.0","v3.0.0-beta.1","v3.0.0-beta.2","v3.0.0-rc.1","v3.0.0-rc.2","v3.0.1","v3.0.10","v3.0.11","v3.0.12","v3.0.2","v3.0.3","v3.0.4","v3.0.5","v3.0.6","v3.0.7","v3.0.8","v3.0.9","v3.1.0","v3.1.1","v3.1.10","v3.1.11","v3.1.12","v3.1.13","v3.1.14","v3.1.15","v3.1.16","v3.1.17","v3.1.18","v3.1.19","v3.1.2","v3.1.20","v3.1.21","v3.1.22","v3.1.23","v3.1.24","v3.1.25","v3.1.26","v3.1.27","v3.1.28","v3.1.29","v3.1.3","v3.1.4","v3.1.5","v3.1.6","v3.1.7","v3.1.8","v3.1.9","v3.2.0","v3.2.0-alpha.1","v3.2.0-alpha.2","v3.2.0-beta.1","v3.2.0-beta.2","v3.2.1","v3.2.10","v3.2.11","v3.2.12","v3.2.13","v3.2.14","v3.2.15","v3.2.16","v3.2.17","v3.2.18","v3.2.19","v3.2.2","v3.2.20","v3.2.21","v3.2.22","v3.2.23","v3.2.24","v3.2.25","v3.2.26","v3.2.3","v3.2.4","v3.2.5","v3.2.6","v3.2.7","v3.2.8","v3.2.9","v3.3.0","v3.3.0-alpha.1","v3.3.0-alpha.2","v3.3.0-beta.1","v3.3.0-beta.2","v3.3.1","v3.3.10","v3.3.11","v3.3.12","v3.3.13","v3.3.14","v3.3.15","v3.3.2","v3.3.3","v3.3.4","v3.3.5","v3.3.6","v3.3.7","v3.3.8","v3.3.9","v3.4.0","v3.4.0-alpha.1","v3.4.0-alpha.2","v3.4.0-alpha.3","v3.4.0-alpha.4","v3.4.0-alpha.5","v3.4.0-alpha.6","v3.4.0-alpha.7","v3.4.0-beta.1","v3.4.1","v3.4.10","v3.4.11","v3.4.14","v3.4.15","v3.4.16","v3.4.2","v3.4.3","v3.4.4","v3.4.5","v3.4.6","v3.4.7","v3.4.8","v3.4.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-cg3c-245w-728m/GHSA-cg3c-245w-728m.json"}},{"package":{"name":"api-platform/graphql","ecosystem":"Packagist","purl":"pkg:composer/api-platform/graphql"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.1.0-alpha.1"},{"fixed":"4.1.5"}]}],"versions":["v4.1.0","v4.1.0-alpha.1","v4.1.0-alpha.2","v4.1.0-beta.1","v4.1.0-beta.2","v4.1.1","v4.1.2","v4.1.3","v4.1.4"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-cg3c-245w-728m/GHSA-cg3c-245w-728m.json"}},{"package":{"name":"api-platform/core","ecosystem":"Packagist","purl":"pkg:composer/api-platform/core"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.1.0-alpha.1"},{"fixed":"4.1.5"}]}],"versions":["v4.1.0","v4.1.0-alpha.1","v4.1.0-alpha.2","v4.1.0-beta.1","v4.1.0-beta.2","v4.1.1","v4.1.2","v4.1.3","v4.1.4"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/04/GHSA-cg3c-245w-728m/GHSA-cg3c-245w-728m.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"}]}