Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔒fix: CVE 2023 26115 (2) #41

Merged
merged 7 commits into from
Jul 18, 2023
Merged

🔒fix: CVE 2023 26115 (2) #41

merged 7 commits into from
Jul 18, 2023

Conversation

OlafConijn
Copy link
Collaborator

@OlafConijn OlafConijn commented Jul 13, 2023

Fixes #32

CVE-2023-26115
TLDR; ReDoS, the issue is due to Regex matching algo.

This PR proposes an alternative solution to #33 in which:

  • string.prototype.trimEnd is not used, as this would break when ran on older nodejs runtimes.
  • no (new) regular expressions are vulnerable to ReDoS (e.g. /\s+$/gm).

Performance:

  • The custom trimEnd is slower compared to native string.prototype.trimEnd.
  • The performance of the trimEnd function however is comparable to the original regular expression.

results here

image

@OlafConijn OlafConijn changed the title 🔒fix: CVE 2023 26115 2 🔒fix: CVE 2023 26115 (2) Jul 13, 2023
@sawilde
Copy link

sawilde commented Jul 15, 2023

string.prototype.trimEnd is not used, as this would break when ran on older nodejs runtimes.

Is there a reason why we can't use the built-in trimEnd if it is available and only revert to a custom implementation when it is not?

@OlafConijn
Copy link
Collaborator Author

OlafConijn commented Jul 15, 2023

Is there a reason why we can't use the built-in trimEnd if it is available and only revert to a custom implementation when it is not?

We certainly could. it would be a nice performance improvement for those running node >=10

I think using the built-in trimEnd requires a slight bit more discussion/thought as this strips out more than just & \t (see here). As the library is used widely it is hard to oversee the effects of changing the implementation to use trimEnd.

I do think it's more likely to be an improvement than a regression. I would hoever advocate for making it a different release where consumers can roll back on the trimEnd change without having to roll back to a version that is vulnerable to CVE 2023 26115.

@doowb
Copy link
Collaborator

doowb commented Jul 18, 2023

Thanks @OlafConijn !

I'm merging and publishing this fix now.

@doowb doowb merged commit 420dce9 into master Jul 18, 2023
@doowb doowb mentioned this pull request Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regular Expression Denial of Service (ReDoS) - CVE-2023-26115
5 participants