The vulnerability is a Denial of Service in Signal K Server, where an unauthenticated attacker can crash the server by flooding the /signalk/v1/access/requests endpoint. This leads to a 'JavaScript heap out of memory' error.
The analysis of the provided patch (commit 55e3574d8266fbc0ed8e453ad4557073541566f5) reveals two key functions that were modified to fix the vulnerability:
-
app.post</signalk/v1/access/requests> in src/serverroutes.ts: This is the entry point for the attack. The original code did not have any rate limiting or payload size checks. An attacker could send an unlimited number of requests, including ones with large bodies, to be processed. The patch introduces express-rate-limit middleware (apiLimiter) to restrict the number of requests from a single IP and adds a check to reject request bodies larger than 10KB.
-
requestAccess in src/tokensecurity.js: This function is called by the route handler to process the access request. The vulnerability lies in its failure to limit the number of pending requests stored in memory. Each request was added to an in-memory object without any bounds. The patch adds a crucial check to limit the number of pending requests to 100. If this limit is reached, new requests are rejected, preventing the server from running out of memory.
During an exploit, a runtime profiler would show a high number of calls to the anonymous route handler in src/serverroutes.ts, which in turn calls the requestAccess function. These two functions are central to the vulnerability, as one provides the open door and the other contains the flawed logic that leads to resource exhaustion.