Uh oh!
There was an error while loading. Please reload this page.
Ignore __proto__ key when copying properties - #162
Open
spokodev wants to merge 1 commit into
Open
Conversation
kilisamemarisaaa
left a comment
There was a problem hiding this comment.
I reviewed this change at head b4ed2f43815f4d96888b58e13a220d4f0368e812.
The guard correctly prevents both own and inherited enumerable __proto__ properties from being assigned while preserving ordinary properties. I independently verified:
- JSON-parsed own
__proto__does not addevilor change the error prototype - an inherited enumerable
__proto__is also ignored Error.prototypeandcreateError.isHttpError()remain correctObject.prototypeis not polluted- project tests: 53 passing, 1 pending; lint passes
No blocking issues found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
createError(status, [msg|err], properties)copiespropertiesonto the error witherr[key] = props[key]. Whenpropertieshas an own__proto__key (for example fromJSON.parseof partially-untrusted data), the bracket assignment invokes the__proto__setter and callsObject.setPrototypeOf(err, ...), soerr instanceof Error,err instanceof createError.HttpErrorandcreateError.isHttpError(err)all becomefalseon an error the module just produced.The README states the
(status, error, properties)form "will not alter the inheritance of the given error object", and an existing test already asserts the prototype is preserved. This skips the__proto__key alongsidestatus/statusCodein the copy loop. The effect is scoped to the created object; there is no globalObject.prototypepollution.