fix(packet): drop capabilities permanently#647
Merged
rewolff merged 1 commit intoMay 25, 2026
Conversation
This was referenced May 9, 2026
cb0b5c1 to
af2afc4
Compare
af2afc4 to
8b8a3d1
Compare
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.
Summary
mtr-packetprocess capabilities after privileged socket setupCAP_NET_RAW/CAP_NET_ADMINin the permitted set for later re-enablingsetsockopt()directly forSO_MARK/SO_BINDTODEVICEinstead of temporarily raising effective capabilities around those callsWhy
This follows the security model discussed in #311, especially the concern in #311 (comment): if packet-handling code can later re-enable a capability from the permitted set, then the privilege was not really dropped for exploit-mitigation purposes.
mtr-packetalready opens its raw sockets before dropping elevated permissions. After that point, later command handling should not be able to regain capabilities. Options that need privileges later will now fail normally if the process no longer has them, rather than silently re-enabling them.This is intentionally not a cherry-pick of #311: that PR moved toward permitted-but-not-effective capabilities. This PR takes the stricter direction requested in the review discussion.
Stack note
#611 has been rebased on top of this PR so low local-port validation and error reporting compose with permanent capability dropping. The combined behavior does not re-enable
CAP_NET_BIND_SERVICE: low privileged ports either succeed because the OS permits the bind without restored capabilities, or fail with a focused permission error.Validation
./bootstrap.sh && ./configure --without-gtk --without-jansson && make -j$(nproc)git diff --checkmake check TESTS='test/capability-drop.py'sudo python3 ./test/cmdparse.py./mtr -r -c 1 127.0.0.1./bootstrap.sh && ./configure --without-gtk --without-jansson && make -j$(nproc)on that composite stackgit diff --checkon that composite stackmake check TESTS='test/capability-drop.py test/dist-version.sh format-count-test'on that composite stacksudo python3 ./test/cmdparse.pyon that composite stacksudo python3 ./test/probe.py TestProbeUDPon that composite stackSupersedes #311.