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

Stun Packet Magic Cookie Must Be 0x2112A442 #19

Open
LuoZijun opened this issue Nov 30, 2016 · 1 comment
Open

Stun Packet Magic Cookie Must Be 0x2112A442 #19

LuoZijun opened this issue Nov 30, 2016 · 1 comment

Comments

@LuoZijun
Copy link

Stun Packet Magic Cookie Must Be 0x2112A442.

@robertsdotpm
Copy link

I've been using a fork of this code for years and only just now discovered this huge issue. I am face palming hard. It means that the vast majority of servers aren't going to respond to the stun request because the request will be malformed. Yet here is your issue right here. Posted 8 years ago... You were definitely right. The fact that anyone has success with this library is actually a bug according to the standard. I only learned this by chasing packet logs. It seems the upstream library that forks this (pystun3) has no issues enabled but this is a good place to collect them. I think this is the biggest issue and very easily fixed:

My fix was to set transaction ID to 12 bytes (so its the expected size for the payload) and then prepend the magic cookie hex string where the payload is built. My fix looks like this:

str_data = ''.join([BindRequestMsg, str_len, "2112A442", tran_info_hex, extra_data])
...

I'm not bothering with a pull here because the project isn't maintained and the networking code here is very basic.

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

2 participants