/

CVE-2026-32611

Severity:

HIGH RISK

(7.0)

SQL Injection in Glances DuckDB Export Module

CVE-2026-32611

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution in Embedded DuckDB Database

Severity:

HIGH RISK

(7.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The DuckDB export module in Glances constructs SQL statements using f-strings with table and column names derived from monitoring statistics, without properly sanitizing or parameterizing these identifiers.

An attacker who can influence these names may inject arbitrary SQL into DDL and table reference statements, potentially altering the DuckDB database, tampering with monitoring data, or disrupting export operations.

Affected context

This vulnerability occurs in Glances deployments that use the DuckDB export backend (glances/exports/glances_duckdb/__init__.py) to persist system monitoring metrics.

In such setups, Glances dynamically creates tables and columns based on metric names and uses these identifiers directly in SQL statements via Python f-strings.

If metric-derived identifiers can be influenced—through configuration, plugins, or upstream data sources—these unsanitized names become a vector for SQL injection within the DuckDB database used by Glances.

Exploit preconditions

  • Attack surface: The DuckDB exporter path within a running Glances process.
  • Required access: Ability to control or significantly influence the values used to derive table names, column names, or other SQL identifiers (for example, metric keys or labels that Glances passes to the DuckDB exporter).
  • Trigger point: Execution of DuckDB-related export logic that builds DDL (CREATE/ALTER TABLE) or table reference SQL via f-strings using attacker-controlled identifier fragments.
  • Why exploitation is possible: Identifier names are directly interpolated into SQL strings without robust escaping or use of composable SQL objects, so crafted values can break out of the intended identifier context and inject additional SQL tokens or clauses.

Why this happens

The core issue is a form of SQL injection (CWE-89) stemming from dynamic SQL construction that treats externally influenced values as trusted identifiers.

In the DuckDB export module, Glances composes CREATE TABLE, ALTER TABLE, and INSERT-adjacent statements by embedding table and column names with f-strings instead of using safe abstractions like parameterized identifiers or composable SQL objects.

While value placeholders (?) are used for INSERT parameters, the surrounding DDL and identifier references remain vulnerable because most database drivers only parameterize literal values, not structural components such as table or column names.

This pattern allows attacker-controlled identifier fragments to alter the shape or meaning of the executed SQL, enabling unintended operations on the DuckDB database.

Potential impact

  • Arbitrary modification of the DuckDB schema (creation, alteration, or deletion of tables).
  • Tampering with or deletion of monitoring data stored in DuckDB.
  • Insertion of misleading or crafted records that corrupt monitoring or reporting outputs.
  • Disruption of Glances export functionality via malformed schema or conflicting SQL.
  • Under some deployments, potential pivot into other components that rely on the compromised DuckDB data for downstream processing or alerting.

General mitigation guidance

Effective mitigation focuses on eliminating dynamic string-based SQL construction for identifiers and reducing trust in metric-derived names:

  • Use database-specific mechanisms or composable SQL helpers to safely construct identifiers (e.g., composable objects or dedicated identifier-quoting APIs when available).
  • Centralize and strictly validate any identifier-generation logic, ensuring only a constrained character set and known-safe patterns are allowed for table and column names.
  • Decouple user- or configuration-facing names from raw SQL identifiers by mapping them to internal, sanitized identifiers (for example, hashing or canonical slugging).
  • Keep the DuckDB database used for monitoring running with minimal privileges appropriate to the exporter's needs and isolate it from other critical data stores or processes.
  • Apply defense-in-depth around configuration and plugins so untrusted parties cannot arbitrarily introduce new metric keys or labels that flow into SQL construction.

How teams detect issues like this

Detection generally involves both code-centric and runtime-oriented approaches:

  • Static analysis: Configure linters or SAST tools to flag direct string interpolation into SQL statements, especially usages of f-strings or string concatenation that combine SQL keywords with non-constant variables.
  • Code review: During review, scrutinize all export backends and database adapters for dynamic DDL or identifier construction; look for patterns like f"CREATE TABLE {name}" or similar constructs.
  • Policy enforcement: Introduce secure coding guidelines requiring the use of composable SQL builders or explicit identifier-escaping utilities and ban ad-hoc f-string SQL in shared libraries.
  • Runtime monitoring: Where feasible, log executed SQL statements from the DuckDB interface and inspect for anomalous patterns, such as unexpected multiple statements, unusual keywords, or identifiers not generated by the normal metric pipeline.

Sources

SourceLink
github.comgithub.com/nicolargo/glances/commit/63b7da28895249d775202d639e5531ba63491a5c
github.comgithub.com/nicolargo/glances/releases/tag/v4.5.2
github.comgithub.com/nicolargo/glances/security/advisories/GHSA-49g7-2ww7-3vf5

Frequently asked

questions

Exploitability depends on whether an attacker can influence the metric or identifier names that Glances passes to the DuckDB exporter.

In environments where metric definitions or labels are tightly controlled and not user-influenced, the practical risk is lower; where untrusted sources can shape those names, the risk is significantly higher.

No direct database access is required.

Exploitation occurs through the Glances process itself: the attacker only needs a way to control the values that Glances uses when constructing SQL identifiers, which then get executed by the embedded DuckDB engine.

Replace all f-string or concatenation-based SQL that includes variable identifiers with a safe construction approach, such as composable SQL objects or dedicated identifier-escaping utilities, and enforce strict validation of any identifier sources.

Parameterization should remain in place for values, but identifier handling must be hardened as well.

Establish project-wide rules that prohibit dynamic SQL string building with untrusted data, mandate use of safe query builders for all database operations, and integrate SAST or linters that flag risky SQL patterns.

Combine these technical controls with code review checklists that explicitly call out dynamic SQL creation and identifier handling as security-sensitive areas.

Find out what's already
exploitable in your codebase.