Summary
Glances exposes its full parsed configuration, including credentials and secret keys, through the /api/4/config REST endpoint without redacting sensitive values.
When this endpoint is accessible, an attacker who can make HTTP requests to the Glances API may retrieve database passwords, API tokens, JWT signing keys, and SSL key passwords, leading to broader system compromise.
Affected context
This vulnerability appears in Glances deployments that expose the /api/4/config REST endpoint, either locally or over the network.
It affects configurations where sensitive secrets (database credentials, API tokens, JWT signing keys, SSL-related passwords) are stored in glances.conf and where the API is reachable to users or services beyond a tightly controlled administrative context.
The risk increases significantly when Glances is bound to non-localhost interfaces, integrated into dashboards, or exposed through reverse proxies without strict access controls.
Exploit preconditions
- Attack surface: HTTP interface or API client that can reach the Glances /api/4/config endpoint.
- Required access: Ability to send a request to the Glances REST API; depending on deployment, this may be unauthenticated or require weak/insufficiently scoped authentication.
- Trigger point: Invoking the /api/4/config endpoint, which returns the result of self.config.as_dict() containing all configuration keys and values.
- Why exploitation is possible: The configuration serialization logic does not distinguish between benign and sensitive fields, and no filtering, masking, or role-based restrictions are applied before returning the response.
Why this happens
The core issue is an information exposure by design: the API endpoint is implemented to return the entire internal configuration structure without classifying or filtering sensitive fields.
This maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where a system provides more information than necessary to callers.
Rather than constructing a minimal, purpose-specific response (e.g., non-sensitive configuration or metadata), the code calls self.config.as_dict() directly, effectively turning an internal configuration object—intended for local processing—into an externally visible data structure.
The lack of a secret-handling policy (marking and redacting sensitive keys such as passwords, tokens, and signing keys) and absence of strict access control for this diagnostic endpoint together create a broad secret disclosure channel.
Potential impact
- Retrieval of database usernames and passwords configured in Glances.
- Disclosure of API tokens and service credentials used for monitoring integrations.
- Compromise of JWT signing keys, enabling token forgery and session impersonation in connected systems.
- Exposure of SSL key passwords, potentially weakening TLS termination security elsewhere in the environment.
- Lateral movement opportunities by using leaked credentials to access other internal services and infrastructure.
- Facilitation of further attacks (data exfiltration, privilege escalation, service disruption) by leveraging the exposed secrets.
General mitigation guidance
Effective mitigation focuses on minimizing exposed configuration data and treating secrets as first-class sensitive objects:
- Restrict diagnostic or configuration endpoints so they are not exposed by default to untrusted networks; prefer binding the monitoring UI/API to localhost or an administrative network segment.
- Redesign configuration APIs to return only non-sensitive, strictly defined fields required by clients, instead of generic dumps of internal configuration structures.
- Introduce explicit secret classification in configuration handling: mark keys that represent passwords, tokens, and private keys, and ensure they are redacted or omitted in any serialized output.
- Apply role-based access control to configuration and diagnostic endpoints, limiting access to trusted administrators and tooling.
- Store secrets in dedicated secret-management systems or environment-specific secret stores rather than long-lived, broadly readable configuration files, and avoid echoing them in logs or APIs.
- Apply the principle of least privilege for Glances itself, ensuring that any credentials it uses are scoped narrowly for monitoring purposes and cannot perform broad administrative actions.
How teams detect issues like this
Organizations can identify and monitor for similar information exposure issues through:
- Static analysis and code scanning: Look for patterns where configuration objects are serialized wholesale (e.g., as_dict(), to_json(), vars()) and returned through HTTP responses or logs without filtering.
- Code review practices: Flag endpoints that provide configuration, diagnostics, or "debug" data, and verify they exclude secrets and enforce strict authorization.
- API contract and schema validation: Define explicit response schemas for configuration-related endpoints and enforce them, ensuring no unmodeled sensitive fields can leak.
- Runtime monitoring and logging: Track access to privileged endpoints (like /api/4/config), alert on unexpected callers or spikes in access, and inspect responses for inadvertent presence of secrets.
- Automated secret scanning: Use tools that scan API responses, logs, and configuration repositories for patterns resembling credentials, tokens, and keys to catch accidental exposures early.

