detect fake origin headers
This commit is contained in:
@@ -109,14 +109,22 @@ export default class WSServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to parse the Origin header sent by the client, if it fails, kill the connection.
|
// Try to parse the Origin header sent by the client, if it fails, kill the connection.
|
||||||
|
var _uri;
|
||||||
var _host;
|
var _host;
|
||||||
try {
|
try {
|
||||||
_host = new URL(req.headers.origin.toLowerCase()).hostname;
|
_uri = new URL(req.headers.origin.toLowerCase());
|
||||||
|
_host = _uri.host;
|
||||||
} catch {
|
} catch {
|
||||||
killConnection();
|
killConnection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// detect fake origin headers
|
||||||
|
if (_uri.pathname !== "/" || _uri.search !== "") {
|
||||||
|
killConnection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the domain name is not in the list of allowed origins, kill the connection.
|
// If the domain name is not in the list of allowed origins, kill the connection.
|
||||||
if(!this.Config.http.originAllowedDomains.includes(_host)) {
|
if(!this.Config.http.originAllowedDomains.includes(_host)) {
|
||||||
killConnection();
|
killConnection();
|
||||||
|
|||||||
Reference in New Issue
Block a user