/

CVE-2026-44738

Severity:

HIGH RISK

(7.7)

Information Disclosure in Grav Twig Rendering

CVE-2026-44738

Modified

Vulnerability type

Category:

Information Disclosure

CWE:

CWE-200

Impact:

Exposure of Sensitive Configuration and Secrets

Severity:

HIGH RISK

(7.7)

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 configuration allows users with the admin.pages role to call config.toArray() from within page content, exposing the full merged site configuration.

When abused, this behavior can leak sensitive plugin secrets such as SMTP passwords, AWS keys, OAuth client secrets, and API tokens directly into rendered HTML, without requiring full administrator privileges.

Affected context

This vulnerability arises in Grav instances where:

  • The Twig templating sandbox is enabled and accessible from editable page content
  • Users with the admin.pages role are allowed to create or modify page bodies
  • The configuration object (config) is exposed to Twig and its toArray() method is present on the sandbox allow-list

In such environments, page authors with limited administrative capabilities can indirectly access and render merged site configuration values, including secrets normally intended to remain server-side.

Exploit preconditions

  • Attack surface: Web-based page editing and rendering in Grav.
  • Required access: An authenticated account with the admin.pages role (but not full administrator access).
  • Trigger point: Insertion of Twig markup into page content that invokes config.toArray() (or equivalent access path) and subsequent rendering of that page.
  • Why exploitation is possible: The Twig sandbox allow-list is overly permissive, exposing a powerful configuration object method to untrusted template contexts. The method returns the entire merged configuration without filtering out secret values, and the templating layer renders this data into HTML where it can be viewed or further exfiltrated.

Why this happens

At its core, this is an information exposure issue caused by improper isolation between trusted configuration APIs and untrusted template code.

The Twig sandbox is supposed to restrict what methods and objects can be accessed from user-controlled templates. By placing config.toArray() on the allow-list, the implementation unintentionally granted low-privileged users the ability to enumerate the full configuration tree. Because the configuration structure includes sensitive secrets (credentials, keys, tokens) alongside non-sensitive settings, there is no separation of confidential data from general configuration.

This maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor: a server-side API exposing sensitive configuration is directly callable from a context controlled by users who are not authorized to access those secrets, and the system does not enforce any additional filtering or redaction when serializing configuration into templates.

Potential impact

  • Disclosure of SMTP credentials, allowing attackers to impersonate the site via outbound email.
  • Exposure of cloud provider keys (for example, AWS keys), which could enable access to storage buckets or other cloud resources.
  • Leakage of OAuth client secrets and API tokens, potentially permitting account takeover or unauthorized API access.
  • Mapping of the full application configuration, assisting in further exploitation, privilege escalation, or lateral movement.
  • Compromise of third-party integrations and services that trust Grav to keep shared secrets confidential.

General mitigation guidance

Effective mitigation centers on reducing what configuration and methods are exposed to untrusted template contexts and separating secrets from general configuration.

Pattern-based guidance includes:

  • Restrict template sandbox allow-lists: Remove powerful configuration objects and methods (such as config.toArray()) from templating sandboxes accessible to non-administrative users. Favor narrowly scoped helper functions that return only the specific, non-sensitive values needed for rendering.
  • Segregate secrets from runtime-readable configuration: Store credentials and tokens in dedicated secret stores or separate configuration domains that are never passed through to template engines. Introduce clear boundaries between content-facing settings and backend-only secrets.
  • Redact sensitive fields by default: When configuration is serialized or exposed for debugging or templating, apply filters that automatically redact values matching secret-like patterns (passwords, keys, tokens) or belonging to designated sensitive keys.
  • Minimize privileges for content authors: Ensure roles such as admin.pages only have access to content editing and safe template features, not to generic configuration APIs or debugging helpers.
  • Use explicit data models for templates: Instead of exposing broad configuration objects, define explicit view models or context objects containing only the fields required to render the page.

How teams detect issues like this

Organizations can detect similar issues by reviewing both configuration exposure patterns and template sandbox rules:

  • Static analysis of template contexts: Scan server-side code for cases where global configuration objects are injected directly into template contexts or where high-privilege methods are added to template allow-lists.
  • Policy-based review of Twig/templating configuration: Maintain a security review checklist for template sandbox configurations, flagging any helpers that expose configuration trees, environment variables, or debugging introspection.
  • Source code review of role-based access boundaries: During code review, verify that roles like content editors cannot indirectly reach configuration APIs through templating constructs or plugin-provided functions.
  • Automated configuration exposure tests: Implement security tests that render pages under low-privilege roles and inspect the HTML output for sensitive patterns (for example, known key prefixes, email credentials, or token-like strings).
  • Use of automated SAST/linters: Employ static analysis tools or custom rules to detect direct exposure of secrets to view layers, such as calls that serialize configuration into templates or logs.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-j274-39qw-32c9

Frequently asked

questions

Yes, it can be triggered remotely, but only by authenticated users who have the admin.pages role or an equivalent permission set that allows editing page content containing Twig code. Anonymous visitors cannot introduce the malicious Twig code, though once a vulnerable page is created, any visitor who loads it may see the exposed data in the rendered HTML.

An attacker needs an account with the ability to create or modify pages using Twig syntax under the admin.pages role (or similar content-author role). Full administrator privileges are not required; the risk stems from giving content editors access to a templating sandbox that exposes configuration internals.

The safest high-level fix is to remove broad configuration access from untrusted template contexts. This usually means tightening the Twig sandbox allow-list, eliminating methods that dump or enumerate configuration, and exposing only narrowly scoped, non-sensitive values to templates that can be edited by lower-privileged users.

To prevent similar problems, design template environments with least privilege in mind: expose only what is necessary for rendering, segregate secrets from displayable configuration, and ensure that any new helper or API added to the template layer is reviewed for security impact. Incorporating automated checks and security-focused code review around templating and configuration handling can further reduce the likelihood of reintroducing such vulnerabilities.

Find out what's already
exploitable in your codebase.