Skip to content

Conversation

Moumouls
Copy link
Member

@Moumouls Moumouls commented Oct 10, 2025

Pull Request

Issue

Closes: GHSA-9g8m-v378-pcg3

Approach

Use Object create null

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

Summary by CodeRabbit

  • New Features
    • Added an API to remove per-object state and return the removed data when available.
  • Bug Fixes
    • Improved safety by using prototype-free maps for state storage, preventing prototype pollution from special class names or IDs.
    • Increased robustness across initialization, server data handling, and pending operations.
  • Tests
    • Added comprehensive tests covering prototype pollution scenarios to ensure no leakage and preserve normal behavior.

Copy link

parse-github-assistant bot commented Oct 10, 2025

🚀 Thanks for opening this pull request!

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Oct 10, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Refactors SingleInstanceStateController to use prototype-free maps via Object.create(null) for all state containers, updates related logic and imports, and adds a new exported removeState function. Adds tests guarding against prototype pollution with dangerous className/id inputs. Adjusts type declaration imports without API signature changes.

Changes

Cohort / File(s) Summary
State controller: proto-free maps and API addition
src/SingleInstanceStateController.ts
Replace all object-backed maps with Object.create(null) in initialization, access, and cleanup paths; adjust functions to operate on prototype-free structures; add exported removeState(obj: ParseObject): State
Prototype pollution tests
src/__tests__/SingleInstanceStateController-test.js
Add tests covering pollution attempts via "proto", "constructor", "prototype", and risky ids; verify no prototype pollution occurs and normal behavior remains intact; include cleanup assertions.
Type declarations import style
types/SingleInstanceStateController.d.ts
Switch single-quoted type imports to double quotes; no signature or API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Controller as SingleInstanceStateController
  participant ObjState as objectState (proto-free)
  participant ClassMap as per-class map (proto-free)

  Client->>Controller: initializeState(obj)
  Controller->>ObjState: ensure container (Object.create(null))
  Controller->>ClassMap: ensure class map (Object.create(null))
  Controller-->>Client: initialized

  Client->>Controller: getState(obj)
  Controller->>ObjState: lookup by className
  ObjState-->>Controller: class map (proto-free)
  Controller->>ClassMap: lookup by id
  ClassMap-->>Controller: State | undefined
  Controller-->>Client: State

  Client->>Controller: removeState(obj)
  Controller->>ObjState: lookup class map
  Controller->>ClassMap: delete id -> return State | null
  Controller-->>Client: removed State | null

  note over Controller,ObjState: All maps are prototype-free to avoid<br/>__proto__/constructor/prototype key collisions.
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly indicates the prototype pollution vulnerability being fixed in SingleInstanceStateController and references the GHSA advisory identifier, clearly summarizing the main change for reviewers.
Description Check ✅ Passed The pull request description adheres to the repository template by including the standard header, a linked advisory in the Issue section, a concise Approach summary, and completed task checkboxes, fulfilling all required sections.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cbe1fb and bb53225.

📒 Files selected for processing (1)
  • types/SingleInstanceStateController.d.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • types/SingleInstanceStateController.d.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build (Node 18, 18.20.4)
  • GitHub Check: build (Node 20, 20.15.1)
  • GitHub Check: build (Node 22, 22.4.1)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4a47f65) to head (bb53225).
⚠️ Report is 5 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff            @@
##             alpha     #2745   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           63        63           
  Lines         6185      6185           
  Branches      1456      1456           
=========================================
  Hits          6185      6185           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 10, 2025
@Moumouls
Copy link
Member Author

@mtrezza ready to review

@mtrezza
Copy link
Member

mtrezza commented Oct 14, 2025

@Moumouls Could you please check the failing types job?

@mtrezza mtrezza changed the title fix: GHSA-9g8m-v378-pcg3 fix: Prototype Pollution vulnerability in SingleInstanceStateController.initializeState (GHSA-9g8m-v378-pcg3) Oct 14, 2025
@mtrezza mtrezza changed the title fix: Prototype Pollution vulnerability in SingleInstanceStateController.initializeState (GHSA-9g8m-v378-pcg3) fix: Prototype Pollution vulnerability in SingleInstanceStateController (GHSA-9g8m-v378-pcg3) Oct 14, 2025
@mtrezza mtrezza merged commit 9e7c1ba into parse-community:alpha Oct 14, 2025
12 of 13 checks passed
parseplatformorg pushed a commit that referenced this pull request Oct 14, 2025
# [7.0.0-alpha.1](6.2.0-alpha.3...7.0.0-alpha.1) (2025-10-14)

### Bug Fixes

*  Prototype Pollution vulnerability in `SingleInstanceStateController`; fixes security vulnerability [GHSA-9g8m-v378-pcg3](GHSA-9g8m-v378-pcg3) ([#2745](#2745)) ([9e7c1ba](9e7c1ba))
* HTTP status code 3XX redirection for Parse Server URL not handled properly ([#2608](#2608)) ([58e7f58](58e7f58))
* Incorrect type in `ParseObject.fetch` parameter `options` ([#2726](#2726)) ([dc78419](dc78419))
* Prototype pollution in `Parse.Object` and internal APIs; fixes security vulnerability [GHSA-9f2h-7v79-mxw](https://github.com/parse-community/Parse-SDK-JS/security/advisories/GHSA-9f2h-7v79-mxw3) ([#2749](#2749)) ([0097398](0097398))
* Unhandled exception when calling `Parse.Cloud.run` with option value `null` ([#2622](#2622)) ([#2623](#2623)) ([2818ed9](2818ed9))

### Features

* Add `Parse.File` upload and download progress in browser and Node environments ([#2503](#2503)) ([d3ca465](d3ca465))
* Add option `Parse.nodeLogging` to fully log `Parse.Object` in Node.js environments ([#1594](#1594)) ([de9d057](de9d057))
* Remove `Parse.serverAuthType`, `Parse.serverAuthToken` infavor of CoreManager `REQUEST_HEADERS` config ([#2639](#2639)) ([ddc66a1](ddc66a1))

### BREAKING CHANGES

* The methods `Parse.serverAuthType()` and `Parse.serverAuthToken()` have been removed; use the CoreManager `REQUEST_HEADER` config to set authorization headers instead. ([ddc66a1](ddc66a1))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.0.0-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 14, 2025
parseplatformorg pushed a commit that referenced this pull request Oct 14, 2025
# [7.0.0](6.1.1...7.0.0) (2025-10-14)

### Bug Fixes

*  Prototype Pollution vulnerability in `SingleInstanceStateController`; fixes security vulnerability [GHSA-9g8m-v378-pcg3](GHSA-9g8m-v378-pcg3) ([#2745](#2745)) ([9e7c1ba](9e7c1ba))
* HTTP status code 3XX redirection for Parse Server URL not handled properly ([#2608](#2608)) ([58e7f58](58e7f58))
* Incorrect type in `ParseObject.fetch` parameter `options` ([#2726](#2726)) ([dc78419](dc78419))
* Missing error message when returning an internal server error ([#2543](#2543)) ([f91f3f1](f91f3f1))
* Prototype pollution in `Parse.Object` and internal APIs; fixes security vulnerability [GHSA-9f2h-7v79-mxw](GHSA-9f2h-7v79-mxw3) ([#2749](#2749)) ([0097398](0097398))
* Unhandled exception when calling `Parse.Cloud.run` with option value `null` ([#2622](#2622)) ([#2623](#2623)) ([2818ed9](2818ed9))

### Features

* Add `Parse.File` upload and download progress in browser and Node environments ([#2503](#2503)) ([d3ca465](d3ca465))
* Add `Uint8Array` support for `Parse.File` data ([#2548](#2548)) ([6f6bb66](6f6bb66))
* Add option `Parse.nodeLogging` to fully log `Parse.Object` in Node.js environments ([#1594](#1594)) ([de9d057](de9d057))
* Remove `Parse.serverAuthType`, `Parse.serverAuthToken` infavor of CoreManager `REQUEST_HEADERS` config ([#2639](#2639)) ([ddc66a1](ddc66a1))

### Performance Improvements

* Optimize bundle packaging with Vite ([#2553](#2553)) ([a4b19e5](a4b19e5))

### BREAKING CHANGES

* The methods `Parse.serverAuthType()` and `Parse.serverAuthToken()` have been removed; use the CoreManager `REQUEST_HEADER` config to set authorization headers instead. ([ddc66a1](ddc66a1))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 7.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released Released as stable version state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants