## 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 | Package | Affected | Fixed | |----------|-----------|----------| | 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. **Vulnerable code** ([`src/index.ts`, lines 293-299 at v5.3.3](https://github.com/storybookjs/telejson/blob/v5.3.3/src/index.ts#L293-L299)): ```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()); } ``` **Fixed code** ([`src/index.ts`, lines 340-346 at v6.0.0](https://github.com/storybookjs/telejson/blob/v6.0.0/src/index.ts#L340-L346)): ```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.
## 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 | Package | Affected | Fixed | |----------|-----------|----------| | 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. **Vulnerable code** ([`src/index.ts`, lines 293-299 at v5.3.3](https://github.com/storybookjs/telejson/blob/v5.3.3/src/index.ts#L293-L299)): ```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()); } ``` **Fixed code** ([`src/index.ts`, lines 340-346 at v6.0.0](https://github.com/storybookjs/telejson/blob/v6.0.0/src/index.ts#L340-L346)): ```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.
Update telejson to 6.0.0 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanTeleJSON: DOM XSS via unsanitised constructor name in `new Function()` affects telejson (npm). Severity is low. ## 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 | Package | Affected | Fixed | |----------|-----------|----------| | 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. **Vulnerable code** ([`src/index.ts`, lines 293-299 at v5.3.3](https://github.com/storybookjs/telejson/blob/v5.3.3/src/index.ts#L293-L299)): ```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()); } ``` **Fixed code** ([`src/index.ts`, lines 340-346 at v6.0.0](https://github.com/storybookjs/telejson/blob/v6.0.0/src/index.ts#L340-L346)): ```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.
AI coding agents often install or upgrade packages automatically in npm. A low vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| telejsonnpm | <6.0.0 | 6.0.0 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL GuardUpdate telejson to 6.0.0 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanTeleJSON: DOM XSS via unsanitised constructor name in `new Function()` affects telejson (npm). Severity is low. ## 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 | Package | Affected | Fixed | |----------|-----------|----------| | 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. **Vulnerable code** ([`src/index.ts`, lines 293-299 at v5.3.3](https://github.com/storybookjs/telejson/blob/v5.3.3/src/index.ts#L293-L299)): ```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()); } ``` **Fixed code** ([`src/index.ts`, lines 340-346 at v6.0.0](https://github.com/storybookjs/telejson/blob/v6.0.0/src/index.ts#L340-L346)): ```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.
AI coding agents often install or upgrade packages automatically in npm. A low vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| telejsonnpm | <6.0.0 | 6.0.0 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL Guard