CS Fundamentals Trainer · JavaScript · Security

Which of these reduce the risk of prototype pollution when handling user-controlled keys?

  1. Storing the data in objects created with `Object.create(null)`
  2. Wrapping the merge function in `try...catch`
  3. Using a `Map` instead of a plain object for the lookup table
  4. Skipping the keys `__proto__`, `constructor` and `prototype` in merge or set-by-path helpers
  5. Parsing the request body with `JSON.parse` instead of `eval`

Difficulty: medium

Answer this question

Related questions