GHSA-5xh2-23cc-5jc6

Suggest an improvement
Source
https://github.com/advisories/GHSA-5xh2-23cc-5jc6
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/01/GHSA-5xh2-23cc-5jc6/GHSA-5xh2-23cc-5jc6.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-5xh2-23cc-5jc6
Aliases
Published
2025-01-09T18:51:51Z
Modified
2025-01-09T22:24:40.183267Z
Severity
  • 3.7 (Low) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N CVSS Calculator
Summary
Strawberry GraphQL has type resolution vulnerability in node interface that allows potential data leakage through incorrect type resolution
Details

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:

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:

  1. Information disclosure if the alternate type exposes sensitive fields
  2. 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

Database specific
{
    "nvd_published_at": "2025-01-09T19:15:20Z",
    "severity": "LOW",
    "github_reviewed_at": "2025-01-09T18:51:51Z",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-351",
        "CWE-843"
    ]
}
References

Affected packages

PyPI / strawberry-graphql

Package

Name
strawberry-graphql
View open source insights on deps.dev
Purl
pkg:pypi/strawberry-graphql

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.182.0
Fixed
0.257.0

Affected versions

0.*

0.182.0
0.183.0
0.183.1.dev1686081894
0.183.1
0.183.2
0.183.3
0.183.4
0.183.5
0.183.6
0.183.7
0.183.8
0.184.0
0.184.1
0.185.0
0.185.1
0.185.2.dev1686819062
0.185.2
0.186.0
0.186.1
0.186.2
0.186.3
0.187.0
0.187.1
0.187.2
0.187.3
0.187.4
0.187.5
0.188.0
0.189.0
0.189.1.dev1687473609
0.189.1
0.189.2
0.189.3
0.190.0.dev1687447182
0.190.0
0.192.0
0.192.1
0.192.2
0.193.0
0.193.1
0.194.0
0.194.1
0.194.2
0.194.3
0.194.4
0.195.0
0.195.1
0.195.2
0.195.3
0.196.0.dev1689676980
0.196.0.dev1689676990
0.196.0.dev1690222024
0.196.0
0.196.1
0.196.2
0.197.0.dev1690539957
0.197.0
0.198.0
0.199.0
0.199.1
0.199.2
0.199.3
0.200.0
0.201.0
0.201.1
0.202.0
0.202.1
0.203.0
0.203.1.dev1691831108
0.203.1
0.203.2
0.203.3
0.204.0
0.205.0
0.206.0
0.207.0
0.207.1
0.208.0
0.208.1
0.208.2
0.208.3
0.209.0
0.209.1
0.209.2
0.209.3.dev1696259772
0.209.3
0.209.4
0.209.5
0.209.6
0.209.7
0.209.8.dev1697789637
0.209.8
0.210.0.dev1697796691
0.210.0
0.211.0
0.211.1
0.211.2
0.212.0.dev1698770659
0.212.0.dev1698790124
0.212.0.dev1699050277
0.212.0.dev1699288765
0.212.0.dev1699291750
0.212.0
0.213.0.dev1699372734
0.213.0.dev1699435418
0.213.0.dev1699437859
0.213.0
0.214.0.dev1699441271
0.214.0.dev1701082152
0.214.0.dev1701368154
0.214.0
0.215.0
0.215.1
0.215.2.dev1701810830
0.215.2
0.215.3
0.216.0
0.216.1
0.217.0
0.217.1
0.218.0.dev1705418681
0.218.0
0.218.1
0.219.0
0.219.1
0.219.2
0.220.0.dev1709543239
0.220.0
0.221.0.dev1710955937
0.221.0
0.221.1
0.222.0
0.223.0
0.224.0.dev1711748192
0.224.0
0.224.1
0.224.2
0.225.0
0.225.1
0.226.0
0.226.1
0.226.2
0.227.0.dev1713463204
0.227.0.dev1713475585
0.227.0
0.227.1
0.227.2
0.227.3
0.227.4
0.227.5
0.227.6
0.227.7
0.228.0.dev1713643365
0.228.0
0.229.0
0.229.1
0.229.2.dev1715873118
0.229.2.dev1715881453
0.229.2
0.230.0.dev1716318708
0.230.0
0.231.0
0.231.1
0.232.0
0.232.1
0.232.2
0.233.0
0.233.1
0.233.2
0.233.3
0.234.0
0.234.1
0.234.2
0.234.3
0.235.0
0.235.1.dev1719337273
0.235.1
0.235.2
0.236.0
0.236.1
0.236.2
0.237.0
0.237.1
0.237.2
0.237.3
0.238.0
0.238.1
0.239.0
0.239.1
0.239.2
0.240.0
0.240.1
0.240.2
0.240.3.dev1726159932
0.240.3
0.240.4
0.241.0
0.242.0
0.243.0
0.243.1
0.244.0
0.244.1
0.245.0
0.246.0
0.246.1
0.246.2
0.246.3
0.247.0
0.247.1
0.247.2
0.248.0
0.248.1
0.249.0
0.250.0
0.250.1
0.251.0
0.252.0
0.253.0
0.253.1
0.254.0
0.254.1
0.255.0
0.256.0
0.256.1
0.257.0.dev1735244504