Summary
clawvet's self-hosted API server uses a hard-coded fallback JWT secret, allowing attackers who know this value to forge HS256 session cookies.
Because scan records expose userId without authentication, a remote attacker can mint valid cg_session tokens and query the authenticated profile endpoint to retrieve a victim's email, subscription plan, and secret apiKey.
Affected context
This vulnerability affects self-hosted deployments of the clawvet apps/api server that:
- Use the default or hard-coded JWT secret defined in
auth.tsand.env.example - Expose
GET /api/v1/scanswithout authentication, returning userId fields for stored scan records - Rely on HS256 cg_session cookies for user authentication on endpoints such as
GET /api/v1/auth/me
In such setups, an attacker on the public internet can interact with the API and exploit predictable secrets and permissive unauthenticated data exposure.
Exploit preconditions
- Attack surface: Public HTTP interface of the self-hosted clawvet API (
apps/api) - Required access: Remote, unauthenticated access to
GET /api/v1/scansandGET /api/v1/auth/me - Trigger point: Use of a known, hard-coded HS256 JWT secret to sign a cg_session cookie for a harvested userId
- Why exploitation is possible: The server accepts tokens signed with a predictable secret, and exposes user identifiers without authentication, enabling offline forgery of valid session tokens.
Why this happens
The core issue is reliance on a static, hard-coded JWT signing key that is distributed in source code and example environment files.
This aligns with CWE-321: Use of Hard-coded Cryptographic Key, where secret material is embedded in the application and becomes predictable to attackers.
Combined with CWE-306: Missing Authentication for Critical Function, the unauthenticated scan listing reveals userId values, which are then used as token claims.
Abstractly, the design treats tokens signed with a generic shared key as trustworthy identity evidence, without ensuring that the signing key is unique per deployment and adequately protected.
Potential impact
- Attackers may forge cg_session cookies for arbitrary users and access their account profile data.
- Victim email addresses and subscription plans could be disclosed, aiding further phishing or social engineering.
- Secret apiKey values can be harvested and used to invoke other clawvet or related services as the victim.
- Compromise of paid or high-privilege accounts, including unauthorized use or abuse of subscription resources.
- Potential downstream impact if the exposed API keys grant access to additional infrastructure or third-party integrations.
General mitigation guidance
Effective mitigation focuses on eliminating predictable secrets and tightening access to identity-linked data.
Recommended patterns include:
- Generate unique, high-entropy JWT signing keys per deployment and store them in secured configuration (e.g., environment variables or secrets managers), not in source code or example files.
- Ensure that example or development configuration files never contain valid-looking production secrets; clearly mark them as placeholders and require override in deployment pipelines.
- Enforce authentication on endpoints that expose user-linked identifiers and sensitive profile data, reducing unauthenticated enumeration of userId values.
- Apply least-privilege principles to API keys and tokens, limiting what a single compromised secret can do and separating read-only from write or administrative capabilities.
- Design authentication flows so that user identity cannot be reconstructed purely from public data combined with a shared secret.
How teams detect issues like this
Teams can identify similar weaknesses through a combination of code and configuration review:
- Static analysis or pattern-based scanning for hard-coded secrets, cryptographic keys, and JWT signing material in source files,
.env.example, and test fixtures. - Code review checklists that flag authentication logic relying on shared secrets or default keys, and verify that deployment-specific secrets are required.
- API security testing to detect unauthenticated endpoints that leak user identifiers or other data that can serve as session token claims.
- Policy enforcement in CI/CD that blocks merges when hard-coded keys or placeholder secrets are detected, and requires secure secret management practices.
- Periodic penetration testing or adversarial reviews focused on token issuance, cookie handling, and exposure of identifiers across the API surface.

