Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd hostname option to mitigate DNS rebinding #1260
Conversation
This adds the `hostname` opt to allow the server to validate the `Host` header of incoming requests to prevent DNS rebinding attacks. Needed for brave/browser-laptop#12616.
This comment has been minimized.
This comment has been minimized.
|
lazy manual test:
|
This comment has been minimized.
This comment has been minimized.
|
credit goes to @taviso for finding and posting transmission/transmission#468 |
This comment has been minimized.
This comment has been minimized.
|
@feross any thoughts on this approach? |
| // header that does not match the origin of the torrent server to prevent | ||
| // DNS rebinding attacks. | ||
| if (opts.hostname) { | ||
| if (req.headers.host !== `${opts.hostname}:${server.address().port}`) { |
This comment has been minimized.
This comment has been minimized.
feross
Jan 18, 2018
Member
What would Brave set the hostname option to? If it would be set to chrome-extension://xxx, then I fear this won't work since it's going to append the torrent server's port to that and reject anything that doesn't match that.
I think we can remove the code that adds the port. Correct me if I'm wrong.
This comment has been minimized.
This comment has been minimized.
diracdeltas
Jan 18, 2018
Author
Contributor
@feross actually it would set it to localhost. The expected host is localhost:$RANDOM_PORT, as assigned in https://github.com/dcposch/webtorrent-remote/blob/3e99afb9a58787afb68f780da0a8f3174aa6cf0e/server.js#L203
note that the Host header is the origin of the server that the client is trying to contact
|
I think we can safely merge this option with Brave's goal is to ensure that content is only served to
How does this sound? |
This comment has been minimized.
This comment has been minimized.
|
One last thought -- the
(Same origin requests are always allowed, with all the options above) Given the presence of DNS rebinding, it doesn't make sense to offer the third option, since cross-origin requests are effectively allowed, even when that option is set. ProposalLet's remove the special handling when the If we merge the
When
|
This comment has been minimized.
This comment has been minimized.
|
@feross It actually can't be merged with
So in the case of Brave, we would set the origin param to |
This comment has been minimized.
This comment has been minimized.
|
Sorry – I lost track of this PR. Merged and released as 0.98.24. |
diracdeltas commentedJan 12, 2018
•
edited
This adds the
hostnameoption to allow the server to validate theHostheader of incoming requests to prevent DNS rebinding attacks. Needed for brave/browser-laptop#12616.For more context, see https://bugs.chromium.org/p/project-zero/issues/detail?id=1447.