{"id":"CVE-2021-41170","aliases":["CVE-2021-41170","GHSA-3v56-q6r6-4gcw"],"related":[],"kind":"vulnerability","state":"published","title":"Evaluation of closures can lead to execution of methods & functions in current program scope","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Impact\nVersions 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. \n\nIn 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. \n\n\n### Patches\nVersion 1.1.1 has addressed this vulnerability. \n```php\n$params = [\n   'reverse' => fn($input) => strrev($input),    // <-- no longer possible with version ~1.1.1\n   'value' => 'My website' \n]\nTemplateFunctions::registerClosure('reverse', fn($input) => strrev($input));  // <-- still possible (and nicely isolated)\nTemplate::embrace('<h1>{{reverse(value)}}</h1>', $params);\n```\n\n### Workarounds\nUnfortunately only working with hardcoded values is safe in prior versions. As this likely defeats the purpose of a template engine, please upgrade.\n\n### References\nAs a possible exploit is relatively easy to achieve, I will not share steps to reproduce the issue for now.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [our repo](https://github.com/sroehrl/neoan3-template)","format":"markdown","source":"ghsa"},{"lang":"es","text":"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","source":"nvd"}],"published":"2021-11-08T19:10:10.000Z","modified":"2026-07-08T06:27:24.923Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","score":7.5,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","score":7.5,"rating":"HIGH"}],"cwes":["CWE-74","CWE-277","CWE-732"],"affected":[{"ranges":[{"version":"< 1.1.1","status":"affected"}],"vendor":"sroehrl","product":"neoan3-template","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.1.1"}],"ecosystem":"Packagist","package":"neoan3-apps/template","purl":"pkg:composer/neoan3-apps/template","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.1.1"}],"vendor":"neoan","product":"neoan3-template","cpe":"cpe:2.3:a:neoan:neoan3-template:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sroehrl/neoan3-template/security/advisories/GHSA-3v56-q6r6-4gcw","tags":["patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sroehrl/neoan3-template/issues/8","tags":["issue-tracking","patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sroehrl/neoan3-template/commit/4a2c9570f071d3c8f4ac790007599cba20e16934","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41170","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/sroehrl/neoan3-template","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-41170","url":"https://www.cve.org/CVERecord?id=CVE-2021-41170","licence":"CVE Terms of Use","modified":"2024-08-04T02:59:31.638Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3v56-q6r6-4gcw","url":"https://github.com/advisories/GHSA-3v56-q6r6-4gcw","licence":"CC-BY-4.0","modified":"2026-07-08T06:27:24.923Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-41170","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41170","licence":"Public domain","modified":"2026-06-17T04:08:01.033Z"}],"updatedAt":"2026-11-25T22:58:05.431Z","epss":{"score":0.01582,"percentile":0.76268,"date":"2026-12-01T12:00:22.000Z"}}