Repository navigation
Match versioned interpreter names, and record denied macOS execs - #84
Merged
Merged
Conversation
Under `agentmon wrap`, Homebrew's python3 exited 255, and no event said why (SECENG-311). ES reports the resolved executable, and /opt/homebrew/bin/python3 resolves to .../bin/python3.15. agent-default names python3, so the exec fell through to default-deny-commands. The command matcher now also tries the basename without a trailing version suffix such as ".15", after the existing ".real" form. Both match loops in the engine had their own copy of this logic, and only one stripped ".real". They now share compiledCommandRule.matchesCommand. The extension now sends an execve event when the daemon denies an exec, as the Linux execve handler does. The process access and wrap reuse test scripts run plain python3 again. scripts/test-macos-wrap-python.sh failed 3 of 3 on build 1677 and passes 3 of 3 on build 1678. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Under
agentmon wrap, Homebrew's python3 exited 255 before it ran any code, and no event said why (SECENG-311).ES reports the resolved executable.
/opt/homebrew/bin/python3resolves to/opt/homebrew/Cellar/python@3.15/3.15.0/bin/python3.15.agent-defaultnamespython3, so the engine deniedpython3.15withdefault-deny-commands. The extension denied the exec and recorded nothing.The fix
compiledCommandRule.matchesCommandchecks the basename as it is, then without.real, then without a trailing version suffix such as.15.python3.15matches a rule forpython3, andperl5.34matches a rule forperl5. A deny rule matches the versioned name too.matchCommandRulesandcheckExecveeach had their own copy of the match logic, and only the first stripped.real. Both now callmatchesCommand.execveevent withargv,parent_pid, the rule and the message when the daemon denies an exec. This follows the Linux execve handler.test-macos-process-access.shandtest-macos-wrap-session-reuse.shrun plain python3 again, instead of thePython.appbinary.Risk
The version suffix adds no new way past a rule. A process can already pass any basename check, because it can name a binary
python3. Only.<digits>parts are stripped, and the part that stays must hold a letter.Verification
scripts/test-macos-wrap-python.shfailed 3 of 3 on build 1677 and passes 3 of 3 on build 1678. It runs python3 underwrap, and expects a denied/usr/bin/bannerand itsexecveevent.test-macos-wrap-session-reuse.shpasses 4 of 4 with plain python3,test-macos-socket-signal-rules.shprints 13 ok, andtest-macos-network-proxy.shpasses 6 of 6.TestStripVersionSuffix,TestCommandNameFormsandTestVersionedInterpreterMatchesRule.go test -tags nofuse ./...passes, andgolangci-lintreports 0 issues.test-macos-process-access.shneeds sudo, and it has not run with plain python3 yet.Fixes SECENG-311.
🤖 Generated with Claude Code