CVE-2022-24725: shescape - Exposure of home directory through shescape on Unix with Bash

shescape Updated 02 Oct 2025

Summary

03/03/2022
Yes i
Moderate
5.5

CVE-2022-24725: Exposure of home directory through shescape on Unix with Bash. Affects shescape versions >= 1.4.0, < 1.5.1. Fixed in 1.5.1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

shescape is an npm package that provides a set of functions for escaping special characters in shell commands. It is commonly used in Unix systems with Bash to ensure the safe execution of shell commands. However, a vulnerability has been discovered in shescape that can lead to the exposure of the home directory on Unix systems when using the escape or escapeAll functions with the interpolation option set to true. This vulnerability does not affect other tested shells like Dash and Zsh.

Vulnerability Detail

The vulnerability in shescape arises from the improper handling of the tilde character (~) when the interpolation option is enabled. By crafting a payload with the home_directory=~ string and using the escape or escapeAll functions with the interpolation option set to true, an attacker can cause the home directory to be exposed. Depending on how the output of shescape is used, this can potentially lead to directory traversal attacks in the application using shescape.

How To Fix

Minimum fixed version

1.5.1

This is the first release that contains the fix.

npm install shescape@1.5.1

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating the shescape dependency is not immediately feasible, a temporary workaround is to manually escape all instances of the tilde character (~) using the replace method. For example, developers can use the following code snippet to replace all tildes with \~: arg.replace(/~/g, '\\~'). This workaround should be applied to any code that uses the escape or escapeAll functions with the interpolation option set to true.

Conclusion

The vulnerability in shescape that exposes the home directory on Unix systems has been described. It is important for developers to update their shescape dependency to version 1.5.1 or higher to mitigate the vulnerability. If immediate updating is not possible, the provided workaround can be used. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for shescape →

Share this vulnerability

FAQ

shescape is an npm package that provides functions for escaping special characters in shell commands. It is commonly used in Unix systems with Bash.

The vulnerability allows for the exposure of the home directory on Unix systems when using shescape with the interpolation option set to true. This can potentially lead to directory traversal attacks in the application using shescape.

Only Bash is affected by this vulnerability. Other tested shells like Dash and Zsh are not affected.

Yes, the vulnerability has been patched in version 1.5.1 of shescape. It is recommended to update to the latest version to mitigate the vulnerability.

Yes, a temporary workaround is to manually escape all instances of the tilde character (~) using the replace method. This should be done for any code that uses the affected functions with the interpolation option set to true.

Related vulnerabilities

Recent vulnerabilities recorded for shescape.

How To Fix

Minimum fixed version

1.5.1

This is the first release that contains the fix.

npm install shescape@1.5.1

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback