GHSA-3V56-Q6R6-4GCW
Vulnerability from github – Published: 2021-11-10 16:41 – Updated: 2021-11-08 21:04Impact
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
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "neoan3-apps/template"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.1.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2021-41170"
],
"database_specific": {
"cwe_ids": [
"CWE-277",
"CWE-732",
"CWE-74"
],
"github_reviewed": true,
"github_reviewed_at": "2021-11-08T21:04:44Z",
"nvd_published_at": "2021-11-08T19:15:00Z",
"severity": "HIGH"
},
"details": "### 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 \u0027reverse\u0027 =\u003e fn($input) =\u003e strrev($input), // \u003c-- no longer possible with version ~1.1.1\n \u0027value\u0027 =\u003e \u0027My website\u0027 \n]\nTemplateFunctions::registerClosure(\u0027reverse\u0027, fn($input) =\u003e strrev($input)); // \u003c-- still possible (and nicely isolated)\nTemplate::embrace(\u0027\u003ch1\u003e{{reverse(value)}}\u003c/h1\u003e\u0027, $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",
"id": "GHSA-3v56-q6r6-4gcw",
"modified": "2021-11-08T21:04:44Z",
"published": "2021-11-10T16:41:08Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/sroehrl/neoan3-template/security/advisories/GHSA-3v56-q6r6-4gcw"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-41170"
},
{
"type": "WEB",
"url": "https://github.com/sroehrl/neoan3-template/issues/8"
},
{
"type": "WEB",
"url": "https://github.com/sroehrl/neoan3-template/commit/4a2c9570f071d3c8f4ac790007599cba20e16934"
},
{
"type": "PACKAGE",
"url": "https://github.com/sroehrl/neoan3-template"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "Insecure Inherited Permissions in neoan3-apps/template"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.