All vulnerabilities

Servers and applications

GHSA-p6qj-p5m7-f62h

sort() passes isSandboxed=false, so a page editor can call arbitrary PHP functions through the Twig sandbox

Severity
High
Published
20 Aug 2026
Last changed
20 Aug 2026
Added to UpHeron
3 Nov 2026
Fixed in
2.0.18
Weakness
Code injection (CWE-94)
Sources
Project advisories (GitHub)

Description

The sortFunc wrapper added by the fix for GHSA-xx48-97m4-h7qm hardcodes Twig's $isSandboxed argument to false. That flag is the only thing that enforces Twig's Closure-only rule for callables, so inside the sandbox |sort accepts a plain function name where |map, |filter and |reduce correctly refuse. The remaining guard is a denylist, and it misses spl_autoload, which performs an include.

system/src/Grav/Common/Twig/Extension/GravExtension.php:2156-2163:

The second parameter of CoreExtension::sort(Environment $env, bool $isSandboxed, ...) is the flag Twig's own check reads (vendor/twig/twig/src/Extension/CoreExtension.php:2109):

The siblings sixty lines above get this right. filterFunc (:2068), mapFunc (:2088) and reduceFunc (:2108) delegate through twig_array_filter / twig_array_map, which resolve the flag honestly (vendor/twig/twig/src/Resources/core.php:491 calls twig_resolve_is_sandboxed($env)).

From getgrav/grav's security advisory. Shortened; the full text is there.

Affected software

SoftwareAffected versions
GravServers and applications · github:getgrav/grav
  • Every version before 2.0.18

About Grav

free software content management system written in PHP

From Wikidata, CC0 1.0.
Monthly downloads (Packagist)
1,748Packagist, 15 Nov 2026
Total downloads (Packagist)
92,444Packagist, 15 Nov 2026
GitHub stars
15,725GitHub, 15 Nov 2026
Forks
1,430GitHub, 15 Nov 2026
Latest release
2.2.29GitHub, 15 Nov 2026
Released
11 Nov 2026GitHub
License
MIT LicenseWikidata
Written in
PHPWikidata
First published on GitHub
2 Aug 2014GitHub

References