Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
disable "null" cors origin
This is impossible to secure properly and Tor users can report origin
by setting network.http.referer.hideOnionSource to false

Thanks Kamil Vavra for the report!
  • Loading branch information
prusnak committed Nov 4, 2020
1 parent a29dfe1 commit ddead55
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 12 deletions.
6 changes: 0 additions & 6 deletions server/api/api.go
Expand Up @@ -254,12 +254,6 @@ func corsValidator() (OriginValidator, error) {
}

v := func(origin string) bool {
// * Electron
// * Tor Browser when `network.http.referer.hideOnionSource` is set to `true` (default)
if origin == "null" {
return true
}

if trezorRegex.MatchString(origin) {
return true
}
Expand Down
2 changes: 0 additions & 2 deletions server/api/api_test.go
Expand Up @@ -10,8 +10,6 @@ func TestOriginValidator(t *testing.T) {
origin string
allow bool
}{
// `null` should be allowed
{"null", true},
// HTTPS for trezor.io should be allowed
{"https://trezor.io", true},
{"https://foo.trezor.io", true},
Expand Down
4 changes: 0 additions & 4 deletions server/api/cors.go
Expand Up @@ -61,10 +61,6 @@ func (ch *cors) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}

if origin == "null" {
origin = "*"
}

w.Header().Set(corsAllowOriginHeader, origin)

if r.Method == corsOptionMethod {
Expand Down

0 comments on commit ddead55

Please sign in to comment.