diff options
author | Felix Lange <fjl@twurst.com> | 2019-02-19 18:49:43 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2019-02-19 18:49:43 +0800 |
commit | 26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb (patch) | |
tree | 678a1c33f6e13b46211d27c54605ad0291921c16 /rpc | |
parent | c283d9b5e89685c73ba856ea51e7d6d49b6922a9 (diff) | |
download | go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.tar go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.tar.gz go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.tar.bz2 go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.tar.lz go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.tar.xz go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.tar.zst go-tangerine-26d3a8ca80bf78946eca7ccdc5945c2ffc6ce8fb.zip |
rpc: skip websocket origin check if there is no origin header
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/websocket.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/rpc/websocket.go b/rpc/websocket.go index b8e067a5f..6b986a914 100644 --- a/rpc/websocket.go +++ b/rpc/websocket.go @@ -124,6 +124,13 @@ func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http log.Debug(fmt.Sprintf("Allowed origin(s) for WS RPC interface %v", origins.ToSlice())) f := func(cfg *websocket.Config, req *http.Request) error { + // Skip origin verification if no Origin header is present. The origin check + // is supposed to protect against browser based attacks. Browsers always set + // Origin. Non-browser software can put anything in origin and checking it doesn't + // provide additional security. + if _, ok := req.Header["Origin"]; !ok { + return + } // Verify origin against whitelist. origin := strings.ToLower(req.Header.Get("Origin")) if allowAllOrigins || origins.Contains(origin) { |