ghsa-5xh2-23cc-5jc6
Vulnerability from github
Vulnerability Summary
A type confusion vulnerability exists in Strawberry GraphQL's relay integration that affects multiple ORM integrations (Django, SQLAlchemy, Pydantic). The vulnerability occurs when multiple GraphQL types are mapped to the same underlying model while using the relay node
interface.
Affected Components - Strawberry GraphQL relay integration - Specifically impacts implementations using: - Django integration - SQLAlchemy integration - Pydantic integration
Technical Details
The vulnerability manifests when:
1. Multiple GraphQL types inherit from relay.Node
2. These types are mapped to the same database model
3. The global node
field is used for type resolution
Example of vulnerable code:
```python from fruits.models import Fruit import strawberry_django import strawberry
@strawberry_django.type(Fruit) class FruitType(relay.Node): name: strawberry.auto
@strawberry_django.type(Fruit) class SpecialFruitType(relay.Node): secret_name: strawberry.auto
@strawberry.type class Query: node: relay.Node = strawberry_django.node() ```
Security Impact
When querying for a specific type using the global node
field (e.g., FruitType:some-id
), the resolver may incorrectly return an instance of a different type mapped to the same model (e.g., SpecialFruitType
). This can lead to:
- Information disclosure if the alternate type exposes sensitive fields
- Potential privilege escalation if the alternate type contains data intended for restricted access
Note
Even with knowledge of the correct type name (e.g., SpecialFruitType
), attackers may still be able to access unauthorized data through direct type queries.
We recommend to use permission on fields instead of creating a dedicate type.
Recommendations
1. Avoid mapping multiple relay Node types to the same model
2. Implement strict access controls at the field resolution level (using permissions)
3. Consider using separate models for different access levels of the same data
4. Update to strawberry-graphql>=0.257.0
5. If using strawberry-graphql-django
, update to strawberry-graphql-django>=0.54.0
{ "affected": [ { "package": { "ecosystem": "PyPI", "name": "strawberry-graphql" }, "ranges": [ { "events": [ { "introduced": "0.182.0" }, { "fixed": "0.257.0" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2025-22151" ], "database_specific": { "cwe_ids": [ "CWE-351", "CWE-843" ], "github_reviewed": true, "github_reviewed_at": "2025-01-09T18:51:51Z", "nvd_published_at": "2025-01-09T19:15:20Z", "severity": "LOW" }, "details": "**Vulnerability Summary**\nA type confusion vulnerability exists in Strawberry GraphQL\u0027s relay integration that affects multiple ORM integrations (Django, SQLAlchemy, Pydantic). The vulnerability occurs when multiple GraphQL types are mapped to the same underlying model while using the relay `node` interface.\n\n**Affected Components**\n- Strawberry GraphQL relay integration\n- Specifically impacts implementations using:\n - Django integration\n - SQLAlchemy integration\n - Pydantic integration\n\n**Technical Details**\n\nThe vulnerability manifests when:\n1. Multiple GraphQL types inherit from `relay.Node`\n2. These types are mapped to the same database model\n3. The global `node` field is used for type resolution\n\nExample of vulnerable code:\n\n```python\nfrom fruits.models import Fruit\nimport strawberry_django\nimport strawberry\n\n@strawberry_django.type(Fruit)\nclass FruitType(relay.Node):\n name: strawberry.auto\n\n@strawberry_django.type(Fruit)\nclass SpecialFruitType(relay.Node):\n secret_name: strawberry.auto\n\n@strawberry.type\nclass Query:\n node: relay.Node = strawberry_django.node()\n```\n\n**Security Impact**\n\nWhen querying for a specific type using the global `node` field (e.g., `FruitType:some-id`), the resolver may incorrectly return an instance of a different type mapped to the same model (e.g., `SpecialFruitType`). This can lead to:\n\n1. Information disclosure if the alternate type exposes sensitive fields\n2. Potential privilege escalation if the alternate type contains data intended for restricted access\n\n**Note**\nEven with knowledge of the correct type name (e.g., `SpecialFruitType`), attackers may still be able to access unauthorized data through direct type queries.\n\nWe recommend to use permission on fields instead of creating a dedicate type.\n\n**Recommendations**\n1. Avoid mapping multiple relay Node types to the same model\n2. Implement strict access controls at the field resolution level (using permissions)\n3. Consider using separate models for different access levels of the same data\n4. Update to `strawberry-graphql\u003e=0.257.0`\n5. If using `strawberry-graphql-django`, update to `strawberry-graphql-django\u003e=0.54.0`", "id": "GHSA-5xh2-23cc-5jc6", "modified": "2025-01-09T22:04:49Z", "published": "2025-01-09T18:51:51Z", "references": [ { "type": "WEB", "url": "https://github.com/strawberry-graphql/strawberry/security/advisories/GHSA-5xh2-23cc-5jc6" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-22151" }, { "type": "WEB", "url": "https://github.com/strawberry-graphql/strawberry/commit/526eb82b70451c0e59d5a71ae9b7396f59974bd8" }, { "type": "PACKAGE", "url": "https://github.com/strawberry-graphql/strawberry" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N", "type": "CVSS_V3" } ], "summary": "Strawberry GraphQL has type resolution vulnerability in node interface that allows potential data leakage through incorrect type resolution" }
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.