Summary
An authentication weakness in 9Router's /api/settings/database endpoint exposes full database export and import functionality behind a minimal token check.
An attacker who can obtain or forge a JWT or CLI token may exfiltrate all stored credentials and configuration or overwrite the database, leading to complete compromise.
Affected context
The vulnerability appears in deployments of 9Router prior to version 0.4.80 where the /api/settings/database endpoint is protected only by the ALWAYS_PROTECTED middleware.
This middleware relies on JWT or CLI token validation without enforcing stronger, operation-specific authorization or additional confirmation.
Environments that reuse tokens broadly, have long-lived tokens, or expose this endpoint over networks accessible to untrusted parties are more susceptible to abuse.
Exploit preconditions
- Attack surface: HTTP(S) endpoint /api/settings/database
- Required access: Any valid JWT or CLI token accepted by the ALWAYS_PROTECTED middleware; no additional privilege or role checks are required
- Trigger point: Issuing a request to export or import the database via the settings API
- Why exploitation is possible: High-impact administrative operations (full database export/import) are exposed behind a generic authentication layer without fine-grained authorization or contextual checks (e.g., admin role, second factor, or restricted management channel)
Why this happens
The root cause is insufficient access control around sensitive configuration and secrets, mapping to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
In this design, a generic middleware that validates only the presence and basic validity of a JWT or CLI token is treated as sufficient for granting access to powerful administrative operations.
There is no separation between ordinary authenticated requests and privileged management operations that expose or overwrite the entire database, leading to overexposure of sensitive data and configuration.
Potential impact
- Extraction of all stored credentials, API keys, OAuth tokens, and configuration settings
- Unauthorized reconstruction of the environment in another location, enabling impersonation of services
- Complete overwrite of the database, resulting in data loss or configuration sabotage
- Introduction of malicious settings that could route traffic to attacker-controlled infrastructure
- Facilitation of further compromise by reusing leaked secrets across other systems or services
General mitigation guidance
Effective mitigation focuses on restricting access to high-impact administrative operations and reducing the exposure of sensitive data.
Common patterns include:
- Enforcing role-based or capability-based authorization for database export/import endpoints, separate from generic authentication
- Restricting management endpoints to dedicated administrative networks or VPNs, and avoiding exposure over public interfaces
- Applying least-privilege principles so that general-purpose tokens cannot invoke backup or restore operations
- Reducing token lifetime and scope, and segmenting tokens used for automation from those used for interactive access
- Minimizing the volume of secrets stored centrally and favoring dedicated secret-management systems designed with stricter access controls
How teams detect issues like this
Organizations can identify and monitor this class of issue using:
- Static analysis or manual code review to flag endpoints that return full configuration or perform bulk import/export without explicit authorization checks
- API design and security reviews that classify operations by impact and verify that high-risk actions require elevated privileges and contextual safeguards
- Centralized logging and alerting for calls to database export/import operations, especially when initiated from atypical clients, locations, or tokens
- Periodic security testing and red teaming focused on administrative and "settings" APIs to ensure they are not protected solely by generic middleware

