Use connected socket to filter out packets from wrong host - #198
Open
fixthething wants to merge 1 commit into
Open
Use connected socket to filter out packets from wrong host#198fixthething wants to merge 1 commit into
fixthething wants to merge 1 commit into
Conversation
fixthething
force-pushed
the
connected_socket
branch
from
September 12, 2026 00:24
aadd2cc to
0f7f25a
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.
With the previous code, an obscure error could happen, where packets from an entirely different host than the intended connected server would be received by self._sock.recvfrom(), because the unconnected socket would accept a packet from any source address that matched the correct port. This could happen maliciously, but could also happen if the ephemeral source port were reused from a previously closed socket by an entirely different app but a response arrived late.
In a real-world example, I observed an IPMI request error out because the received packet was actually a stray DHCP response, which obviously did not match the expected format for an RMCP response packet.
When using a connected socket (see the added
self._sock.connect()), the OS will filter out packets coming from an incorrect source address or port and only receive a response from the server we are attempting to communicate with.I also updated examples/interface_rmcp.py with connection parameters compatible with ipmi_sim so anybody could run it repeatably without a live server at the 10.x.x.x hardcoded address.