Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security: switch to using Map during parsing #99

Closed
bcoe opened this issue Apr 10, 2022 · 4 comments
Closed

security: switch to using Map during parsing #99

bcoe opened this issue Apr 10, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@bcoe
Copy link
Collaborator

bcoe commented Apr 10, 2022

Once we merge into the Node.js codebase, getting security patches out the door becomes more painful.

I've had to fix several prototype related bugs/security notifications over the years by virtue of using a POJO when parsing. Here's an example as to how this can cause weird behavior:

> const obj = {__proto__: {a: 99}}
undefined
> obj.a
99

I think it would be worth preemptively moving our implementation to using a Map, and then converting the Map into an object as a final step.

@bcoe bcoe added the enhancement New feature or request label Apr 10, 2022
@shadowspawn
Copy link
Collaborator

The issues I looked at that were reported against Yargs and Minimist were due to supporting structured options, where --foo.bar is parsed into { foo: { bar: true } }. We are doing single level assignment in parseArgs, although we do also have arrays.

I'm not against using SafeMap, but I don't think we are exposed to the same risks.

(Previous PR using SafeMap without tests: #65)

@bcoe
Copy link
Collaborator Author

bcoe commented Apr 11, 2022

The issues I looked at that were reported against Yargs and Minimist were due to supporting structured options, where --foo.bar

I agree, potentially I'm being too paranoid. I wasn't sure if:

const obj = {__proto__: 99}

Is cause for a alarm? as far as I can tell the key just get dropped.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Apr 14, 2022

There is now a test in StoreOptionValue to return early if the key is __proto__ (thanks to @bcoe).

See also #108 for low tech map, the null prototype object.

I suggest SafeMap is more churn than useful and close this issue?

@bcoe
Copy link
Collaborator Author

bcoe commented Apr 14, 2022

👍 let's close this issue and concentrate on #104

@bcoe bcoe closed this as completed Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants