d3-selection Prototype Pollution Vulnerability

Open
#323 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
d3, javascript
Domain
frontend, security

Research direction

Start with the local.set method in d3-selection/src/local.js and trace how it stores values when given Object.prototype. Reproduce the report using its Node.js proof of concept and confirm whether the prototype is modified. Done means the reported pollution is prevented while the existing local.set behavior remains intact.

Written by the indexing model from the issue text.

Description

hi, we are a security team. We found a Prototype Pollution vulnerability in your project.
Vulnerability Cause
The local.set() method uses numeric IDs as keys to store data. It does not check if the node is Object.prototype, so passing the prototype object causes global pollution.
Vulnerable Code Location
d3-selection/src/local.js – set method

node[id] = value;
Pollutes prototype directly when node = Object.prototype.

Proof of Concept (POC)

const d3_selection = require('d3-selection');
const local = d3_selection.local();

// Pass prototype object
local.set(Object.prototype, 'polluted', 'd3_polluted');

// Verify pollution
console.log({}.polluted); // Output: d3_polluted

Reproduction Steps
Install: npm i d3-selection
Run poc.js
If polluted value is printed, vulnerability is reproduced
Impact
Affects all applications using d3 visualization libraries; may break application logic or enable further attacks.

Dominant language
JavaScript
Stars
571
Forks
283
Avg merge
7h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from d3/d3-selection

All issues in d3/d3-selection

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.