Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Send hostname option to webtorrent to mitigate DNS rebinding #13844

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions js/webtorrent/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const store = {
errorMessage: null
}

// Hostname of the webtorrent server
const webtorrentServerHostname = 'localhost'

let client, server

init()
Expand Down Expand Up @@ -135,7 +138,9 @@ function initTorrent (torrent) {
server = torrent.createServer({
// Only allow requests from this origin ('chrome-extension://...) so websites
// cannot violate same-origin policy by reading contents of active torrents.
origin: window.location.origin
origin: window.location.origin,
// Use hostname option to mitigate DNS rebinding (#12616)
hostname: webtorrentServerHostname
})
server.listen(onServerListening)

Expand All @@ -148,7 +153,7 @@ function initTorrent (torrent) {
}

function onServerListening () {
store.serverUrl = 'http://localhost:' + server.address().port
store.serverUrl = `http://${webtorrentServerHostname}:${server.address().port}`
update()
}

Expand Down