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] Generic Object Injection Sink #45

Open
DerekNonGeneric opened this issue Aug 17, 2022 — with Codacy Production · 3 comments
Open

[security] Generic Object Injection Sink #45

DerekNonGeneric opened this issue Aug 17, 2022 — with Codacy Production · 3 comments

Comments

Copy link
Member

Codacy detected an issue:

Message: Generic Object Injection Sink

Currently on:

@DerekNonGeneric
Copy link
Member Author

@DerekNonGeneric
Copy link
Member Author

As a potential solution, the initProperty function can be used to get us partially there. The initProperty function and friends, however, should be useful as a solution for the specific problem of “Object Injection Sink” as it appears throughout the rest of the codebase as well.

As noted by ljharb, the implementation of omit can actually be implemented using:

ljharb: for omit tho, there's a lot better ways to implement it like function omit(obj, keys) { return Object.fromEntries(Object.entries(obj).filter(([k]) => !keys.includes(k))); }

Performance can be a deciding factor on what the implementation should look like here as it is related to #27.


Notably, the for...in loop enumerates properties in the prototype chain as well.1 This can be used to dynamically create the list of disallowed property keys by using an Object literal (available via syntax {}) as input (as opposed to a POJO, which normally has a null prototype available via new Object(null)).

Footnotes

  1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

@DerekNonGeneric DerekNonGeneric changed the title [Security] Generic Object Injection Sink [security] Generic Object Injection Sink Aug 18, 2022
@DerekNonGeneric
Copy link
Member Author

DerekNonGeneric commented Aug 18, 2022

Reopening as would like to see this tested…

Also, [potentially] returning the originally-passed object as mutated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant