Summary
Grav 2.0.4 contains an issue in the Blueprint dynamic data handling that lets attacker-controlled callable strings be passed directly into call_user_func_array() with no allowlist.
An authenticated user with page editing permissions can embed a malicious callable in page frontmatter that then executes as the web-server user whenever the page is viewed, including by unauthenticated visitors.
Affected context
This vulnerability appears in Grav installations where:
- The blueprint system processes dynamic data via
Blueprint::dynamicData() - The form or related plugins route page frontmatter through this dynamic resolution path
- Users with
admin.pagesorapi.pages.writepermissions can edit page content or metadata - PHP is configured to allow callable strings to be executed through
call_user_func_array()
In such contexts, page frontmatter serves as a vehicle for attacker-controlled callable directives that are evaluated at request time.
Exploit preconditions
- Attack surface: HTTP(S) interface of the Grav admin/API and public page rendering.
- Required access: An authenticated account with
admin.pagesorapi.pages.writecapability to create or modify pages/frontmatter. - Trigger point: Any subsequent visit to the crafted page (by any user, including anonymous visitors) that causes the blueprint dynamic data resolution to evaluate the malicious callable.
- Why exploitation is possible: The blueprint resolver accepts an arbitrary
Class::methodstring and arguments from frontmatter and forwards them directly tocall_user_func_array()without validating the target against an allowlist or restricting the callable context, enabling execution of unintended application or PHP code paths.
Why this happens
The core issue is an unvalidated dynamic function call, where blueprint "dynamic data" is implemented by taking a user-influenced Class::method string and parameters and sending them directly into call_user_func_array().
This pattern maps to CWE-94: Improper Control of Code Generation (or execution), because it allows external input to determine which code is invoked at runtime.
Rather than constraining dynamic blueprint callbacks to a fixed, well-defined set of safe handlers with strict argument validation, the implementation permits arbitrary callables to be invoked, effectively turning configuration/frontmatter into an execution control channel.
Potential impact
- Remote execution of arbitrary PHP methods within the Grav application context
- Full compromise of the Grav site, including modification or deletion of content
- Access to sensitive configuration or secrets accessible to the web-server user
- Pivoting to the underlying server via local file access, process interaction, or additional vulnerabilities
- Defacement or deployment of backdoors that execute on every page visit
General mitigation guidance
Effective mitigation focuses on removing unbounded dynamic execution paths and strictly constraining blueprint-driven behavior:
- Replace generic
call_user_func_array()usage with an explicit allowlist of permitted blueprint handlers, mapping symbolic identifiers to internal methods. - Treat frontmatter and other declarative configuration as data only; disallow direct specification of
Class::methodcallables from user-editable content. - Introduce strong validation that rejects unknown or unexpected directive names and enforces argument types and ranges.
- Apply least-privilege principles to admin roles so that only trusted users can modify pages that influence dynamic behavior.
- Where possible, separate execution logic from layout/metadata and ensure any dynamic resolution uses immutable, server-side registered callbacks instead of arbitrary callables.
How teams detect issues like this
Detection typically combines code-level review with runtime monitoring:
- Static analysis: Search for
call_user_func_array()or similar reflection/dynamic-call APIs where the callable comes from user-controlled or configuration sources, especially in blueprint, template, or frontmatter processing. - Code review: Flag patterns where page metadata or form definitions are allowed to specify
Class::methodor other callables without a central registry or allowlist; verify that all dynamic callback registries validate targets. - Policy enforcement: Establish guidelines that prohibit treating content/frontmatter as a source of executable callables; enforce these rules through automated checks in continuous integration.
- Runtime observation: Monitor logs for unexpected or suspicious method invocations associated with blueprint evaluation and for anomalies in page rendering paths indicative of dynamic execution misuse.

