/

CVE-2026-42608

Severity:

CRITICAL RISK

(9.1)

Path Traversal in Grav FormFlash Session Handling

CVE-2026-42608

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write and Application Behavior Manipulation

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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-id value 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.yaml files 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-id values 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.yaml files 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.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-hmcx-ch82-3fv2

Frequently asked

questions

Yes. An unauthenticated attacker with network access to the Grav instance can exploit the vulnerability by sending crafted POST requests that abuse the __form-flash-id parameter.

No. The weakness resides in how FormFlash handles incoming identifiers for form state and does not inherently require authentication, assuming the vulnerable endpoint is reachable.

The most robust fix is to treat client-supplied identifiers as opaque tokens, map them to server-generated, sanitized filenames, and enforce that the final, canonical path always remains within a predefined storage root, rejecting any value that cannot meet these constraints.

Establish centralized utilities for building filesystem paths from user-related data, enforce strict validation and normalization in those utilities, apply least-privilege filesystem permissions, and include automated checks in code review and CI to flag direct use of request parameters in file paths.

Find out what's already
exploitable in your codebase.