GHSA-CCGF-5RWJ-J3HV
Vulnerability from github – Published: 2026-04-02 23:21 – Updated: 2026-05-20 18:08Summary
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):
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):
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.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "telejson"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "6.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-47099"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2026-04-02T23:21:23Z",
"nvd_published_at": null,
"severity": "LOW"
},
"details": "## Summary\n \ntelejson 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.\n \n## Affected versions\n \n| Package | Affected | Fixed |\n|----------|-----------|----------|\n| telejson | \u003c 6.0.0 | \u003e= 6.0.0 |\n \n \n## Details\n \ntelejson\u0027s `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\u0027s prototype.\n \nIn 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.\n \n**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)):\n \n```ts\nif (isObject\u003cValueContainer\u003e(value) \u0026\u0026 value[\u0027_constructor-name_\u0027]) {\n const name = value[\u0027_constructor-name_\u0027];\n if (name !== \u0027Object\u0027) {\n const Fn = new Function(`return function ${name}(){}`)();\n Object.setPrototypeOf(value, new Fn());\n }\n```\n \n**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)):\n \n```ts\nif (isObject\u003cValueContainer\u003e(value) \u0026\u0026 value[\u0027_constructor-name_\u0027] \u0026\u0026 options.allowFunction) {\n const name = value[\u0027_constructor-name_\u0027];\n if (name !== \u0027Object\u0027) {\n const Fn = new Function(`return function ${name.replace(/[\\W_]+/g, \u0027\u0027)}(){}`)();\n Object.setPrototypeOf(value, new Fn());\n }\n```\n \nThe 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.\n \n## Impact\n \nAn 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.\n \n## Remediation\n \nUpgrade to telejson \u003e= 6.0.0.",
"id": "GHSA-ccgf-5rwj-j3hv",
"modified": "2026-05-20T18:08:00Z",
"published": "2026-04-02T23:21:23Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/storybookjs/telejson/security/advisories/GHSA-ccgf-5rwj-j3hv"
},
{
"type": "PACKAGE",
"url": "https://github.com/storybookjs/telejson"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "TeleJSON: DOM XSS via unsanitised constructor name in `new Function()`"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.