/

CVE-2026-32714

Severity:

CRITICAL RISK

(9.8)

SQL Injection in SciTokens KeyCache SQLite Queries

CVE-2026-32714

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Command Execution Against Local SQLite Database

Severity:

CRITICAL RISK

(9.8)

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

SciTokens' KeyCache class previously constructed SQLite queries using Python's str.format() with user-controlled values like issuer and key_id, leading to classic SQL injection.

In environments where an attacker can influence these fields, they may execute arbitrary SQL commands against the local SciTokens SQLite database, potentially altering or exfiltrating cached key material and related metadata.

Affected context

This vulnerability appears in deployments using the SciTokens reference library where:

  • The KeyCache class is enabled to store and retrieve token-related keys via SQLite.
  • Values such as issuer and key_id can be influenced, directly or indirectly, by external input (for example from token contents, configuration, or upstream services).
  • SQL statements are constructed dynamically rather than via parameterized APIs.

The issue is limited to the local SQLite database used by SciTokens, but its impact depends on how the cached data is used in the broader authorization and trust pipeline.

Exploit preconditions

  • Attack surface: Code paths that call KeyCache methods which construct SQL queries using issuer, key_id, or other externally influenced parameters.
  • Required access: Ability to supply or manipulate values that flow into these parameters (e.g., controlling token contents or configuration fields that become query inputs).
  • Trigger point: Invocation of a KeyCache read/write/lookup operation that interpolates untrusted values into an SQL string using str.format().
  • Why exploitation is possible: The application concatenates untrusted data directly into SQL statements without parameter binding or sanitization, allowing crafted input to break out of expected query structure and inject additional SQL.

Why this happens

The core issue is the construction of SQL statements via Python string formatting functions (str.format()) with parameters derived from untrusted or partially trusted data.

This pattern directly matches CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'). Instead of using parameterized queries or prepared statements, the application embeds values into the SQL string itself. As a result, characters like quotes and SQL metacharacters are interpreted as part of the command rather than as data, enabling attackers to alter query logic, chain multiple commands, or bypass expected query constraints.

Potential impact

  • Modification or deletion of rows in the local SciTokens SQLite database.
  • Insertion of crafted records that may affect key lookup, caching behavior, or trust decisions.
  • Potential exposure of sensitive cached data, such as key identifiers or metadata that could aid further attacks.
  • Corruption of the local cache, causing denial-of-service within components relying on SciTokens for authorization decisions.
  • In some environments, influence over which keys are treated as valid, potentially enabling token validation bypass depending on surrounding controls.

General mitigation guidance

Effective mitigation focuses on eliminating direct string-based SQL construction and tightening trust boundaries around query inputs:

  • Prefer parameterized SQL queries or prepared statements for all database operations, passing dynamic values as bound parameters instead of interpolating them into the SQL string.
  • Centralize database access through a minimal, well-reviewed data access layer to avoid ad hoc query construction scattered throughout the codebase.
  • Treat all issuer, key identifier, and similar fields as untrusted input, even if they originate from tokens or configuration, and avoid using them to modify query structure.
  • Apply the principle of least privilege to the database schema, limiting tables and operations available via the cache interface so unexpected queries have reduced impact.
  • Introduce defensive coding guidelines and linting rules that prohibit use of str.format(), f-strings, or concatenation for SQL assembly.

How teams detect issues like this

Detection typically combines code-centric and behavior-centric approaches:

  • Static analysis: Configure SAST tools or custom rules to flag uses of str.format(), f-strings, or string concatenation in proximity to SQL keywords (SELECT, INSERT, UPDATE, DELETE, FROM, WHERE, etc.).
  • Code review: During reviews, focus on data access layers and ensure all database calls use parameter binding, not raw string interpolation; treat any dynamic SQL construction as a high-risk pattern requiring justification.
  • Automated policy enforcement: Introduce linters or CI checks that prevent direct string-formatted SQL in the repository and encourage standardized database helper APIs.
  • Runtime monitoring (where applicable): For systems with more advanced observability, watch for anomalous or syntactically unusual SQL statements, such as unexpected unions or stacked commands, originating from SciTokens-related components.

Sources

SourceLink
github.comgithub.com/scitokens/scitokens/commit/3dba108853f2f4a6c0f2325c03779bf083c41cf2
github.comgithub.com/scitokens/scitokens/releases/tag/v1.9.6
github.comgithub.com/scitokens/scitokens/security/advisories/GHSA-rh5m-2482-966c

Frequently asked

questions

Exploitability depends on whether an attacker can influence the values passed to KeyCache (such as issuer or key_id). In environments where these parameters originate from user-controlled tokens or external systems without strict validation, the vulnerability can be fully exploitable; in more tightly controlled deployments, practical risk may be reduced but not eliminated.

It often requires the ability to supply or manipulate token-like data or configuration that feeds into SciTokens. Whether that equates to "authenticated" depends on how the surrounding system handles token issuance and ingestion. From the library's perspective, any actor who can control those fields can attempt exploitation.

The robust fix pattern is to replace all string-formatted SQL with parameterized queries or prepared statements, ensuring that dynamic values are always bound as parameters. Additionally, isolating database interactions into a dedicated, reusable data access layer helps enforce this pattern consistently.

Preventing recurrence involves adopting strict development practices: mandate parameterized queries, add linting or static analysis rules against interpolated SQL, review database access code with higher scrutiny, and treat all externally influenced values (including token claims and configuration entries) as untrusted data that must never shape query structure directly.

Find out what's already
exploitable in your codebase.