Skip to content
Sonicjs Issues 1043

Sonicjs Issues 1043

github.com • November 28, 2026

This project is an open-source project, and any user can obtain the hardcoded JWT Secret in this project. At the same time, there is no warning prompt when starting the project with the default JWT Secret value, so most users may not modify this default JWT Secret value. This may allow attackers to forge arbitrary user permission tokens, thereby bypassing authentication and authorization mechanisms and accessing protected interfaces.

sonicjs/packages/core/src/middleware/auth.ts

sonicjs/packages/core/src/middleware/csrf.ts

sonicjs/packages/core/src/routes/auth.ts

Exploitability Analysis:

The project hardcodes the default JWT Secret your-super-secret-jwt-key-change-in-production in multiple source files. When the JWT_SECRET environment variable is not configured, both verifyToken() and generateToken() silently fall back to the hardcoded value through secret || JWT_SECRET_FALLBACK .

Because the default secret is committed to public source code, any user can obtain it. If a deployment does not explicitly configure JWT_SECRET , the production environment may use the public default secret for JWT signing and verification.

The business authentication logic trusts identity and permission fields from the JWT payload. Once the hardcoded secret is known, an attacker can craft arbitrary payloads and generate tokens that pass server-side signature verification.

The payload is not bound to any server-enforced high-entropy random value, server-side session state, token version, revocation list, or blacklist mechanism.

Token Validation Flow

The request token validation flow mainly includes:

The server extracts the JWT from the request;

The token signature is verified using JWT_SECRET or the fallback default secret;

The payload is decoded after signature verification succeeds;

Business logic directly uses identity and permission fields from the payload;

The server does not query the database to verify the user's current role or status;

The server does not validate server-side session state, token revocation state, or non-forgeable fields.

Therefore, this token validation mechanism is stateless or weakly semi-stateful. The server mainly relies on JWT signature validity to determine whether a token is trusted, but the signing key is publicly hardcoded, which breaks the authentication boundary.

After obtaining the hardcoded secret, an attacker can forge JWT tokens with arbitrary identities and permissions. The forged tokens can pass the validation flow and be accepted by business logic for identity recognition, authorization control, and data isolation. This can result in authentication bypass, privilege escalation, and unauthorized access.

Attackers can forge JWTs for arbitrary users

Attackers can impersonate administrators or privileged accounts to access sensitive interfaces

The user identity authentication mechanism fails

This may lead to data leakage, unauthorized operations, or account takeover

The JWT Secret can be placed in the system environment variable, or starting the project with default values can be prohibited.

coderabbitai added area: auth Issue concerns auth bug Something isn't working priority: P1 Urgent: security exposure or core workflow/build blocker; validate and address first security Security vulnerabilities triage: needs-validation Validate report or remaining scope against current release before implementation on Oct 23, 2026

coderabbitai added the Bug issue type on Oct 23, 2026

lane711 closed this as completed on Oct 26, 2026