You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've identified several prototype pollution gadgets within the dustjs template engine that could potentially be leveraged by attackers to achieve client-side cross-site scripting (XSS) through prototype pollution vulnerability.
In light of the findings, I kindly request your confirmation of this potential issue to improve the security of the JavaScript ecosystem. We would greatly appreciate any steps taken to address them and we stand ready to submit a pull request on the GitHub repository to help improve the security for all users of your excellent work.
Root Cause
The existence of these gadgets can be attributed to a specific programming practice. When checking for the presence of a property within an object variable, the lookup scope isn't explicitly defined. In JavaScript, the absence of a defined lookup scope prompts a search up to the root prototype (Object.prototype). This could potentially be under the control of an attacker if other prototype pollution vulnerabilities are present within the application.
Some vulnerable coding patterns are as follows.
if(obj.prop){ //... }
var x = obj.prop || ''
Impact
If the application server is using the dustjs as the backend template engine, and there is another prototype pollution vulnerability in the application, then the attacker could leverage the found gadgets inside the template engine to escalate the prototype pollution to reflected XSS that affects all the client users.
Proof of Concept
Below, I present a Proof of Concept (PoC) to demonstrate the identified gadgets within the dustjs@3.0.1 template engine. This particular gadget activates when there's a non-iterative variable lookup (rootdir) within an array context in the template ({#names}...{/names}). The pertinent code segment can be found in the dustjs run-time function _get.
Hi there!
I've identified several prototype pollution gadgets within the
dustjs
template engine that could potentially be leveraged by attackers to achieve client-side cross-site scripting (XSS) through prototype pollution vulnerability.In light of the findings, I kindly request your confirmation of this potential issue to improve the security of the JavaScript ecosystem. We would greatly appreciate any steps taken to address them and we stand ready to submit a pull request on the GitHub repository to help improve the security for all users of your excellent work.
Root Cause
The existence of these gadgets can be attributed to a specific programming practice. When checking for the presence of a property within an object variable, the lookup scope isn't explicitly defined. In JavaScript, the absence of a defined lookup scope prompts a search up to the root prototype (Object.prototype). This could potentially be under the control of an attacker if other prototype pollution vulnerabilities are present within the application.
Some vulnerable coding patterns are as follows.
Impact
If the application server is using the
dustjs
as the backend template engine, and there is another prototype pollution vulnerability in the application, then the attacker could leverage the found gadgets inside the template engine to escalate the prototype pollution to reflected XSS that affects all the client users.Proof of Concept
Below, I present a Proof of Concept (PoC) to demonstrate the identified gadgets within the
dustjs@3.0.1
template engine. This particular gadget activates when there's a non-iterative variable lookup (rootdir
) within an array context in the template ({#names}...{/names}
). The pertinent code segment can be found in thedustjs
run-time function_get
.Output:
General Suggested Fix
To mitigate this issue, I recommend constraining the property lookup to the current object variable.
Here are two general strategies:
By adopting these measures, we can effectively prevent the potential exploitation of prototype pollution vulnerabilities.
The text was updated successfully, but these errors were encountered: