Improper Control of Generation of Code ('Code Injection') Affecting getgrav/grav package, versions <1.7.45


0.0
high

Snyk CVSS

    Attack Complexity Low
    Privileges Required High
    Confidentiality High
    Integrity High
    Availability High

    Threat Intelligence

    Exploit Maturity Proof of concept
    EPSS 0.04% (9th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PHP-GETGRAVGRAV-6476899
  • published 22 Mar 2024
  • disclosed 21 Mar 2024
  • credit as3617, juckchang

How to fix?

Upgrade getgrav/grav to version 1.7.45 or higher.

Overview

getgrav/grav is a Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS.

Affected versions of this package are vulnerable to Improper Control of Generation of Code ('Code Injection') due to the improper validation of accessible functions through the Utils::isDangerousFunction function and the lack of restrictions on twig functions like twig_array_map, allowing attackers to bypass the validation and execute arbitrary commands. Twig processing of static pages can be enabled in the front matter by any administrative user allowed to create or edit pages. Since the Twig processor runs unsandboxed, this behavior can be exploited to gain arbitrary code execution and elevate privileges on the instance.

PoC

{% set cmd = {'id':'system'} %}
{{ twig_array_map(grav.twig.twig,cmd,'call_user_func')|join }}

References