close socket if SSID is not valid

This commit is contained in:
zefie
2024-05-04 12:39:25 -04:00
parent ae93620b7a
commit 95bd52d673
2 changed files with 12 additions and 0 deletions

View File

@@ -1471,6 +1471,11 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
if (!headers) return;
if (headers["wtv-client-serial-number"] != null && socket.ssid == null) {
if (!wtvshared.checkSSID(headers["wtv-client-serial-number"])) {
// close socket for invalid ssid
cleanupSocket(socket)
return;
}
socket.ssid = wtvshared.makeSafeSSID(headers["wtv-client-serial-number"]);
if (socket.ssid != null) {
if (!ssid_sessions[socket.ssid]) {

View File

@@ -69,6 +69,13 @@ class WTVShared {
return crc.toString(16).padStart(2, '0');
}
// check if the SSID has a valid checksum
checkSSID(ssid) {
if (ssid.slice(-2) == this.getSSIDCRC(ssid))
return true;
return false;
}
parseConfigVars(s) {
if (s.indexOf("%ServiceDeps%") >= 0) {