fix Prototype-polluting function mod.activity() code Injection #17335
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
lila/ui/mod/src/mod.activity.ts
Line 104 in 0d7709f
fix for problem, we need to ensure that the
mergefunction does not allow prototype pollution. This can be achieved by:__proto__andconstructorfrom being merged.We will modify the
mergefunction to include these checks. Specifically, we will:__proto__andconstructor.Most JavaScript objects inherit the properties of the built-in
Object.prototypeobject. Prototype pollution is a type of vulnerability in which an attacker is able to modifyObject.prototype. Since most objects inherit from the compromisedObject.prototype, the attacker can use this to tamper with the application logic, and often escalate to remote code execution or cross-site scripting.One way to cause prototype pollution is through use of an unsafe merge or extend function to recursively copy properties from one object to another, or through the use of a deep assignment function to assign to an unverified chain of property names. Such a function has the potential to modify any object reachable from the destination object, and the built-in
Object.prototypeis usually reachable through the special properties__proto__andconstructor.prototype.POC
This function recursively copies properties from
srctodst:However, if src is the
object {"__proto__": {"isAdmin": true}}, it will inject the propertyisAdmin: trueinObject.prototype. The issue can be fixed by ensuring that only own properties of the destination object are merged recursively:Alternatively, block the
__proto__andconstructorproperties:References
lodash, jQuery, extend, just-extend, merge.recursive
CWE-78
CWE-79
CWE-94
CWE-400
CWE-471
CWE-915