You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Details
The ReDoS vulnerability stems from "catastrophic backtracking" in the EMOJI_REGEX. This is caused by ambiguity in the regex pattern due to overlapping character classes.
Specifically, 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}.
When 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.
PoC
The following code demonstrates the vulnerability.
import*asvfrom'valibot';constschema=v.object({x: v.pipe(v.string(),v.emoji()),});constattackString='\u{1F1E6}'.repeat(49)+'0';console.log(`Input length: ${attackString.length}`);console.log('Starting parse... (This will take a long time)');// On my machine, a length of 99 takes approximately 2 minutes.console.time();try{v.parse(schema,{x: attackString});}catch(e){}console.timeEnd();
Impact
Any project using Valibot's emoji validation on user-controllable input is vulnerable to a Denial of Service attack.
An 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)).
Recommended Fix
The 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.
The following modified EMOJI_REGEX applies this principle:
Add examples action to add example values to a schema (pull request #1199)
Add getExamples method to extract example values from a schema (pull request #1199)
Add isbn validation action to validate ISBN-10 and ISBN-13 strings (pull request #1097)
Add exports for RawCheckAddIssue, RawCheckContext, RawCheckIssueInfo, RawTransformAddIssue, RawTransformContext and RawTransformIssueInfo types for better developer experience with rawCheck and rawTransform actions (pull request #1359)
Change build step to tsdown
Fix ReDoS vulnerability in EMOJI_REGEX used by emoji action
Add gtValue and ltValue action for greater than and less than validation (pull request #978, #985)
Add values and notValues action for easier multi-value validation (pull request #919)
Add slug action to validate URL slugs (pull request #910)
Add support for ReadonlyMap and ReadonlySet to readonly action (issue #1059)
Add entriesFromObjects util to improve tree shaking (pull request #1023)
Add new overload signature to pipe and pipeAync method to support unlimited pipe items of same input and output type (issue #852)
Add @__NO_SIDE_EFFECTS__ notation to improve tree shaking (pull request #995)
Add exactOptional and exactOptionalAsync schema (PR #1013)
Change types and implementation to support Standard Schema
Change behaviour of minValue and maxValue for NaN (pull request #843)
Change type and behaviour of nullable, nullableAsync, nullish, nullishAsync, optional, optionalAsync, undefinedable and undefinedableAsync for undefined default value (issue #878)
Change type signature of partialCheck and partialCheckAsync action to add .pathList property in a type-safe way
Change type signature of findItem action to support type predicates (issue #867)
Change validation of missing object entries in looseObject, looseObjectAsync, object, objectAsync, objectWithRest, objectWithRestAsync, strictObject and strictObject (PR #1013)
Change type signature of optional and optionalAsync when used within an object schema (PR #1013)
Change MarkOptional type to fix order of entries and TS error when using generic schemas (issue #1021)
Change VariantOption and VariantOptionAsync type to fix TS error when using generic schemas (issue #842)
Change implementation of variant and variantAsync to support optional discriminators using exactOptional, exactOptionalAsync, optional, optionalAsync, nullish or nullishAsync
Change _addIssue to not ignore empty strings as error message (pull request #1065)
Change ISO_DATE_TIME_REGEX and ISO_TIMESTAMP_REGEX to support space as separator (pull request #1064)
Change pipe tuple of pipe and pipeAsync to be readonly by default
Change forward, forwardCheck, partialCheck and partialCheckAsync to improve TypeScript performance (issue #987)
Change DECIMAL_REGEX to support floats that start with a dot (pull request #1086)
Change exports to export only public types to reduce noise
Refactor bytes, maxBytes, minBytes and notBytes action
Fix implementation of nonOptional, nonOptionalAsync, nonNullable, nonNullableAsync, nonNullish and nonNullishAsync schema in edge cases (issue #909)
Fix instantiation error for any in PathKeys type (issue #929)
Fix TypeScript error of keyof method for objects with many keys (pull request #988)
Fix options filtering in enum_ schema (pull request #941)
Fix partialCheck and partialCheckAsync action for typed data with issues
Configuration
📅 Schedule: Branch creation - "" in timezone America/New_York, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
If you want to rebase/retry this PR, check this box
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@remix-run/node@2.15.0. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
Warn
Obfuscated code: npm @expo/cli is 98.0% likely obfuscated
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@expo/cli@0.18.19. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
Warn
Obfuscated code: npm @react-native/debugger-frontend is 96.0% likely obfuscated
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@react-native/debugger-frontend@0.74.83. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
Warn
Obfuscated code: npm @react-native/debugger-frontend is 96.0% likely obfuscated
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@react-native/debugger-frontend@0.74.84. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
Warn
Obfuscated code: npm @react-native/debugger-frontend is 96.0% likely obfuscated
Next steps: Take a moment to review the security alert above. Review
the linked package source code to understand the potential risk. Ensure the
package is not malicious before proceeding. If you're unsure how to proceed,
reach out to your security team or ask the Socket team for help at
support@socket.dev.
Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@react-native/debugger-frontend@0.74.88. You can
also ignore all packages with @SocketSecurity ignore-all.
To ignore an alert for all future pull requests, use Socket's Dashboard to
change the triage state of this alert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependenciesUpgrade or downgrade of project dependencies.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^0.42.1→^1.0.0GitHub Vulnerability Alerts
CVE-2025-66020
Summary
The
EMOJI_REGEXused in theemojiaction 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.Details
The ReDoS vulnerability stems from "catastrophic backtracking" in the
EMOJI_REGEX. This is caused by ambiguity in the regex pattern due to overlapping character classes.Specifically, 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}.When 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.
PoC
The following code demonstrates the vulnerability.
Impact
Any project using Valibot's
emojivalidation on user-controllable input is vulnerable to a Denial of Service attack.An 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)).
Recommended Fix
The 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.The following modified
EMOJI_REGEXapplies this principle:Release Notes
open-circle/valibot (valibot)
v1.2.0Compare Source
Many thanks to @EskiMojo14, @makenowjust, @ysknsid25 and @jacekwilczynski for contributing to this release.
toBigint,toBoolean,toDate,toNumberandtoStringtransformation actions (pull request #1212)examplesaction to add example values to a schema (pull request #1199)getExamplesmethod to extract example values from a schema (pull request #1199)isbnvalidation action to validate ISBN-10 and ISBN-13 strings (pull request #1097)RawCheckAddIssue,RawCheckContext,RawCheckIssueInfo,RawTransformAddIssue,RawTransformContextandRawTransformIssueInfotypes for better developer experience withrawCheckandrawTransformactions (pull request #1359)EMOJI_REGEXused byemojiactionv1.1.0Compare Source
Many thanks to @EltonLobo07, @sacrosanctic, @muningis, @EskiMojo14, @MOZGIII, @vktrl and @jasperteo for contributing to this release.
messagemethod to overwrite local error message configuration of a schema (pull request #1103)summarizemethod to summarize issues into a pretty-printable multi-line string (pull request #1158)getTitle,getDescriptionandgetMetadatamethods to extract metadata of a schema (pull request #1154)minEntriesandmaxEntriesvalidation action to validate number of object entries (pull request #1100)entriesandnotEntriesvalidation action to validate number of object entries (pull request #1156)parseJsonandstringifyJsontransformation action to parse and stringify JSON (pull request #1137)flavortransformation action to flavor the output type of a schema (pull request #950)multipleOfvalidation action (pull request #1164)variantandvariantAsyncschema to improve performance by aborting validation of discriminators early (pull request #1110)NanoIDActionandNanoIDIssueinterface toNanoIdActionandNanoIdIssue(pull request #1171)MarkOptionaltype to fix input and output type of objects in edge cases (issue #1176)v1.0.0Compare Source
This is a summary of the changes between v0 and v1. Many thanks to everyone who contributed to this release.
assertmethod to assert values (issue #862)checkItemsAsyncaction (pull request #856)graphemes,maxGraphemes,minGraphemesandnotGraphemesaction (pull request #853)words,maxWords,minWordsandnotWordsactionargsandreturnsaction to transform functions (issue #243)rfcEmailaction to validate RFC 5322 email addresses (pull request #912)gtValueandltValueaction for greater than and less than validation (pull request #978, #985)valuesandnotValuesaction for easier multi-value validation (pull request #919)slugaction to validate URL slugs (pull request #910)ReadonlyMapandReadonlySettoreadonlyaction (issue #1059)entriesFromObjectsutil to improve tree shaking (pull request #1023)pipeandpipeAyncmethod to support unlimited pipe items of same input and output type (issue #852)@__NO_SIDE_EFFECTS__notation to improve tree shaking (pull request #995)exactOptionalandexactOptionalAsyncschema (PR #1013)minValueandmaxValueforNaN(pull request #843)nullable,nullableAsync,nullish,nullishAsync,optional,optionalAsync,undefinedableandundefinedableAsyncfor undefined default value (issue #878)partialCheckandpartialCheckAsyncaction to add.pathListproperty in a type-safe wayfindItemaction to support type predicates (issue #867)looseObject,looseObjectAsync,object,objectAsync,objectWithRest,objectWithRestAsync,strictObjectandstrictObject(PR #1013)optionalandoptionalAsyncwhen used within an object schema (PR #1013)MarkOptionaltype to fix order of entries and TS error when using generic schemas (issue #1021)VariantOptionandVariantOptionAsynctype to fix TS error when using generic schemas (issue #842)variantandvariantAsyncto support optional discriminators usingexactOptional,exactOptionalAsync,optional,optionalAsync,nullishornullishAsync_addIssueto not ignore empty strings as error message (pull request #1065)ISO_DATE_TIME_REGEXandISO_TIMESTAMP_REGEXto support space as separator (pull request #1064)pipeandpipeAsyncto be readonly by defaultforward,forwardCheck,partialCheckandpartialCheckAsyncto improve TypeScript performance (issue #987)DECIMAL_REGEXto support floats that start with a dot (pull request #1086)bytes,maxBytes,minBytesandnotBytesactionnonOptional,nonOptionalAsync,nonNullable,nonNullableAsync,nonNullishandnonNullishAsyncschema in edge cases (issue #909)anyinPathKeystype (issue #929)keyofmethod for objects with many keys (pull request #988)enum_schema (pull request #941)partialCheckandpartialCheckAsyncaction for typed data with issuesConfiguration
📅 Schedule: Branch creation - "" in timezone America/New_York, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.