9.8critical
Evaluation of closures can lead to execution of methods & functions in current program scope
- Severity
- 9.8critical CVSS:3.1 by GitHub_M
- Exploit likelihood
- 1.58% (higher than 76% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-3v56-q6r6-4gcw
Description
neoan3-apps/template is a neoan3 minimal template engine. Versions prior to 1.1.1 have allowed for passing in closures directly into the template engine. As a result values that are callable are executed by the template engine. The issue arises if a value has the same name as a method or function in scope and can therefore be executed either by mistake or maliciously. In theory all users of the package are affected as long as they either deal with direct user input or database values. A multi-step attack on is therefore plausible. Version 1.1.1 has addressed this vulnerability. Unfortunately only working with hardcoded values is safe in prior versions. As this likely defeats the purpose of a template engine, please upgrade.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| sroehrl neoan3-template | < 1.1.1 | CVE List |
| neoan3-apps/template (Packagist) | before 1.1.1 | GitHub Advisory Database |
| neoan neoan3-template | before 1.1.1 | NVD |
All scores
| GitHub_M | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 7.5high CVSS:2.0 | AV:N/AC:L/Au:N/C:P/I:P/A:P |
Classification
What each source says
CVE List
neoan3-apps/template is a neoan3 minimal template engine. Versions prior to 1.1.1 have allowed for passing in closures directly into the template engine. As a result values that are callable are executed by the template engine. The issue arises if a value has the same name as a method or function in scope and can therefore be executed either by mistake or maliciously. In theory all users of the package are affected as long as they either deal with direct user input or database values. A multi-step attack on is therefore plausible. Version 1.1.1 has addressed this vulnerability. Unfortunately only working with hardcoded values is safe in prior versions. As this likely defeats the purpose of a template engine, please upgrade.
GitHub Advisory Database
Impact
Versions prior 1.1.1 have allowed for passing in closures directly into the template engine. As a result values that are callable are executed by the template engine. The issue arises if a value has the same name as a method or function in scope and can therefore be executed either by mistake or maliciously.
In theory all users of the package are affected as long as they either deal with direct user input or database values. A multi-step attack on is therefore plausible.
Patches
Version 1.1.1 has addressed this vulnerability.
$params = [
'reverse' => fn($input) => strrev($input), // <-- no longer possible with version ~1.1.1
'value' => 'My website'
]
TemplateFunctions::registerClosure('reverse', fn($input) => strrev($input)); // <-- still possible (and nicely isolated)
Template::embrace('<h1>{{reverse(value)}}</h1>', $params);
Workarounds
Unfortunately only working with hardcoded values is safe in prior versions. As this likely defeats the purpose of a template engine, please upgrade.
References
As a possible exploit is relatively easy to achieve, I will not share steps to reproduce the issue for now.
For more information
If you have any questions or comments about this advisory:
- Open an issue in our repo
NVD (es)
neoan3-apps/template es un motor de plantillas mínimo de neoan3. Las versiones anteriores a la 1.1.1 han permitido pasar cierres directamente al motor de plantillas. Como resultado, los valores que son invocables son ejecutados por el motor de plantillas. El problema surge si un valor tiene el mismo nombre que un método o función en el ámbito y, por lo tanto, puede ser ejecutado por error o maliciosamente. En teoría, todos los usuarios del paquete se ven afectados siempre y cuando traten con entradas directas del usuario o con valores de la base de datos. Por lo tanto, es plausible un ataque en varios pasos. La versión 1.1.1 ha solucionado esta vulnerabilidad. Lamentablemente, en las versiones anteriores sólo es seguro trabajar con valores codificados. Dado que esto probablemente anula el propósito de un motor de plantillas, por favor, actualice
References
| https://github.com/sroehrl/neoan3-template/security/advisories/GHSA-3v56-q6r6-4gcw | patch, third-party-advisory, web | |
| https://github.com/sroehrl/neoan3-template/issues/8 | issue-tracking, patch, third-party-advisory, web | |
| https://github.com/sroehrl/neoan3-template/commit/4a2c9570f071d3c8f4ac790007599cba20e16934 | patch, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-41170 | advisory | |
| https://github.com/sroehrl/neoan3-template | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-41170 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-3v56-q6r6-4gcw changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-41170 changed 2026-06-17 | Public domain |