Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP best practices #138

Open
choksi81 opened this issue Jun 2, 2014 · 0 comments
Open

UDP best practices #138

choksi81 opened this issue Jun 2, 2014 · 0 comments
Assignees

Comments

@choksi81
Copy link
Contributor

choksi81 commented Jun 2, 2014

The usual way of receiving UDP traffic on Seattle involves registering a callback (V1) or polling a listening socket for incoming messages (V2). This works fine for remote-initiated traffic (Seattle is the server) when connections from any IP address should be served.

However, there is a subtle issue with implementing a UDP client that receives a response to a query it sent: If you just send the UDP message, then register the callback/poll the socket, it is not guaranteed that the answer you will receive comes from the host you sent the message to! All an attacker needed to do was to flood the known Seattle ports with UDP messages to falsely trigger your callback.

The correct way to implement a UDP client in Seattle thus involves checking inside the callback (V1), or in the (ip, port, message) tuple returned from udpserversocket.getmessage() from an established UDP server socket in V2, whether the received message comes from the host and port that was contacted initially.

(Also, note a possible race: sending-then-registering could result in the callback not being set up before the message arrives. On the other side, registering-then-sending could trigger the callback prematurely because of attack/unsolicited traffic.)

We should (a) come up with correct, comprehensible code examples (e.g. using closures, global variables, etc.), and (b) check whether our platform code needs to be refurbished. I think #1261 shows how unsolicited incoming messages could really harm the system.

@choksi81 choksi81 self-assigned this Jun 2, 2014
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

No branches or pull requests

1 participant