fix(packet): allow privileged local ports - #611
Conversation
1d8ec96 to
42c8504
Compare
|
Not entirely sure what you want to do. My reasoning is that it should not be possible to leverage the elevated privileges that MTR requires to open raw sockets to obtain privileged ports. So for this to be accepted you need to convince me that this is the case. Just outright refusing to use privileged ports is IMHO safe and reduces functionality only a very little bit. (the "rsh" protocol relies on a privileged source port. And this is no longer used. What are the chances that a port specific routing issue needs to be diagnosed going forward?) |
63b8cfe to
ba6701d
Compare
|
Thanks, that concern makes sense. This PR came from #421 rather than from a strong preference of mine. The intended behavior is only: if an operator explicitly asks for The safety boundary I was relying on is the OS bind permission itself: with only the usual raw-socket capability, binding low UDP source ports still fails; it only succeeds when mtr-packet also runs as root or has That said, I do not have a strong stake in changing this policy. If you prefer the existing conservative behavior, rejecting this PR is fine. If #421's use case is worth supporting, this PR is also ready to merge. It is independent of the other packet/port changes; either direction can be accepted or rejected separately. |
005c567 to
44f2a93
Compare
44f2a93 to
401d569
Compare
401d569 to
9b4ffa9
Compare
9b4ffa9 to
a76de3a
Compare
|
If we were to allow this, mtr would have to be audited that people don't use mtr to elevate privileges or "mess up the network" (denial of service) by sending "bad" packets onto the network. People will have to find their own solution if they find it necessary to use a privileged port. |
Fixes #421.
Stacked on #647.
Summary
--localportvalues in the full UDP port range1..65535instead of rejecting ports below 1024 in the UI andmtr-packetparserpacket/ports.hso UI validation, packet parsing, source-port rotation, and permission checks use the same definitionsbind()preflight after capability droppingSecurity note
This branch no longer keeps or re-enables
CAP_NET_BIND_SERVICEafter startup. With #647 below it,mtr-packetdrops all capabilities permanently after privileged socket setup.Raw UDP packet construction can otherwise place a privileged source port directly in the UDP header. To avoid bypassing the kernel's local-port policy, this branch performs a real UDP
bind()check for explicit low local ports on the raw-socket path. A low local port therefore succeeds only if the OS allows the bind without later capability re-enabling; otherwise it fails cleanly withpermission-denied.Validation
./bootstrap.sh && ./configure --without-gtk --without-jansson && make -j$(nproc)git diff --checkmake check TESTS='test/capability-drop.py'sudo python3 ./test/cmdparse.pysudo python3 ./test/probe.py TestProbeUDP./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 stack