The vulnerability is an authentication bypass in FUXA, enabling an unauthenticated remote attacker to gain administrative access. The root cause is the combination of two main flaws. First, the /api/heartbeat endpoint, configured in the init function in server/api/index.js, allowed for token renewal requests without first checking if the user was authenticated. Second, the getNewToken function in server/api/jwt-helper.js, which was called by the heartbeat endpoint, insecurely created a new JSON Web Token (JWT) based on the unvalidated x-auth-user header sent by the client.
An attacker could exploit this by sending a POST request to /api/heartbeat with a crafted x-auth-user header (e.g., {"user":"admin","groups":["admin"]}). The verifyToken middleware would fail to authenticate the request but would allow it to proceed. The heartbeat handler would then call getNewToken, which would mint a new JWT with administrative privileges based on the attacker-controlled header. This grants the attacker full administrative access, leading to potential remote code execution.
The patch addresses these issues by:
- Modifying the
verifyToken middleware to explicitly set an isAuthenticated flag on the request.
- Adding a check in the
/api/heartbeat handler to ensure req.isAuthenticated is true before attempting to refresh a token.
- Replacing the insecure
getNewToken function with getNewTokenFromRequest, which creates a token based on the trusted, server-side user identity established during authentication, rather than a client-controlled header.