Repository navigation
sptp: only answer bare DELAY_REQ probes in ptping - #600
Support-itecz wants to merge 1 commit into
Conversation
A datagram on port 319 from a host the client does not sync to falls through to ptping, which answered it without checking the message type or the OriginTimestamp. It answered SYNCs and the stamped DELAY_REQ that handleDelayReq sends, so two sptp clients that are not each other's servers, or an sptp client and a ptp4u it does not use, keep answering each other once a single spoofed DELAY_REQ starts them. The listener also handed ptping the whole receive buffer instead of buf[:bbuf], so a 1-octet datagram was parsed against stale bytes and answered. Answer only a DELAY_REQ with an empty OriginTimestamp, the same test collectReply uses to tell a reply from a probe, and parse only the datagram.
|
Hi @Support-itecz! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Unless you sign CLA we can't review this |
Summary
When sptp gets a datagram on port 319 from a host it doesn't sync to, it falls through to
ptpingand answers with a stamped DELAY_REQ plus an ANNOUNCE.ptpinganswered more than ptping probes:handleDelayReqitself sends. Two sptp clients that are not each other's servers keep answering each other once one spoofed DELAY_REQ (source set to the other client) starts the exchange. The same happens between an sptp client and a ptp4u it is not configured for, because ptp4u answers an sptp DELAY_REQ with a SYNC.RunListenerpassed the whole receive buffer instead ofbuf[:bbuf], so the length checks inFromBytesnever saw the datagram size. A single0x01octet was parsed against the stale or zeroed rest of the buffer and answered with two packets.This is a UDP application-layer loop (the CVE-2024-2169 "Loop DoS" class). One unauthenticated, spoofed packet starts traffic that never stops, and every loop runs inline in the event-port listener goroutine that also handles SYNCs from the configured GMs. A host that can send spoofed UDP to port 319 of two sptp clients can start as many loops as it likes.
ptpingnow answers only a bare DELAY_REQ (type DELAY_REQ, empty OriginTimestamp). That is the same testcollectReplyalready uses to tell a reply from a probe ("a DELAY_REQ carrying a stamped OriginTimestamp, which a genuine inbound request never has"). The requester in the tree,pingUnicastbehindptpcheck ptping, sendsReqDelaywith an empty OriginTimestamp, so real probes are still answered. The listener now passesbuf[:bbuf].TestPTPingused a zero header (a SYNC) as its valid probe. It now sendsReqDelay, which is what a ptping probe looks like on the wire.Test Plan
Two new regression tests in
ptp/sptp/client/sptp_test.go:TestPtpingIgnoresRepliesanswers a real probe, then feeds the captured reply and a stamped SYNC back intoptping. Neither may be answered.TestRunListenerPtpingShortDatagramsends a 1-octet datagram from an unknown host throughRunListener. Nothing may be written.Without the change to
sptp.go:With it, on Linux with Go 1.26 (the package doesn't build on macOS, see #593):
Loop reproducer (not committed): two
SPTPinstances joined by an in-memory UDP network, neither configured as the other's server, with one DELAY_REQ injected into A as if it came from B. The in-memory network has no latency, so the rate is an upper bound. On real hosts it is limited by RTT and TX timestamping, but it still never stops.before after
packets in 200ms after one spoofed DELAY_REQ 5681 2
packets sent in reply to a 1-byte datagram 2 0
packets sent in reply to a SYNC from an unconfigured GM 2 0