Summary
A path traversal vulnerability in Grav's FormFlash core component allows attackers to manipulate the __form-flash-id POST parameter to escape the intended storage directory.
In affected versions, this can be abused to create arbitrary directories and write attacker-controlled index.yaml files, potentially altering application behavior and disrupting production environments without authentication.
Affected context
This issue affects Grav deployments that use the FormFlash core component to store form-related session data on disk.
The vulnerability surfaces when the application derives filesystem paths directly from the __form-flash-id parameter (mapped from session_id) and uses those paths to create directories and index.yaml files without sufficient normalization or restriction.
It is most relevant in environments where the web process has write permissions beyond the intended FormFlash storage directory or where YAML configuration files influence runtime behavior.
Exploit preconditions
- Attack surface: HTTP POST requests to endpoints using the FormFlash core functionality
- Required access: No authentication required; the attacker only needs network access to the vulnerable Grav instance
- Trigger point: Supplying a crafted
__form-flash-idvalue in a POST request so that, when mapped to a filesystem path, it traverses outside the intended directory structure - Why exploitation is possible: User-controlled path segments are concatenated into filesystem paths without proper canonicalization, normalization, or enforcement of an allowed root directory, enabling directory creation and file writes in unintended locations
Why this happens
The root cause is the direct use of unvalidated, user-supplied data to construct filesystem paths, a classic manifestation of CWE-22: Path Traversal.
FormFlash treats the session_id (provided as __form-flash-id) as a trusted identifier and interpolates it into directory paths used for form state storage.
Without robust normalization, rejection of traversal sequences (such as ../), and enforcement that the resulting path remains within a designated base directory, an attacker can cause the application to create directories and write index.yaml files at arbitrary locations accessible to the web process.
Potential impact
- Creation of arbitrary directories within the web process's writable filesystem
- Writing attacker-controlled
index.yamlfiles that may influence Grav's behavior or plugin/config loading logic - Unauthorized modification of application behavior or routing based on tampered YAML content
- Data integrity issues where legitimate configuration or content is shadowed or overridden
- Service disruption, including application errors or denial of service if critical paths or configs are manipulated
- Potential stepping stone to broader compromise if written files are later interpreted as configuration, metadata, or other trusted input by the application
General mitigation guidance
Mitigation strategies center on strict control of how user input influences filesystem paths and how on-disk YAML is interpreted:
- Normalize and canonicalize any path derived from user-controllable data and enforce that the resolved path remains under a fixed, application-controlled root directory.
- Reject or sanitize any
session_id/__form-flash-idvalues containing directory traversal characters or unexpected path separators; treat them as opaque tokens rather than path fragments. - Use whitelist-based naming (e.g., fixed-length, character-restricted identifiers) for on-disk form/session keys instead of trusting client-supplied values directly.
- Separate configuration and runtime data paths, ensuring that user-driven writes cannot land in directories that the application later treats as configuration or executable metadata.
- Run the Grav process under a least-privilege account with write access only to strictly necessary directories and no ability to modify core application or configuration paths.
- Where feasible, store ephemeral form state outside the web-accessible tree or use non-filesystem-backed storage for transient form/session data.
How teams detect issues like this
Effective detection involves both code-level and operational monitoring approaches:
- Use static analysis to flag concatenation of request parameters (like
__form-flash-id) into filesystem paths, especially when combined with directory creation or file write operations. - During code review, look for patterns where user IDs or tokens are used as directory names or filenames without centralized validation or canonicalization logic.
- Implement logging around file write operations for the FormFlash component, capturing the resolved absolute paths and correlating them with client IPs and request parameters, then alert on writes outside expected directories.
- Employ host-based intrusion detection or file integrity monitoring to watch for unexpected directory creation and new
index.yamlfiles in sensitive or configuration-related locations. - Integrate automated security testing (SAST/DAST) into CI pipelines to probe endpoints that accept identifier-like parameters and verify they cannot cause writes outside the designated storage area.

