GHSA-fwj4-72fm-c93g

Suggest an improvement
Source
https://github.com/advisories/GHSA-fwj4-72fm-c93g
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2023/05/GHSA-fwj4-72fm-c93g/GHSA-fwj4-72fm-c93g.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-fwj4-72fm-c93g
Aliases
Published
2023-05-05T02:18:26Z
Modified
2024-08-20T20:59:06.806330Z
Summary
Under-validated ComSpec and cmd.exe resolution in Mutagen projects
Details

Impact

Mutagen projects offer shell-based execution functionality. On Windows, the shell is resolved using the standard %ComSpec% mechanism, with a fallback to a %PATH%-based search for cmd.exe. While this is the standard practice on Windows systems, it presents somewhat risky behavior.

Firstly, %ComSpec% could, in theory, be set maliciously. Unfortunately, there's not much that can be done to prevent this attack surface, because %ComSpec% is the official mechanism for shell specification on Windows. We can, however, validate that it points to an absolute path, which one would expect for a properly set value.

Secondly, a fallback to a relative cmd.exe path, resolved via %PATH%, could be risky. The risk is largely mitigated by changes in Go 1.19 and later, but prior to that a malicious cmd.exe could been resolved in the current working directory. To mitigate this issue, Mutagen now uses the %SystemRoot% environment variable (also validated to be an absolute path) to resolve cmd.exe in the event that %ComSpec% is not set correctly.

Patches

The problem has been patched in Mutagen v0.16.6 and v0.17.1. Earlier versions of Mutagen are no longer supported and will not be patched. Versions of Mutagen after v0.18.0 will also have the patch merged.

Workarounds

Maintain control of the environment variable settings on your system, in particular the ComSpec environment variable.

References

More information on %ComSpec% can be found online.

More information on Go's PATH-based lookup changes can be found here, here, and here.

A similar issue that was addressed within the Python subprocess module also provides additional discussion.

Database specific
{
    "nvd_published_at": null,
    "cwe_ids": [],
    "github_reviewed_at": "2023-05-05T02:18:26Z",
    "severity": "LOW",
    "github_reviewed": true
}
References

Affected packages

Go / github.com/mutagen-io/mutagen

Package

Name
github.com/mutagen-io/mutagen
View open source insights on deps.dev
Purl
pkg:golang/github.com/mutagen-io/mutagen

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
0.16.6

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2023/05/GHSA-fwj4-72fm-c93g/GHSA-fwj4-72fm-c93g.json"

Go / github.com/mutagen-io/mutagen

Package

Name
github.com/mutagen-io/mutagen
View open source insights on deps.dev
Purl
pkg:golang/github.com/mutagen-io/mutagen

Affected ranges

Type
SEMVER
Events
Introduced
0.17.0
Fixed
0.17.1

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2023/05/GHSA-fwj4-72fm-c93g/GHSA-fwj4-72fm-c93g.json"