-
Notifications
You must be signed in to change notification settings - Fork 788
Harden Linux manager executable lookup to prevent PATH hijacking #4621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,8 +51,8 @@ public Pacman() | |
|
|
||
| public override IReadOnlyList<string> FindCandidateExecutableFiles() | ||
| { | ||
| var candidates = new List<string>(CoreTools.WhichMultiple("pacman")); | ||
| foreach (var path in new[] { "/usr/bin/pacman", "/usr/local/bin/pacman" }) | ||
| var candidates = new List<string>(); | ||
| foreach (var path in new[] { "/usr/bin/pacman", "/bin/pacman" }) | ||
| { | ||
| if (File.Exists(path) && !candidates.Contains(path)) | ||
| candidates.Add(path); | ||
|
Comment on lines
+54
to
58
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Candidate discovery only checks File.Exists; it will treat non-executable files (missing +x) as valid candidates and may mark the manager as found, then later fail to launch with a permission error. Consider additionally verifying executability (e.g., via Unix execute bits) or reusing CoreTools.WhichMultiple/Which on the absolute paths to leverage its executable-checking logic without searching PATH.