The vulnerability lies in the server/integrations/node-red/index.js file, specifically within the mountNodeRedIfInstalled function. This function defines and applies a middleware named allowDashboard. The original implementation of allowDashboard contained a critical flaw: it explicitly bypassed authentication for the /nodered/flows endpoint. This allowed an unauthenticated attacker to send a specially crafted request to this endpoint to deploy a malicious Node-RED flow, leading to remote code execution.
The patch addresses this by completely rewriting the allowDashboard middleware to enforce authentication. The new implementation checks for a valid JWT token or an API key before allowing access to sensitive endpoints like /nodered/flows. The vulnerable code, which unconditionally called next() for the /nodered/flows URL, was removed.
Therefore, the primary vulnerable function is the allowDashboard middleware. Since this function is defined within mountNodeRedIfInstalled, this parent function is also identified as a key location for the vulnerability. A runtime profiler would likely show allowDashboard in the stack trace when the vulnerable endpoint is accessed.