CVE-2026-32611: Glances SQL Injection Vulnerability

HIGH
Advisory Identifier: GHSA-49g7-2ww7-3vf5
CVSS 7.0
CWE-89
Published
Advisory Summary

CVE-2026-32611 is a HIGH (CVSS 7.0) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Glances libraries in the PyPI ecosystem. The issue involves glances has a sql injection in duckdb export via unparameterized ddl statements. Remediation is available by upgrading affected packages to version 4.5.2.

CVE-2026-32611 at a Glance

CVE Identifier CVE-2026-32611
GHSA Identifier GHSA-49g7-2ww7-3vf5
Severity HIGH
CVSS v3.1 Base Score 7.0
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Glances
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2026-32611

To remediate this vulnerability, upgrade all affected Glances dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Glances fixed: 4.5.2
pip install Glances>=4.5.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Glances

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-32611, inspect your installed packages using pip:

pip show Glances

Analyze the terminal output to locate any version of Glances in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.5.2), your application is affected.

Note: The pip show Glances command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Glances, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary The GHSA-x46r fix (commit 39161f0) addressed SQL injection in the TimescaleDB export module by converting all SQL operations to use parameterized queries and `psycopg.sql` composable objects. However, the DuckDB export module (`glances/exports/glances_duckdb/__init__.py`) was not included in this fix and contains the same class of vulnerability: table names and column names derived from monitoring statistics are directly interpolated into SQL statements via f-strings. While DuckDB INSERT values already use parameterized queries (`?` placeholders), the DDL construction and table name references do not escape or parameterize identifier names. ## Details The DuckDB export module constructs SQL DDL statements by directly interpolating stat field names and plugin names into f-strings. **Vulnerable CREATE TABLE construction** (`glances/exports/glances_duckdb/__init__.py:156-162`): ```python create_query = f""" CREATE TABLE {plugin} ( {', '.join(creation_list)} );""" self.client.execute(create_query) ``` The `creation_list` is built from stat dictionary keys in the `update()` method (`glances/exports/glances_duckdb/__init__.py:117-118`): ```python for key, value in plugin_stats.items(): creation_list.append(f"{key} {convert_types[type(self.normalize(value)).__name__]}") ``` The INSERT statement also uses the unescaped `plugin` name (`glances/exports/glances_duckdb/__init__.py:172-174`): ```python insert_query = f""" INSERT INTO {plugin} VALUES ( {', '.join(['?' for _ in values])} );""" ``` While INSERT values use `?` placeholders (safe), the table name `{plugin}` is directly interpolated in both CREATE TABLE and INSERT INTO statements. Column names in creation_list are also directly interpolated without quoting. **Comparison with the TimescaleDB fix (commit 39161f0):** The TimescaleDB fix addressed this exact pattern by: 1. Using `psycopg.sql.Identifier()` for table and column names 2. Using `psycopg.sql.SQL()` for composing queries 3. Using `%s` placeholders for all values The DuckDB module was not part of this fix despite having the same vulnerability class. **Attack vector:** The primary attack vector is through stat dictionary keys. While most keys come from hardcoded psutil field names (e.g., `cpu_percent`, `memory_usage`), any future plugin that introduces dynamic keys from external data (container labels, custom metrics, user-defined sensor names) would create an exploitable injection path. Additionally, the table name (`plugin`) comes from the internal plugins list, but any custom plugin with a crafted name could inject SQL. ## PoC The injection is demonstrable when column or table names contain SQL metacharacters: ```python # Simulated injection via a hypothetical plugin with dynamic keys # If a stat dict contained a key like: # "cpu_percent BIGINT); DROP TABLE cpu; --" # The creation_list would produce: # "cpu_percent BIGINT); DROP TABLE cpu; -- VARCHAR" # Which in the CREATE TABLE f-string becomes: # CREATE TABLE plugin_name ( # time TIMETZ, # hostname_id VARCHAR, # cpu_percent BIGINT); DROP TABLE cpu; -- VARCHAR # ); ``` ```bash # Verify with DuckDB export enabled: # 1. Configure DuckDB export in glances.conf: # [duckdb] # database=/tmp/glances.duckdb # 2. Start Glances with DuckDB export and debug logging glances --export duckdb --debug 2>&1 | grep "Create table" # 3. Observe the unescaped SQL in debug output ``` ## Impact - **Defense-in-depth gap:** The identical vulnerability pattern was identified and fixed in TimescaleDB (GHSA-x46r) but the fix was not applied to the sibling DuckDB module. This represents an incomplete patch that leaves the same attack surface open through a different code path. - **Future exploitability:** If any Glances plugin is added or modified to produce stat dictionary keys from external/user-controlled data (e.g., container metadata, custom metric names, SNMP OID labels), the DuckDB export would become immediately exploitable for SQL injection without any additional code changes. - **Data integrity:** A successful injection in the CREATE TABLE statement could corrupt the DuckDB database, create unauthorized tables, or modify schema in ways that affect other applications reading from the same database file. ## Recommended Fix Apply the same parameterization approach used in the TimescaleDB fix. DuckDB supports identifier quoting with double quotes: ```python # glances/exports/glances_duckdb/__init__.py def _quote_identifier(name): """Quote a SQL identifier to prevent injection.""" # DuckDB uses double-quote escaping for identifiers return '"' + name.replace('"', '""') + '"' def export(self, plugin, creation_list, values_list): """Export the stats to the DuckDB server.""" logger.debug(f"Export {plugin} stats to DuckDB") table_list = [t[0] for t in self.client.sql("SHOW TABLES").fetchall()] if plugin not in table_list: # Quote table and column names to prevent injection quoted_plugin = _quote_identifier(plugin) quoted_fields = [] for item in creation_list: parts = item.split(' ', 1) col_name = _quote_identifier(parts[0]) col_type = parts[1] if len(parts) > 1 else 'VARCHAR' quoted_fields.append(f"{col_name} {col_type}") create_query = f"CREATE TABLE {quoted_plugin} ({', '.join(quoted_fields)});" try: self.client.execute(create_query) except Exception as e: logger.error(f"Cannot create table {plugin}: {e}") return self.client.commit() # Insert with quoted table name quoted_plugin = _quote_identifier(plugin) for values in values_list: insert_query = f"INSERT INTO {quoted_plugin} VALUES ({', '.join(['?' for _ in values])});" try: self.client.execute(insert_query, values) except Exception as e: logger.error(f"Cannot insert data into table {plugin}: {e}") self.client.commit() ```

