STUN response with SOFTWARE attribute causes compatibility issue with FreeSWITCH
Hello,
I'm encountering an issue when using your STUN server with FreeSWITCH.
When the server responds to a Binding Request with a Binding Success Response that includes the SOFTWARE attribute before the XOR-MAPPED-ADDRESS attribute, FreeSWITCH fails to extract the IP and port, even though the packet is RFC 5389-compliant.
Examples
Captured using Wireshark:
Working STUN Response (IP/port extracted successfully)
Message Type: 0x0101 (Binding Success Response)
Message Length: 12
Attributes:
XOR-MAPPED-ADDRESS: x.x.x.x:48755
Problematic STUN Response (Returns success, but IP/port are NULL)
Message Type: 0x0101 (Binding Success Response)
Message Length: 32
Attributes:
SOFTWARE: "P1 STUN library"
XOR-MAPPED-ADDRESS: x.x.x.x:34996
Both messages appear well-formed and are accepted by Wireshark and other parsers.
Questions
- Is the order of attributes in your response configurable?
- Would it be possible to place
XOR-MAPPED-ADDRESSbefore other attributes likeSOFTWARE? - Alternatively, is there a known workaround on the client side for this behavior?
Thanks in advance
The order currently isn't configurable, and an option to do that seems a bit weirdo to me.
I see the following solutions:
- Hard-code a different order, hoping that the new order will be good enough for everyone.
- Allow for omitting the
SOFTWAREattribute altogether. - Do both.
I'm leaning towards (2). The RFC says that
the server SHOULD add a
SOFTWAREattribute to the message.
However, it also says:
Revealing the specific software version of the agent through the
SOFTWAREattribute might allow them to become more vulnerable to attacks against software that is known to contain security holes. Implementers SHOULD make usage of theSOFTWAREattribute a configurable option.
Therefore, such an option might make sense anyway, to allow for some security by obscurity.
I guess that should do the trick for you?
(Regardless of what we do, this sounds like FreeSWITCH might want to fix their client.)
I guess that should do the trick for you?
Yes, I believe it should work. Thank you! I'm still awaiting a response from the FreeSWITCH team.
In case that helps with testing, we've published new Linux binaries/packages here (temporarily):
https://eturnal.net/tmp/HEAD-2025-03-24/
Those would allow for setting software_name: none.
@weiss thank you for the fast fix! However, we are using your official containers and it seems like the "edge" container is still lagging behind. Any plans to update it?
@zinid will look into the container tonight.
@zinid fixed.
It seems like the fix only works only when TURN is enabled. And that is a problem in the "stun" library: it only sets all the options in "prepare_state" when use_turn is true. However, we use eturnal as a STUN server only and enabling TURN is a potential risk for us.
We should find the guy who wrote that library.
(Will have a look later.)
Next try …