The vulnerability exists because the application fails to enforce a minimum length on the JWT signing secret, allowing for weak secrets (less than 32 bytes for HS256) that are vulnerable to offline brute-force attacks. The analysis of the patch and source code identified a two-stage issue.
First, during application startup, the configuration is loaded. The function config.Base64Decoded.UnmarshalText decodes the JWT_SECRET from the environment but does not validate its length. This is orchestrated by config.AppConfig.ParseConfig, which, prior to the patch, lacked the logic to reject secrets shorter than 32 bytes.
Second, the weak secret is then used in core authentication routines. core.CreateAuthenticationToken uses the secret to sign new JWTs, and core.ParseAuthenticationToken uses it to verify incoming tokens. An attacker can capture a token created by the server, crack the weak secret offline, and then forge a new token for any user. The core.ParseAuthenticationToken function would then validate this forged token as legitimate, leading to a full account takeover.
The patch addresses the root cause by adding a validate:"gte=32" struct tag to the JWTSecret field in backend/config/config.go, which is enforced by the ParseConfig function. This ensures the application will not start with a weak secret.