PT-2026-32206 · Npm · Telejson

Publicado

2026-04-02

·

Atualizado

2026-04-02

CVSS v3.1

6.1

Média

VetorAV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

Summary

telejson versions prior to 6.0.0 (released 2022) are vulnerable to DOM-based Cross-Site Scripting (XSS) through unsafe deserialisation. Attacker-controlled input from the constructor-name property in parsed JSON is passed directly to new Function() without sanitisation, allowing arbitrary JavaScript execution.

Affected versions

PackageAffectedFixed
telejson< 6.0.0>= 6.0.0

Details

telejson's parse() function uses a custom reviver to reconstruct JavaScript objects from serialised JSON. When processing objects with a constructor-name property, the reviver passes the constructor name directly to new Function() to recreate the object's prototype.
In versions prior to 6.0.0, this constructor name is not sanitised. An attacker who can deliver a crafted JSON payload to telejson.parse() (for example, via postMessage in applications that use telejson for cross-frame communication) can inject arbitrary JavaScript into the new Function() call.
ts
if (isObject<ValueContainer>(value) && value[' constructor-name ']) {
 const name = value[' constructor-name '];
 if (name !== 'Object') {
  const Fn = new Function(`return function ${name}(){}`)();
  Object.setPrototypeOf(value, new Fn());
 }
ts
if (isObject<ValueContainer>(value) && value[' constructor-name '] && options.allowFunction) {
 const name = value[' constructor-name '];
 if (name !== 'Object') {
  const Fn = new Function(`return function ${name.replace(/[W ]+/g, '')}(){}`)();
  Object.setPrototypeOf(value, new Fn());
 }
The fix introduces two mitigations: a character allowlist via regex that strips non-word characters before they reach new Function(), and gating the entire code path behind the allowFunction option.

Impact

An attacker can execute arbitrary JavaScript in the context of the application using the vulnerable telejson version. Depending on the application, this could enable session hijacking, credential theft, or arbitrary DOM manipulation.

Remediation

Upgrade to telejson >= 6.0.0.

Exploit

Correção

XSS

Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾

Enumeração de Fraquezas

Identificadores relacionados

GHSA-CCGF-5RWJ-J3HV

Produtos afetados

Telejson