{"id":"CVE-2025-66020","aliases":["CVE-2025-66020","GHSA-vqpr-j7v3-hqw9"],"related":[],"kind":"vulnerability","state":"published","title":"Valibot has a ReDoS vulnerability in `EMOJI_REGEX`","summary":"Valibot helps validate data using a schema. In versions from 0.31.0 to 1.1.0, the EMOJI_REGEX used in the emoji action is vulnerable to a Regular Expression Denial of Service (ReDoS) attack. A short, maliciously crafted string (e.g., <100 characters) can cause the regex engine to consume excessive CPU time (minutes), leading to a Denial of Service (DoS) for the application. This issue has been patched in version 1.2.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Valibot helps validate data using a schema. In versions from 0.31.0 to 1.1.0, the EMOJI_REGEX used in the emoji action is vulnerable to a Regular Expression Denial of Service (ReDoS) attack. A short, maliciously crafted string (e.g., <100 characters) can cause the regex engine to consume excessive CPU time (minutes), leading to a Denial of Service (DoS) for the application. This issue has been patched in version 1.2.0.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe `EMOJI_REGEX` used in the `emoji` action is vulnerable to a Regular Expression Denial of Service (ReDoS) attack. A short, maliciously crafted string (e.g., <100 characters) can cause the regex engine to consume excessive CPU time (minutes), leading to a Denial of Service (DoS) for the application.\n\n### Details\n\nThe ReDoS vulnerability stems from \"catastrophic backtracking\" in the `EMOJI_REGEX`. This is caused by ambiguity in the regex pattern due to overlapping character classes.\n\nSpecifically, the class `\\p{Emoji_Presentation}` overlaps with more specific classes used in the same alternation, such as `[\\u{1F1E6}-\\u{1F1FF}]` (regional indicator symbols used for flags) and `\\p{Emoji_Modifier_Base}`.\n\nWhen the regex engine attempts to match a string that almost matches but ultimately fails (like the one in the PoC), this ambiguity forces it to explore an exponential number of possible paths. The matching time increases exponentially with the length of the crafted input, rather than linearly.\n\n### PoC\n\nThe following code demonstrates the vulnerability.\n\n```javascript\nimport * as v from 'valibot';\n\nconst schema = v.object({\n  x: v.pipe(v.string(), v.emoji()),\n});\n\nconst attackString = '\\u{1F1E6}'.repeat(49) + '0';\n\nconsole.log(`Input length: ${attackString.length}`);\nconsole.log('Starting parse... (This will take a long time)');\n\n// On my machine, a length of 99 takes approximately 2 minutes.\nconsole.time();\ntry {\n  v.parse(schema, {x: attackString });\n} catch (e) {}\nconsole.timeEnd();\n```\n\n### Impact\n\nAny project using Valibot's `emoji` validation on user-controllable input is vulnerable to a Denial of Service attack.\n\nAn attacker can block server resources (e.g., a web server's event loop) by submitting a short string to any endpoint that uses this validation. This is particularly dangerous because the attack string is short enough to bypass typical input length restrictions (e.g., maxLength(100)).\n\n### Recommended Fix\n\nThe root cause is the overlapping character classes. This can be resolved by making the alternatives mutually exclusive, typically by using negative lookaheads (`(?!...)`) to subtract the specific classes from the more general one.\n\nThe following modified `EMOJI_REGEX` applies this principle:\n\n```javascript\nexport const EMOJI_REGEX: RegExp =\n  // eslint-disable-next-line redos-detector/no-unsafe-regex, regexp/no-dupe-disjunctions -- false positives\n  /^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$/u;\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"Valibot ayuda a validar datos usando un esquema. En las versiones de 0.31.0 a 1.1.0, la EMOJI_REGEX utilizada en la acción de emoji es vulnerable a un ataque de Denegación de Servicio por Expresiones Regulares (ReDoS). Una cadena corta y maliciosamente elaborada (por ejemplo, anterior a 100 caracteres) puede hacer que el motor de expresiones regulares consuma un tiempo excesivo de CPU (minutos), lo que lleva a una Denegación de Servicio (DoS) para la aplicación. Este problema ha sido parcheado en la versión 1.2.0.","source":"nvd"}],"published":"2025-11-26T01:49:38.276Z","modified":"2026-10-23T22:10:00.160Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-1333"],"affected":[{"ranges":[{"version":">= 0.31.0, < 1.2.0","status":"affected"}],"vendor":"open-circle","product":"valibot","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0.31.0","status":"affected","fixed":"1.2.0"}],"ecosystem":"npm","package":"valibot","purl":"pkg:npm/valibot","source":"ghsa"}],"references":[{"url":"https://github.com/open-circle/valibot/security/advisories/GHSA-vqpr-j7v3-hqw9","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/open-circle/valibot/commit/cfb799db301a953a0950d5c05a34a3ab121262dc","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-66020","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/open-circle/valibot","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2025-11-26T14:15:40.424Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-66020","url":"https://www.cve.org/CVERecord?id=CVE-2025-66020","licence":"CVE Terms of Use","modified":"2025-11-26T14:16:54.610Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-vqpr-j7v3-hqw9","url":"https://github.com/advisories/GHSA-vqpr-j7v3-hqw9","licence":"CC-BY-4.0","modified":"2025-11-26T20:28:24.415Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-66020","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-66020","licence":"Public domain","modified":"2026-10-23T22:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:08.029Z","epss":{"score":0.00355,"percentile":0.31225,"date":"2026-12-01T12:00:22.000Z"}}