fix: use null prototype for LayoutAnimationRepository config #3383
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.
Description
Prevent the
configs
object from having properties inherited fromObject.prototype
, such astoString
or__proto__
. Otherwise, using these properties could potentially have a security impact.Changes
Changed the prototype of the
configs
object so it doesn't inherit fromObject.prototype
, as regular JS objects do by default.Test code and steps to reproduce
Couldn't find a test case that I could base on to demonstrate how this could present a risk.
An example of the problem caused by using an object inheriting from
Object.prototype
can be demonstrated by the following line (corresponding to thestartAnimationForTag
function):If both
tag
andtype
had the valueconstructor
, style would have the result of evaluatingconfigs.constructor.constructor(yogaValues)
, which in many platforms would be the same asnew Function(yogaValues)
. This could potentially be used to create functions with malicious code. Although I suspect the conditions to make this work would be hard to achieve, it's probably better to get rid of this potential threat by using null prototypes.Checklist