Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS00NDZ3LXJybTQtcjQ3Zs0v7w

Exposure of home directory through shescape on Unix with Bash

Impact

The issue allows for exposure of the home directory on Unix systems when using Bash with the escape or escapeAll functions from the shescape API with the interpolation option set to true. Other tested shells, Dash and Zsh, are not affected.

const cp = require("child_process");
const shescape = require("shescape");

const payload = "home_directory=~";
const options = { interpolation: true };
console.log(cp.execSync(`echo ${shescape.escape(payload, options)}`));
// home_directory=/home/user

Depending on how the output of shescape is used, directory traversal may be possible in the application using shescape.

Patches

The issue was patched in v1.5.1.

Workarounds

Manually escape all instances of the tilde character (~) using arg.replace(/~/g, "\\~").

References

See GitHub issue https://github.com/ericcornelissen/shescape/issues/169.

Permalink: https://github.com/advisories/GHSA-446w-rrm4-r47f
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS00NDZ3LXJybTQtcjQ3Zs0v7w
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: about 2 years ago
Updated: 11 months ago


CVSS Score: 5.5
CVSS vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Identifiers: GHSA-446w-rrm4-r47f, CVE-2022-24725
References: Repository: https://github.com/ericcornelissen/shescape
Blast Radius: 8.0

Affected Packages

npm:shescape
Dependent packages: 15
Dependent repositories: 28
Downloads: 14,328 last month
Affected Version Ranges: >= 1.4.0, < 1.5.1
Fixed in: 1.5.1
All affected versions: 1.4.0, 1.5.0
All unaffected versions: 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 2.0.0, 2.0.1, 2.0.2, 2.1.0, 2.1.1