The vulnerability is an improper certificate validation issue in the 1Panel agent, which allows an attacker to bypass authentication and execute arbitrary commands. The root cause is in the server.Start function, where the TLS server was configured with tls.RequireAnyClientCert. This setting only requires a client to present a certificate but doesn't validate it against a trusted Certificate Authority (CA), allowing an attacker to use a self-signed certificate.
This initial TLS-level weakness was compounded by a flawed application-level check in the middleware.Certificate function. This middleware only checked if the certificate's Common Name (CN) was panel_client, a condition that is trivial for an attacker to satisfy in a self-signed certificate. Once the weak authentication is bypassed, the attacker gains access to sensitive API endpoints, including WebSocket interfaces for terminal access (/hosts/terminal, /containers/terminal), leading to remote code execution.
The patch addresses the vulnerability comprehensively. First, it changes the TLS client authentication policy in server.Start to tls.RequireAndVerifyClientCert, which enforces strict validation against a trusted CA. Second, it removes the weak CN check from the middleware.Certificate function. The combination of these changes ensures that only clients with valid, trusted certificates can communicate with the agent.