Skip to content

馃悰 fix(discovery): skip empty PATH entries - #132

Merged
gaborbernat merged 1 commit into
mainfrom
fix-empty-path-cwd
Sep 18, 2026
Merged

gaborbernat merged 1 commit into
mainfrom
fix-empty-path-cwd

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Sep 18, 2026

Copy link
Copy Markdown
Member

get_paths() turned every PATH entry into a Path with no filtering. An empty entry (leading, trailing, or doubled separator) means "current directory" on both POSIX and Windows, so Path("") resolved to it and the caller's cwd got searched for interpreters alongside every real PATH directory.

I confirmed this on a real machine. With PATH=/usr/bin:/bin: and a python3.11-named file planted in an attacker-writable cwd, discovery's own interrogation step executed that file, whether or not it went on to pick it as the result.

filter(None, ...) drops empty entries before they become Path objects.

Tracked as GHSA-f7q5-7cq5-gvgh.

get_paths() turned every PATH entry into a Path via map(Path, ...) with
no filtering. An empty entry - a leading, trailing, or doubled
separator - means "current directory" per POSIX and Windows PATH
semantics, so Path("") resolved to it and the caller's cwd got
searched for interpreters alongside every real directory on PATH.

Confirmed on a real machine: PATH=/usr/bin:/bin: with a
python3.11-named file planted in an attacker-writable cwd got that
file executed during discovery's own interrogation step, independent
of whether it was ultimately selected as the result.

filter(None, ...) drops the empty entries before they become Path
objects.
@gaborbernat gaborbernat added the bug Something isn't working label Sep 18, 2026
@gaborbernat
gaborbernat merged commit 5d64819 into main Sep 18, 2026
19 checks passed
@gaborbernat
gaborbernat deleted the fix-empty-path-cwd branch September 18, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant