Skip to content

Prevent object prototype pollution#799

Merged
mattbaileyuk merged 1 commit into
masterfrom
pollution
May 19, 2026
Merged

Prevent object prototype pollution#799
mattbaileyuk merged 1 commit into
masterfrom
pollution

Conversation

@andrew-coleman
Copy link
Copy Markdown
Member

In line with best practices described here:
https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/Prototype_pollution the following changes have been made across the codebase to prevent potential object prototype pollution:

  • All objects created using … = {} have been changed to ... = Object.create(null) (i.e.) null prototype objects.
  • All occurrencies of obj.hasOwnProperty(‘prop’) have been changed to Object.prototype.hasOwnProperty.call(obj, ‘prop’)
  • All occurrencies of for(const prop in obj) have been changed to for(const prop of Object.keys(obj))
  • Changed arr.forEach(…) to Array.prototype.forEach.call(arr, …) when iterating over input sequences.

In line with best practices described here:
https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/Prototype_pollution
the following changes have been made across the codebase to prevent potential object prototype pollution:
- All objects created using `… = {}` have been changed to `... = Object.create(null)` (i.e.) null prototype objects.
- All occurrencies of `obj.hasOwnProperty(‘prop’)` have been changed to `Object.prototype.hasOwnProperty.call(obj, ‘prop’)`
- All occurrencies of `for(const prop in obj)` have been changed to `for(const prop of Object.keys(obj))`
- Changed arr.forEach(…) to Array.prototype.forEach.call(arr, …) when iterating over input sequences.

Signed-off-by: Andrew Coleman <andrew_coleman@uk.ibm.com>
@mattbaileyuk mattbaileyuk merged commit 59e2514 into master May 19, 2026
8 checks passed
@mattbaileyuk mattbaileyuk deleted the pollution branch May 19, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants