Repository navigation
Apply the command name check to external lookups - #24483
Conversation
- `brew.sh` rejects command names containing `/`, `.` or `..` but `brew help <name>` reaches `Commands.path` without that check, so `brew help ../../x` could run an executable outside the command directories. Signed-off-by: Patrick Linnane <patrick@linnane.io>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
brew.shrejects command names containing/,.or..butbrew help <name>reachesCommands.pathwithout that check, andwhichbuilds its candidates withFile.expand_path, sobrew help ../../xcould resolve and run an executable outside the command directories. Before this changeprintf '#!/bin/sh\necho ran\n' > /tmp/x/brew-poc && chmod +x /tmp/x/brew-poc && brew help ../../../../../../../tmp/x/brew-pocprintsran.The same check now guards the external command lookups so every caller of
Commands.pathrejects such names, andinternal_cmd_name?becomesvalid_cmd_name?since it no longer applies only to internal commands.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Mythos 5.1) found the gap while triaging a report, wrote the change and test, checked that the new example fails without the change, ran
brew lgtmand checkedbrew helpandbrewagainst internal, external and path-like command names before and after the change.