Skip to content

Conversation

@rmi22186
Copy link
Member

@rmi22186 rmi22186 commented Dec 2, 2025

Background

Previous version of jQuery and lodash had a prototype pollution issue in their extend functions. It allows bad actors to pass __proto__, prototype, or constructor to create unintended behavior for the SDK, which uses the extend helper function throughout the SDK to merge configuration objects and options.

What Has Changed

Added validation to skip reserved object properties (proto, constructor, prototype) during object extension operations, following JavaScript best practices for property iteration.

Screenshots/Video

  • {Include any screenshots or video demonstrating the new feature or fix, if applicable}

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Reference Issue (For employees only. Ignore if you are an outside contributor)

Copy link

@glen-testing glen-testing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security approves because we asked for this as a result of a bugbounty report. We didn't confirm any functionality isn't affected.

Copy link
Contributor

@jaissica12 jaissica12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this PR since the prototype pollution fix looks solid and the tests are comprehensive. We can add a couple more tests and clean up some SonarCloud noise, but nothing blocking.

describe('extend() - Prototype Pollution Prevention', () => {
it('should block __proto__ in shallow merge', () => {
const malicious = JSON.parse('{"__proto__": {"isAdmin": true}}');
const result = helpers.extend({}, malicious);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the unused variable noise we can add minimal assertions like expect(result).toBeDefined() or expect(typeof result).toBe('object') .
This satisfies the linter while keeping the tests focused on pollution blocking

@@ -0,0 +1,201 @@
import Helpers from '../../src/helpers';

describe('Helpers - Prototype Pollution Protection', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add tests for:
(1) objects with null prototype (Object.create(null)) to handle prototype-less objects
(2) null/undefined source arguments (extend({}, obj1, null, obj2, undefined)) to ensure extend() handles these edge cases correctly.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 4, 2025

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.

5 participants