GHSA-446w-rrm4-r47f

Suggest an improvement
Source
https://github.com/advisories/GHSA-446w-rrm4-r47f
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/03/GHSA-446w-rrm4-r47f/GHSA-446w-rrm4-r47f.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-446w-rrm4-r47f
Aliases
Published
2022-03-03T19:26:11Z
Modified
2023-11-08T04:08:33Z
Severity
  • 5.5 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N CVSS Calculator
Summary
Exposure of home directory through shescape on Unix with Bash
Details

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.

Database specific
{
    "cwe_ids": [
        "CWE-200",
        "CWE-78"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2022-03-03T19:26:11Z",
    "nvd_published_at": "2022-03-03T22:15:00Z",
    "severity": "MODERATE"
}
References

Affected packages

npm / shescape

Package

Affected ranges

Type
SEMVER
Events
Introduced
1.4.0
Fixed
1.5.1

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/03/GHSA-446w-rrm4-r47f/GHSA-446w-rrm4-r47f.json"