{"id":"CVE-2021-41170","aliases":["EUVD-2021-2287","GHSA-3v56-q6r6-4gcw"],"status":"published","title":"Evaluation of closures can lead to execution of methods \u0026 functions in current program scope","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.","severity":{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-11","score":0.01582,"percentile":0.75866,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-277","CWE-732","CWE-74"],"published":"2021-11-08T19:10:10Z","modified":"2026-10-20T10:54:58Z","fixes":[{"ecosystem":"Packagist","package":"neoan3-apps/template","fixed_in":["1.1.1"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"Packagist","package":"neoan3-apps/template","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.1.1"}]}]},{"source":"osv","ecosystem":"Packagist","package":"neoan3-apps/template","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.1.1"}]}],"versions":["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.1.0"]}],"products":[{"vendor":"neoan","product":"neoan3-template"},{"vendor":"sroehrl","product":"neoan3-template"}],"references":[{"url":"https://github.com/sroehrl/neoan3-template/security/advisories/GHSA-3v56-q6r6-4gcw","tags":["x_refsource_CONFIRM","x_transferred","Patch","Third Party Advisory","fix","web"]},{"url":"https://github.com/sroehrl/neoan3-template/issues/8","tags":["x_refsource_MISC","x_transferred","Issue Tracking","Patch","Third Party Advisory","fix","web"]},{"url":"https://github.com/sroehrl/neoan3-template/commit/4a2c9570f071d3c8f4ac790007599cba20e16934","tags":["x_refsource_MISC","x_transferred","Patch","Third Party Advisory","fix","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41170","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-3v56-q6r6-4gcw"},{"url":"https://github.com/sroehrl/neoan3-template","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2021-41170","title":"Evaluation of closures can lead to execution of methods \u0026 functions in current program scope","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.","status":"published","published":"2021-11-08T19:10:10Z","modified":"2024-08-04T02:59:31.638Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"cna"}],"cwes":["CWE-277","CWE-74"],"updated_at":"2026-11-02T14:32:59.105382Z"}],"euvd":[{"id":"EUVD-2021-2287","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.","status":"published","published":"2021-11-08T19:10:10Z","modified":"2024-08-04T02:59:31Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-03T03:24:19.242491Z"}],"ghsa":[{"id":"GHSA-3v56-q6r6-4gcw","title":"Insecure Inherited Permissions in neoan3-apps/template","description":"### 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' =\u003e fn($input) =\u003e strrev($input),    // \u003c-- no longer possible with version ~1.1.1\n   'value' =\u003e 'My website' \n]\nTemplateFunctions::registerClosure('reverse', fn($input) =\u003e strrev($input));  // \u003c-- still possible (and nicely isolated)\nTemplate::embrace('\u003ch1\u003e{{reverse(value)}}\u003c/h1\u003e', $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)\n\n","status":"published","published":"2021-11-10T16:41:08Z","modified":"2023-02-01T05:06:15Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"cwes":["CWE-74","CWE-277","CWE-732"],"updated_at":"2026-11-02T14:36:38.281533Z"}],"nvd":[{"id":"CVE-2021-41170","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.","status":"published","published":"2021-11-08T19:15:07.64Z","modified":"2026-06-17T04:08:01.033Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"secondary"},{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical","assessor":"secondary"},{"version":"2.0","score":7.5,"vector":"AV:N/AC:L/Au:N/C:P/I:P/A:P","level":"high","assessor":"primary"}],"cwes":["CWE-74","CWE-277","CWE-732"],"updated_at":"2026-11-02T14:07:00.984108Z"}],"osv":[{"id":"CVE-2021-41170","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.","status":"published","published":"2021-11-08T19:15:07.64Z","modified":"2026-10-20T10:54:58.086280944Z","cvss":[{"version":"3.1","score":9.8,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T15:44:21.249056Z"},{"id":"GHSA-3v56-q6r6-4gcw","title":"Insecure Inherited Permissions in neoan3-apps/template","description":"### 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' =\u003e fn($input) =\u003e strrev($input),    // \u003c-- no longer possible with version ~1.1.1\n   'value' =\u003e 'My website' \n]\nTemplateFunctions::registerClosure('reverse', fn($input) =\u003e strrev($input));  // \u003c-- still possible (and nicely isolated)\nTemplate::embrace('\u003ch1\u003e{{reverse(value)}}\u003c/h1\u003e', $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)\n\n","status":"published","published":"2021-11-10T16:41:08Z","modified":"2026-07-08T06:27:24.923064334Z","cvss":[{"version":"3.1","score":7.5,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N","level":"high"}],"cwes":["CWE-277","CWE-732","CWE-74"],"updated_at":"2026-11-02T15:46:36.092962Z"}]}}
