Summary
Grav has an insecure blueprint trust issue that can let a publisher account use attacker-controlled blueprint files to expose secrets or execute PHP code. The risk arises when the application processes blueprint-related file references or settings without adequately restricting which files and operations are trusted.
Affected context
The issue affects Grav releases from 2.0.0 before 2.2.18 when blueprint handling trusts attacker-controlled files or references. Relevant paths include the import@ directive, uploaded YAML media named to match a page template, and the form.flash_folder setting. The described outcomes depend on a publisher being able to plant or select the relevant blueprint files.
Exploit preconditions
- Attack surface: Blueprint imports, uploaded YAML media, and form-related blueprint settings
- Required access: A publisher account with the ability to plant or select attacker-controlled blueprint files
- Trigger point: Processing or evaluating the affected blueprint or setting
- Why exploitation is possible: File selection and blueprint behavior are not sufficiently constrained to trusted paths and safe operations
Why this happens
The underlying issue is that attacker-influenced values can affect which files Grav trusts or processes as blueprints. This maps to CWE-73: External Control of File Name or Path, where externally controlled input can influence file selection or path handling. In this case, insufficient trust boundaries around blueprint files and directives may enable access to sensitive data or invocation of PHP methods.
Potential impact
- Password hashes or application keys could be disclosed
- PHP code could be executed in the application context
- Application data or configuration could be compromised
- An attacker could gain a foothold for further activity, depending on runtime privileges
General mitigation guidance
Mitigation generally focuses on treating blueprint files and related references as untrusted unless their provenance is verified.
- Restrict blueprint selection and imports to explicitly approved locations
- Validate file names and canonicalized paths against a narrow allowlist
- Avoid interpreting user-controlled configuration as executable behavior
- Limit publisher permissions to the capabilities required for their work
- Keep secrets out of locations accessible to content-processing workflows, and apply least privilege to the application runtime
How teams detect issues like this
- Review file and path handling for blueprint imports, uploaded YAML, and form settings
- Use static analysis to identify externally influenced values reaching file-selection or dynamic method-invocation logic
- Review whether upload and publishing policies permit blueprint files to be planted or selected
- Monitor for unexpected blueprint references, changes to sensitive configuration, and unusual access to secret-bearing files
- Apply policy checks that restrict blueprint sources and allowed configuration directives

