CVE-2025-66299

8.8 HIGH

📋 TL;DR

Grav CMS versions before 1.8.0-beta.27 contain a Server-Side Template Injection vulnerability that allows authenticated users with editor permissions to execute arbitrary code on the server by bypassing the Twig sandbox. This enables remote code execution through malicious Twig template directives. Only authenticated editors can exploit this vulnerability.

💻 Affected Systems

Products:
  • Grav CMS
Versions: All versions prior to 1.8.0-beta.27
Operating Systems: All operating systems running Grav CMS
Default Config Vulnerable: ⚠️ Yes
Notes: Requires authenticated user with editor permissions; default Grav installations with editor accounts are vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full server compromise with attacker gaining complete control over the web server, allowing data theft, malware deployment, and lateral movement within the network.

🟠

Likely Case

Authenticated editor exploits the vulnerability to execute arbitrary code, potentially compromising the web application and underlying server.

🟢

If Mitigated

With proper access controls limiting editor permissions to trusted users only, the attack surface is reduced but still presents significant risk.

🌐 Internet-Facing: HIGH
🏢 Internal Only: HIGH

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires authenticated access with editor permissions and knowledge of Twig template injection techniques.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.8.0-beta.27 and later

Vendor Advisory: https://github.com/getgrav/grav/security/advisories/GHSA-gjc5-8cfh-653x

Restart Required: Yes

Instructions:

1. Backup your Grav installation and database. 2. Update Grav CMS to version 1.8.0-beta.27 or later via the admin panel or command line. 3. Clear the cache. 4. Restart the web server.

🔧 Temporary Workarounds

Restrict Editor Permissions

all

Temporarily remove or restrict editor permissions for all non-essential users until patching can be completed.

# Edit user accounts in Grav admin panel or user/accounts.yaml files

Web Application Firewall Rules

all

Implement WAF rules to block Twig template injection patterns and suspicious template directives.

# Configure WAF specific to your environment

🧯 If You Can't Patch

  • Implement strict access controls to limit editor permissions to absolute minimum required users
  • Monitor and audit all editor account activity for suspicious template modifications

🔍 How to Verify

Check if Vulnerable:

Check Grav version in admin panel or via command: php bin/grav version

Check Version:

php bin/grav version

Verify Fix Applied:

Confirm version is 1.8.0-beta.27 or higher and test that Twig sandbox protections are functioning

📡 Detection & Monitoring

Log Indicators:

  • Unusual Twig template modifications
  • Editor account performing unexpected template edits
  • Suspicious PHP function calls in logs

Network Indicators:

  • Unusual POST requests to template editing endpoints
  • Requests containing Twig injection patterns

SIEM Query:

source="grav_logs" AND ("twig" OR "template") AND ("inject" OR "eval" OR "system")

🔗 References

📤 Share & Export