CVE-2026-32611 Affected Glances Versions

1 component(s)
Fixed Versions:
4.5.2
Product / Package Ecosystem Affected Versions Fixed Version
Glances
PyPI
< 4.5.2
4.5.2

References

Frequently Asked Questions

What is CVE-2026-32611?
CVE-2026-32611 is a security vulnerability in Glances involving Glances has a SQL Injection in DuckDB Export via Unparameterized DDL Statements under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Glances versions are affected?
Affected versions include releases prior to 4.5.2 across affected packages: Glances.
What version fixes CVE-2026-32611?
Upgrading to 4.5.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Glances affected?
Yes, Glances is affected in releases prior to 4.5.2. Upgrade your dependency to 4.5.2 or later.
What is the CVSS score of CVE-2026-32611?
CVE-2026-32611 has a CVSS v3.1 base score of 7.0 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:L.
What CWE is associated with CVE-2026-32611?
CVE-2026-32611 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check PyPI dependencies for CVE-2026-32611?
Run the dependency tree command: 'pip show Glances'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-49g7-2ww7-3vf5",
  "modified" : "2026-03-18T21:48:32Z",
  "published" : "2026-03-16T16:34:03Z",
  "aliases" : [ "CVE-2026-32611" ],
  "summary" : "Glances has a SQL Injection in DuckDB Export via Unparameterized DDL Statements",
  "details" : "## Summary\n\nThe GHSA-x46r fix (commit 39161f0) addressed SQL injection in the TimescaleDB export module by converting all SQL operations to use parameterized queries and `psycopg.sql` composable objects. However, the DuckDB export module (`glances/exports/glances_duckdb/__init__.py`) was not included in this fix and contains the same class of vulnerability: table names and column names derived from monitoring statistics are directly interpolated into SQL statements via f-strings. While DuckDB INSERT values already use parameterized queries (`?` placeholders), the DDL construction and table name references do not escape or parameterize identifier names.\n\n## Details\n\nThe DuckDB export module constructs SQL DDL statements by directly interpolating stat field names and plugin names into f-strings.\n\n**Vulnerable CREATE TABLE construction** (`glances/exports/glances_duckdb/__init__.py:156-162`):\n\n```python\ncreate_query = f\"\"\"\nCREATE TABLE {plugin} (\n{', '.join(creation_list)}\n);\"\"\"\nself.client.execute(create_query)\n```\n\nThe `creation_list` is built from stat dictionary keys in the `update()` method (`glances/exports/glances_duckdb/__init__.py:117-118`):\n\n```python\nfor key, value in plugin_stats.items():\n    creation_list.append(f\"{key} {convert_types[type(self.normalize(value)).__name__]}\")\n```\n\nThe INSERT statement also uses the unescaped `plugin` name (`glances/exports/glances_duckdb/__init__.py:172-174`):\n\n```python\ninsert_query = f\"\"\"\nINSERT INTO {plugin} VALUES (\n{', '.join(['?' for _ in values])}\n);\"\"\"\n```\n\nWhile INSERT values use `?` placeholders (safe), the table name `{plugin}` is directly interpolated in both CREATE TABLE and INSERT INTO statements. Column names in creation_list are also directly interpolated without quoting.\n\n**Comparison with the TimescaleDB fix (commit 39161f0):**\n\nThe TimescaleDB fix addressed this exact pattern by:\n1. Using `psycopg.sql.Identifier()` for table and column names\n2. Using `psycopg.sql.SQL()` for composing queries\n3. Using `%s` placeholders for all values\n\nThe DuckDB module was not part of this fix despite having the same vulnerability class.\n\n**Attack vector:**\n\nThe primary attack vector is through stat dictionary keys. While most keys come from hardcoded psutil field names (e.g., `cpu_percent`, `memory_usage`), any future plugin that introduces dynamic keys from external data (container labels, custom metrics, user-defined sensor names) would create an exploitable injection path. Additionally, the table name (`plugin`) comes from the internal plugins list, but any custom plugin with a crafted name could inject SQL.\n\n## PoC\n\nThe injection is demonstrable when column or table names contain SQL metacharacters:\n\n```python\n# Simulated injection via a hypothetical plugin with dynamic keys\n# If a stat dict contained a key like:\n#   \"cpu_percent BIGINT); DROP TABLE cpu; --\"\n# The creation_list would produce:\n#   \"cpu_percent BIGINT); DROP TABLE cpu; -- VARCHAR\"\n# Which in the CREATE TABLE f-string becomes:\n#   CREATE TABLE plugin_name (\n#     time TIMETZ,\n#     hostname_id VARCHAR,\n#     cpu_percent BIGINT); DROP TABLE cpu; -- VARCHAR\n#   );\n```\n\n```bash\n# Verify with DuckDB export enabled:\n# 1. Configure DuckDB export in glances.conf:\n# [duckdb]\n# database=/tmp/glances.duckdb\n\n# 2. Start Glances with DuckDB export and debug logging\nglances --export duckdb --debug 2>&1 | grep \"Create table\"\n\n# 3. Observe the unescaped SQL in debug output\n```\n\n## Impact\n\n- **Defense-in-depth gap:** The identical vulnerability pattern was identified and fixed in TimescaleDB (GHSA-x46r) but the fix was not applied to the sibling DuckDB module. This represents an incomplete patch that leaves the same attack surface open through a different code path.\n\n- **Future exploitability:** If any Glances plugin is added or modified to produce stat dictionary keys from external/user-controlled data (e.g., container metadata, custom metric names, SNMP OID labels), the DuckDB export would become immediately exploitable for SQL injection without any additional code changes.\n\n- **Data integrity:** A successful injection in the CREATE TABLE statement could corrupt the DuckDB database, create unauthorized tables, or modify schema in ways that affect other applications reading from the same database file.\n\n## Recommended Fix\n\nApply the same parameterization approach used in the TimescaleDB fix. DuckDB supports identifier quoting with double quotes:\n\n```python\n# glances/exports/glances_duckdb/__init__.py\n\ndef _quote_identifier(name):\n    \"\"\"Quote a SQL identifier to prevent injection.\"\"\"\n    # DuckDB uses double-quote escaping for identifiers\n    return '\"' + name.replace('\"', '\"\"') + '\"'\n\ndef export(self, plugin, creation_list, values_list):\n    \"\"\"Export the stats to the DuckDB server.\"\"\"\n    logger.debug(f\"Export {plugin} stats to DuckDB\")\n\n    table_list = [t[0] for t in self.client.sql(\"SHOW TABLES\").fetchall()]\n    if plugin not in table_list:\n        # Quote table and column names to prevent injection\n        quoted_plugin = _quote_identifier(plugin)\n        quoted_fields = []\n        for item in creation_list:\n            parts = item.split(' ', 1)\n            col_name = _quote_identifier(parts[0])\n            col_type = parts[1] if len(parts) > 1 else 'VARCHAR'\n            quoted_fields.append(f\"{col_name} {col_type}\")\n\n        create_query = f\"CREATE TABLE {quoted_plugin} ({', '.join(quoted_fields)});\"\n        try:\n            self.client.execute(create_query)\n        except Exception as e:\n            logger.error(f\"Cannot create table {plugin}: {e}\")\n            return\n\n    self.client.commit()\n\n    # Insert with quoted table name\n    quoted_plugin = _quote_identifier(plugin)\n    for values in values_list:\n        insert_query = f\"INSERT INTO {quoted_plugin} VALUES ({', '.join(['?' for _ in values])});\"\n        try:\n            self.client.execute(insert_query, values)\n        except Exception as e:\n            logger.error(f\"Cannot insert data into table {plugin}: {e}\")\n\n    self.client.commit()\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Glances"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.5.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nicolargo/glances/security/advisories/GHSA-49g7-2ww7-3vf5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32611"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nicolargo/glances/commit/63b7da28895249d775202d639e5531ba63491a5c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nicolargo/glances"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nicolargo/glances/releases/tag/v4.5.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-16T16:34:03Z",
    "nvd_published_at" : "2026-03-18T18:16:28Z"
  }
}