backend/gateway: enforce d field to be a single numeric 0 for ping payloads

This commit is contained in:
hippoz 2022-04-14 21:32:52 +03:00
parent 538717cfc9
commit bf5e4f554e
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -216,7 +216,11 @@ export default function(server: Server) {
break;
}
case GatewayPayloadType.Ping: {
// TODO: also check session here and ensure packet is sent at the right time
if (payload.d !== 0) {
return closeWithBadPayload(ws, "d: expected numeric '0'");
}
// TODO: also check session here
ws.state.alive = true;
break;
}