CVE-2022-25918: Regular Expression Denial of Service (ReDoS)

Published Oct 25, 2022
·
Updated

Impact

This impacts users that use shescape to escape arguments:

- for the Unix shell Bash, or any not-officially-supported Unix shell; - using the escape or escapeAll functions with the interpolation option set to true.

An attacker can cause polynomial backtracking in terms of the input string length due to a Regular Expression in shescape that is vulnerable to Regular Expression Denial of Service (ReDoS). Example:

javascript import as shescape from "shescape";

/ 1. Prerequisites / const options = { interpolation: true, // and shell: "/bin/bash", // or shell: "some-not-officially-supported-shell", // or shell: undefined, // Only if the system's default shell is bash or an unsupported shell. };

/ 2. Attack / let userInput = '{,'.repeat(150000); // polynomial backtracking

/ 3. Usage / shescape.escape(userInput, options); // or shescape.escapeAll([userInput], options);

Patches

This bug has been patched in v1.6.1 which you can upgrade to now. No further changes required.

Workarounds

Alternatively, a maximum length can be enforced on input strings to shescape to reduce the impact of the vulnerability. It is not recommended to try and detect vulnerable input strings, as the logic for this may end up being vulnerable to ReDoS itself.

References

- Shescape commit 552e8ea - Shescape Release v1.6.1

For more information

- Comment on commit 552e8ea - Open an issue at https://github.com/ericcornelissen/shescape/issues (New issue > Question > Get started)

Other sources

The package shescape from 1.5.10 and before 1.6.1 are vulnerable to Regular Expression Denial of Service (ReDoS) via the escape function in index.js, due to the usage of insecure regex in the escapeArgBash function.

Affected Software

3 affected componentsFixes available
npm/shescape>=1.5.10<1.6.1
1.6.1
Shescape Project Shescape Node.js=1.5.10
Shescape Project Shescape Node.js=1.6.0

Event History

Oct 25, 2022
Advisory Published
10:27 PM
Oct 27, 2022
CVE Published
via MITRE·05:05 AM
Data Sourced
via MITRE·05:05 AM
DescriptionSeverityWeakness

Frequently Asked Questions

1

What is the impact of CVE-2022-25918?

The vulnerability allows an attacker to cause polynomial backtracking, leading to Denial of Service (DoS).

2

Which versions of shescape are affected by CVE-2022-25918?

Versions 1.5.10 to 1.6.0 of shescape are vulnerable.

3

How can I fix CVE-2022-25918?

Upgrade to version 1.6.1 of shescape to fix the vulnerability.

4

Where can I find more information about CVE-2022-25918?

You can find more information about CVE-2022-25918 in the following references: [GitHub Advisory](https://github.com/ericcornelissen/shescape/security/advisories/GHSA-cr84-xvw4-qx3c), [NVD](https://nvd.nist.gov/vuln/detail/CVE-2022-25918), [GitHub Commit](https://github.com/ericcornelissen/shescape/commit/552e8eab56861720b1d4e5474fb65741643358f9).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203