Skip to content

Use connected socket to filter out packets from wrong host - #198

Open
fixthething wants to merge 1 commit into
kontron:masterfrom
fixthething:connected_socket
Open

Use connected socket to filter out packets from wrong host#198
fixthething wants to merge 1 commit into
kontron:masterfrom
fixthething:connected_socket

Conversation

@fixthething

Copy link
Copy Markdown

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.

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.

1 participant