/

CVE-2026-76846

Severity:

HIGH RISK

(7.5)

Twig Sandbox Secret Exposure (CWE-522) in Grav CMS

CVE-2026-76846

Deferred

Vulnerability type

Category:

Sensitive Information Exposure

CWE:

CWE-522

Impact:

Exposure of sensitive configuration credentials

Severity:

HIGH RISK

(7.5)

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

Grav's Twig sandbox may allow users with page-edit permission to access sensitive system configuration values when configuration access is enabled. By calling configuration helpers from Twig templates, an attacker could retrieve secrets such as a Redis password.

Affected context

The issue occurs in Grav deployments using Twig sandboxing with an incomplete default denylist and configuration access enabled. It becomes risky when a user who can edit pages is also able to influence Twig template content or otherwise cause templates to invoke configuration access methods.

Exploit preconditions

  • Attack surface: Twig template rendering in the Grav CMS
  • Required access: Permission to edit pages or otherwise control relevant template content
  • Trigger point: Rendering a template that invokes configuration access functionality
  • Required configuration: Configuration access must be enabled and the affected values must be present
  • Why exploitation is possible: The sandbox denylist does not sufficiently restrict access to sensitive system configuration data

Why this happens

The underlying bug is an incomplete access-control policy in the Twig sandbox. Configuration helper methods remain available for retrieving sensitive values even though templates are treated as restricted content. This reflects CWE-522, where credentials or other authentication-related secrets are insufficiently protected from unauthorized disclosure.

Potential impact

  • Sensitive configuration values may be disclosed
  • Redis or other service credentials could be exposed
  • Attackers could use recovered secrets to access connected services
  • Application data or session security could be weakened
  • Further compromise may occur depending on the privileges of exposed credentials

General mitigation guidance

Mitigation generally focuses on reducing trust in template-authored content

and enforcing a complete, deny-by-default sandbox policy.

Common defensive patterns include:

  • Exposing only explicitly approved, non-sensitive template variables and methods
  • Preventing Twig templates from reading application-wide configuration objects
  • Treating page-edit permissions as potentially security-sensitive
  • Keeping credentials outside template-accessible configuration paths
  • Applying least privilege and narrow scopes to service credentials
  • Requiring explicit authorization before enabling configuration access
  • Rotating exposed secrets when unauthorized disclosure is suspected

How teams detect issues like this

Detection approaches may include:

  • Static analysis for template calls that access configuration objects or conversion helpers
  • Code review checks for sandbox allowlists and default-deny behavior
  • Policy tests verifying that templates cannot retrieve credential-bearing settings
  • Audit logging for page edits, template changes, and configuration-access events
  • Automated security review tools that flag sensitive data flows into rendered templates

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-xjw5-q542-3vmr
vulncheck.comvulncheck.com/advisories/grav-before-information-disclosure-via-twig-sandbox

Frequently asked

questions

Exploitation generally requires page-edit permission or another capability that allows an attacker to influence Twig template content. The practical scope depends on Grav permissions and deployment configuration.

No. Exposure depends on whether configuration access is enabled, sensitive values are available, and the affected sandbox restrictions are in use.

Use a strict default-deny Twig sandbox that exposes only explicitly approved, non-sensitive values and methods. Configuration objects containing credentials should not be template-accessible.

Treat template authors as untrusted, test sandbox boundaries with security-focused cases, review permission assignments, and keep service credentials isolated from presentation-layer data.

Find out what's already
exploitable in your codebase.