Skip to content

fix(packet): drop capabilities permanently#647

Merged
rewolff merged 1 commit into
traviscross:masterfrom
Komzpa:darafei/drop-packet-capabilities
May 25, 2026
Merged

fix(packet): drop capabilities permanently#647
rewolff merged 1 commit into
traviscross:masterfrom
Komzpa:darafei/drop-packet-capabilities

Conversation

@Komzpa

@Komzpa Komzpa commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • drop all mtr-packet process capabilities after privileged socket setup
  • stop keeping CAP_NET_RAW / CAP_NET_ADMIN in the permitted set for later re-enabling
  • call setsockopt() directly for SO_MARK / SO_BINDTODEVICE instead of temporarily raising effective capabilities around those calls
  • add a regression test that rejects future packet-helper code paths that select or re-enable individual capabilities

Why

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-packet already 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

Supersedes #311.

@Komzpa Komzpa force-pushed the darafei/drop-packet-capabilities branch from cb0b5c1 to af2afc4 Compare May 9, 2026 10:33
@Komzpa Komzpa force-pushed the darafei/drop-packet-capabilities branch from af2afc4 to 8b8a3d1 Compare May 9, 2026 11:12
@rewolff rewolff merged commit 0d9bca1 into traviscross:master May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants