Summary
A broken authorization check in Craft CMS's GraphQL @parseRefs directive allows attackers to resolve internal reference tags into sensitive element attributes without proper access control.
When a public GraphQL schema is enabled, even unauthenticated guests can abuse this behavior to read data they are not authorized to view across various CMS elements.
Affected context
This vulnerability affects Craft CMS instances that expose the GraphQL API and use the @parseRefs directive to resolve internal reference tags such as {user:1:email} or other element attributes.
It becomes relevant when:
- The GraphQL API is enabled, and
- Either authenticated users or unauthenticated guests (via a Public Schema) can send queries using @parseRefs.
In this context, the Elements::parseRefs implementation attempts to resolve references into element fields but does not consistently apply authorization checks before returning the resolved values.
Exploit preconditions
- Attack surface: Craft CMS GraphQL endpoint where the @parseRefs directive is available.
- Required access:
- Any authenticated GraphQL consumer; and
- Unauthenticated guests if a Public Schema is enabled for GraphQL.
- Trigger point: Execution of a GraphQL query that applies @parseRefs to carefully crafted reference tags targeting sensitive elements or attributes.
- Why exploitation is possible: The Elements::parseRefs function resolves internal reference tags and returns associated element attributes without enforcing per-element authorization checks, effectively bypassing normal access control rules.
Why this happens
The core issue is an authorization check omission in the code path responsible for parsing internal reference tags within the GraphQL layer.
The Elements::parseRefs implementation treats any syntactically valid reference tag as resolvable, assuming the caller is authorized, and fails to verify whether the current principal (user or guest) has permission to view the targeted element or attribute.
This maps directly to CWE-639: Authorization Bypass Through User-Controlled Key, since attackers supply identifiers or references (e.g., element IDs) that the system uses to fetch data without re-checking access rights.
Potential impact
- Unauthorized reading of sensitive user attributes (e.g., email addresses or profile details).
- Exposure of confidential content fields from entries, assets, or other CMS elements.
- Leakage of internal identifiers and structural metadata that can support further attacks (enumeration, social engineering, targeted phishing).
- Potential regulatory or compliance impact if personal or regulated data is exposed.
General mitigation guidance
Effective mitigation centers on enforcing robust authorization checks wherever identifiers or reference tags are resolved:
- Ensure that any function resolving element references (like parseRefs) performs explicit permission checks against the current user or API consumer before returning data.
- Treat internal reference tags as untrusted input when they originate from GraphQL or other client-controlled interfaces, and validate them as you would any direct ID-based lookup.
- Constrain GraphQL schemas to the minimum required fields and types, avoiding exposure of sensitive attributes through generalized directives.
- Where feasible, separate public and private data models or views so that even if a resolver is misused, sensitive data is never placed on publicly reachable types.
- Apply the principle of least privilege for GraphQL APIs by disabling public schemas or reducing their scope when not strictly needed.
How teams detect issues like this
Detection generally involves both code-level analysis and runtime monitoring:
- Static analysis / code review:
- Identify API endpoints or resolvers that accept user-controlled identifiers, reference tags, or keys and verify that they all perform authorization checks.
- Look for helper methods like
parseRefsor similar that retrieve elements by ID or handle templated references without checking permissions. - Enforce secure coding guidelines that mandate access checks at all data access boundaries, especially in shared utility functions.
- Policy and automated checks:
- Use security linters or custom rules to flag ID-based lookups that do not pass through a standardized authorization helper.
- Implement CI policies that require security review for changes touching GraphQL resolvers or access-control logic.
- Runtime monitoring:
- Log GraphQL queries and look for patterns where @parseRefs is used with unusual or out-of-scope element IDs.
- Monitor for spikes in GraphQL traffic that enumerate element IDs or fields that are typically non-public.

