SIPSorcery, the C# WebRTC and SIP library published on NuGet, parses the Data Channel Establishment Protocol (DCEP) OPEN message in src/SIPSorcery/net/WebRTC/DCEP.cs. The parser checks that the buffer holds the 12 fixed bytes of the message header, then reads labelLength and protocolLength and passes them straight to Encoding.UTF8.GetString. Neither field is validated against the actual buffer length, so a 12-byte OPEN message that declares a 65,535-byte label raises ArgumentException and the data channel silently fails to open.
The private report reached the maintainers, who filed it in the public tracker as issue #1778 on 2026-08-14 and closed it. No CVE or GHSA followed. A second defect sits in the same function: the parser ignores posn for the two variable-length reads.
01Background: DCEP runs before the data channel exists
WebRTC data channels are carried over SCTP, but the channel itself has to be negotiated in-band first. DCEP, defined in RFC 8832, is that negotiation: OPEN, ACK and the closing messages travel as SCTP user data on stream 0 with PPID 50 (WebRTC_DCEP), and the OPEN message carries the channel type, priority, reliability parameters, a text label and an optional protocol string.
In SIPSorcery the OPEN message is decoded by DataChannelOpenMessage.Parse(byte[] buffer, int posn). This is the first code that touches peer-supplied bytes on the data-channel path, and it runs inside the SCTP receive loop, before any application-level handler or channel object exists. A throw here does not fail a callback; it aborts the delivery of the packet that carried the OPEN.
02Root cause: a 12-byte length check followed by unbounded reads
The function's only guard verifies that the buffer contains the fixed parameters, a constant named DCEP_OPEN_FIXED_PARAMETERS_LENGTH equal to 12 bytes:
if (buffer.Length < DCEP_OPEN_FIXED_PARAMETERS_LENGTH)
{
throw new ApplicationException("The buffer did not contain the minimum number of bytes for a DCEP open message.");
}
The two length fields live at offsets 8 and 10 of that header. They are read as unsigned 16-bit values and used immediately, with no comparison against buffer.Length:
ushort labelLength = NetConvert.ParseUInt16(buffer, posn + 8);
ushort protocolLength = NetConvert.ParseUInt16(buffer, posn + 10);
if (labelLength > 0)
{
dcepOpen.Label = Encoding.UTF8.GetString(buffer, 12, labelLength);
}
if (protocolLength > 0)
{
dcepOpen.Protocol = Encoding.UTF8.GetString(buffer, 12 + labelLength, protocolLength);
}
SCTP validates chunk-level bounds: a DATA chunk cannot claim to be longer than the packet that carries it. It knows nothing about DCEP's internal layout, so an internally inconsistent payload passes. Twelve bytes is a valid SCTP chunk payload and an invalid DCEP OPEN message at the same time.
Second defect: posn is ignored for the variable-length fields
The label and protocol reads hardcode offset 12 instead of posn + 12. Every caller in the tree currently passes posn = 0, so this is latent rather than live, but the function is incorrect as written and would misparse the moment a caller passes a non-zero offset. A fix that only adds a bounds check would leave this in place.
03Proof of concept: 12 bytes that declare a 65535-byte label
Any peer that has finished the DTLS handshake can send this. It needs one SCTP DATA chunk on stream 0 with PPID 50, and its user data is exactly these 12 bytes:
| Offset | Value | Field |
|---|---|---|
| 0 | 0x03 | Message type (OPEN) |
| 1 | 0x00 | Channel type (reliable) |
| 2-3 | 0x0000 | Priority |
| 4-7 | 0x00000000 | Reliability |
| 8-9 | 0xFFFF | Label length = 65535 |
| 10-11 | 0x0000 | Protocol length |
The header passes the only check in the function. GetString(buffer, 12, 65535) is then called on a buffer whose length is 12. Encoding.UTF8.GetString validates its arguments before touching memory and throws ArgumentException, which is the reported behaviour. The same throw can be produced with a label and protocol pair that individually fit but overflow when summed, for example a 12-byte buffer declaring a label of 10 and a protocol of 10: the second read starts at offset 22 on a 12-byte array.
04Impact and severity: a failed OPEN, not memory corruption
The exception propagates out of the parser to the defence-in-depth handler in RTCSctpTransport.DoReceive, which logs it and drops the packet. The observable effects are narrow:
- The OPEN is discarded and no data channel is created.
- The receive thread survives and the SCTP association stays up.
- Any remaining frames in the same
sortedFramesbatch inSctpAssociation.OnPacketReceivedare lost, because the throw exits the delivery loop after the SACK has already been sent and the frames have been dequeued from the receiver.
This page rates the defect Low. The worst outcome stays inside the sender's own session: a channel that does not open, plus frames dropped from one batched delivery. GetString throws before reading, so nothing past the end of the buffer is disclosed. No memory corruption, no cross-session effect, no impact on another peer.
The maintainers argue it does not meet the bar for a vulnerability at all. Reaching the parser requires a completed DTLS handshake, which in WebRTC means being the peer authenticated against the fingerprint in the signalled SDP. The whole effect is that the sender's own channel does not open, the same result as never sending the OPEN. They also point out that the receive thread and association survive, so it is not a denial of service. The Low rating follows that reading: a genuine parser defect with sender-only, availability-only impact, which the maintainers declined to treat as an advisory. Moderate would imply harm to another party, and the code does not support that.
Disclosure status. Filed as a normal bug, not a security advisory. No CVE and no GHSA. The issue is closed.
05Affected versions
| Package | Affected | Patched |
|---|---|---|
SIPSorcery (NuGet) | All releases up to the report date | No fixed version named in the issue |
The issue does not name a fix commit, a pull request or a release that carries the corrected parser, so no patched version can be stated here. Deployments that accept data channels from untrusted peers should check the current NuGet release notes for a fix before assuming one exists; the vulnerable shape is the presence of Encoding.UTF8.GetString(buffer, 12, labelLength) without a preceding bounds comparison in DataChannelOpenMessage.Parse.
06Remediation: validate the declared lengths, then fix the offset
- Check both fields against the buffer. Reject the message with
ApplicationExceptionwhenlabelLength, or12 + labelLength + protocolLength, exceeds what the buffer actually holds.ApplicationExceptionmatches how the rest of the parser reports malformed input, so callers keep one error contract. - Use
posn + 12for the variable-length reads. The hardcoded12is wrong for any non-zero offset and should be corrected in the same change. - Test the edges. A unit test should cover the
0xFFFFlabel length on a 12-byte buffer and a label/protocol pair that fits individually but overflows when summed.
Until a fixed build is available, the exposure is limited to peers that have already completed DTLS and are authenticated against the signalled fingerprint, which is the normal trust boundary for a WebRTC association. Applications that accept data-channel connections from semi-trusted peers can treat a failed OPEN as expected and retry or close the association, but that only hides the symptom; the parser still needs the check.