You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TURN server should return 420 (Unknown attribute) when it sees unexpected attribute #76
I noticed that when a request contained Requested-Transport attribute in CreatePermission, RefreshRequest or ChannelBind request, the TURN server never complains it and handles it as if it was no there.
The coturn however, returns 420 (Unknown Attribute) in the above cases.
Our TURN client is being tested with its own TURN server, it would be great to generate errors when the server sees unexpected situations.
Handling of attributes is defined in RFC 8489 like so
If the request contains one or more unknown comprehension-required
attributes, the server replies with an error response with an error
code of 420 (Unknown Attribute) and includes an UNKNOWN-ATTRIBUTES
attribute in the response that lists the unknown comprehension-
required attributes.
The following logic is already available in pion/stun.
To allow future revisions of this specification to add new attributes
if needed, the attribute space is divided into two ranges.
Attributes with type values between 0x0000 and 0x7FFF are
comprehension-required attributes, which means that the STUN agent
cannot successfully process the message unless it understands the
attribute. Attributes with type values between 0x8000 and 0xFFFF are
comprehension-optional attributes, which means that those attributes
can be ignored by the STUN agent if it does not understand them.
So we need to process/handle STUN packets in our Client+Server and if we get an attribute we don't understand return a 420
As per handling unknown attributes, I agree with @Sean-Der: we should reject unknown comprehension-required attributes with an error code of 420 (Unknown Attribute) and include an UNKNOWN-ATTRIBUTES attribute in the response, and we should silently ignore the rest.
As per implementing this in pion/stun: it seems all machinery is in-place, we even have func (AttrType) Required() and func (AttrType) Optional() implemented, and we have const AttrUnknownAttributes AttrType = 0x000A defined. What's missing is the actual implementation of the correct attribute handling logic. What's the most pion-y way to make this work? Should we manually inject the unknown attribute logic at each call site where we deal with message parsing? Or should we inject this into func (m *Message) Parse(getters ...Getter) error and move from per-attribute parsing in pion/stun and pion/turn to calling message.Parse first? Or should we automate this in some other way?
Activity
Sean-Der commentedon Dec 3, 2025
Handling of attributes is defined in RFC 8489 like so
The following logic is already available in pion/stun.
So we need to process/handle STUN packets in our Client+Server and if we get an attribute we don't understand return a 420
rg0now commentedon Dec 3, 2025
As per handling unknown attributes, I agree with @Sean-Der: we should reject unknown comprehension-required attributes with an error code of 420 (Unknown Attribute) and include an
UNKNOWN-ATTRIBUTESattribute in the response, and we should silently ignore the rest.As per implementing this in pion/stun: it seems all machinery is in-place, we even have
func (AttrType) Required()andfunc (AttrType) Optional()implemented, and we haveconst AttrUnknownAttributes AttrType = 0x000Adefined. What's missing is the actual implementation of the correct attribute handling logic. What's the most pion-y way to make this work? Should we manually inject the unknown attribute logic at each call site where we deal with message parsing? Or should we inject this intofunc (m *Message) Parse(getters ...Getter) errorand move from per-attribute parsing in pion/stun and pion/turn to callingmessage.Parsefirst? Or should we automate this in some other way?Add AttrType.Valid method
Add AttrType.Known method
Add AttrType.Known method
Add AttrType.Known method
Add Unknown Attribute Handler
Add Unknown Attribute Handler
Add Unknown Attribute Handler
Add Unknown Attribute Handler