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

Use unique IDs and internal hashtable to map SCTP associations with usrsctp #2302

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

lminiero
Copy link
Member

This patch aims at addressing a vulnerability that apparently still affects usrsctp, and so you should test this if you use datachannels in your application. You can learn more about the vulnerability (and the workaround we implemented) by reading this thread on Twitter.

Basically, with usrsctp almost everyone (including us, libwebrtc developers, and others) passed our custom structures/classes as opaque pointers when creating associations, as this way usrsctp would provide the same pointer back in callbacks, making it easier to address, e.g., incoming messages and events and relate them to the right instance. Apparently, though, usrsctp is actually putting the address of that pointer in SCTP messages (as part of the cookie), which creates an obvious vulnerability. I was made aware of this issue some time ago, but at the same time the notice said this had been fixed in usrsctp itself about a year ago: since we always recommend installing the latest version, I assumed we were fine, but apparently that's not the case. As such, I'm implementing the same workaround the libwebrtc developers implemented, that is an internal map with unique IDs: we pass these harmless IDs to usrsctp, and then look for the right SCTP instance when we get an ID in one of the callbacks.

While it seems to be working as expected in the few tests I made, you're encouraged to test this more thoroughly yourself, especially if you rely on datachannels in your applications. This new map I added also adds a new mutex, and as such there's always the risk of deadlocks in unexpected circumstances (which should happen, but you never know).

@ibc
Copy link

ibc commented Jul 29, 2020

blablabla but looks ok

@lminiero
Copy link
Member Author

Well, look at it this way: you can just open a PR with no text and say "read here"... I did you a favor!

@ibc
Copy link

ibc commented Jul 29, 2020

Thanks I'll do

@lminiero
Copy link
Member Author

Just warn them that the description might be a bit impolite...

ibc added a commit to versatica/mediasoup that referenced this pull request Jul 29, 2020
ibc added a commit to versatica/mediasoup that referenced this pull request Jul 29, 2020
…ons (#439)

Fix the usrsctp vulnerability by using a global map for SctpAssociations instead of passing this pointer to usrsctp API

- Related commit in libwebrtc: https://webrtc-review.googlesource.com/c/src/+/176422/5/media/sctp/sctp_transport.cc
- Related commit in Janus: meetecho/janus-gateway#2302
@lminiero
Copy link
Member Author

lminiero commented Aug 4, 2020

I don't see any objection, so I'll merge.

@lminiero lminiero merged commit 85a0e1e into master Aug 4, 2020
@lminiero lminiero deleted the sctp-idmap branch August 4, 2020 17:27
@ibc
Copy link

ibc commented Aug 4, 2020

I don't see any objection, so I'll merge.

Actually you don't see anything.

@lminiero
Copy link
Member Author

lminiero commented Aug 5, 2020

Yeah, that was my point. But I can't wait for feedback forever, so merging they HAVE to test.

@chadfurman
Copy link
Contributor

Yeah, that was my point. But I can't wait for feedback forever, so merging they HAVE to test.

Yeah, once we update! :)

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

Successfully merging this pull request may close these issues.

None yet

3 participants