Severity:

HIGH RISK

(7.3)

SQL Injection in PandasAI LanceDB Extension Query Handlers

CVE-2026-4996

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-74, CWE-89

Impact:

Data Exposure and Manipulation via SQL Injection

Severity:

HIGH RISK

(7.3)

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

Sinaptik AI PandasAI versions up to 0.1.4 contain a SQL injection vulnerability in multiple query and document management functions within the pandasai-lancedb extension.

When untrusted input is interpolated into database queries without proper sanitization or parameterization, a remote attacker may manipulate or execute arbitrary SQL statements against the underlying LanceDB-backed datastore.

Affected context

This issue occurs in the pandasai-lancedb extension of PandasAI, specifically in the lancedb.py module under extensions/ee/vectorstores/lancedb/pandasai_lancedb/.

The vulnerable functions include:

  • delete_question_and_answers
  • delete_docs
  • update_question_answer
  • update_docs
  • get_relevant_question_answers_by_id
  • get_relevant_docs_by_id

The risk is present when these functions construct database queries with user-controlled identifiers, filters, or document metadata, especially in deployments where PandasAI is exposed through APIs, web backends, agents, or other remotely accessible services.

Exploit preconditions

  • Attack surface: Any API endpoint, web handler, or service method that routes unvalidated client input into the affected LanceDB-related functions.
  • Required access: Ability to send requests that influence question IDs, document IDs, filters, or other query parameters consumed by the vulnerable functions; no prior authentication may be required depending on the surrounding application.
  • Trigger point: Execution of a database operation (delete, update, or retrieval) where input is concatenated into the query string or otherwise bound without strict parameterization.
  • Why exploitation is possible: The code path appears to construct LanceDB or SQL-like queries directly from untrusted values without using safe parameter binding, canonicalization, or robust input validation, aligning with CWE-89 and CWE-74 patterns.

Why this happens

The root cause is unsafe construction of database queries using untrusted input in the pandasai-lancedb extension.

Instead of relying on parameterized queries or a type-safe query builder, the implementation likely interpolates IDs, conditions, or document attributes into query expressions as raw strings.

This behavior matches:

  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') — untrusted input is embedded into commands interpreted by a database engine.
  • CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component — the downstream component (LanceDB / query engine) consumes data that has not been neutralized for its context.

As a result, crafted input can break out of the intended query structure and alter the semantics of delete, update, or select operations.

Potential impact

  • Reading data from tables or collections that the application logic does not intend to expose.
  • Modifying or deleting stored questions, answers, and documents, potentially corrupting AI knowledge bases or vector stores.
  • Bypassing application-level access controls by directly manipulating query predicates.
  • Injecting conditions that cause denial of service, such as extremely expensive queries or broad destructive operations.
  • In some environments, pivoting to compromise adjacent data or services that share the same database engine.

General mitigation guidance

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

  • Prefer parameterized queries or prepared statements offered by the underlying LanceDB or database driver, ensuring that user-supplied values are always treated as data rather than executable query syntax.
  • Introduce a constrained query-building API or repository layer that accepts only strongly-typed parameters (IDs, enums, whitelisted fields) and never raw fragments of query language.
  • Apply strict input validation for IDs, limits, and filters, using allowlists for acceptable fields and operators instead of free-form expressions.
  • Centralize authorization checks around delete/update operations so that even if input is malformed, it cannot bypass role- or tenant-based restrictions.
  • Run database and application components with least-privilege accounts, limiting what an injected query is allowed to do if a flaw is reached.

How teams detect issues like this

Detection typically combines code-level analysis with runtime monitoring:

  • Static analysis: Configure SAST rules to flag string concatenation or f-string formatting used to build queries in lancedb.py and related data-access modules. Look specifically for patterns where user-controlled parameters flow into query constructors.
  • Code review: During reviews, require that all database interactions use parameterized APIs; add checklist items focused on query construction in extensions and vector store integrations.
  • Policy enforcement: Introduce linters or CI checks that forbid direct use of low-level query execution functions with raw strings, except in explicitly reviewed and annotated locations.
  • Runtime monitoring: Enable database query logging and anomaly detection to identify unexpected query patterns, overly broad deletions/updates, or queries containing attacker-controlled substrings.

Sources

SourceLink
gist.github.comgist.github.com/YLChen-007/e33f76941234bed3824181ed252bd09f
vuldb.comvuldb.com/?ctiid.353883
vuldb.comvuldb.com/?id.353883
vuldb.comvuldb.com/?submit.778268

Frequently asked

questions

Yes. The description notes that the attack can be launched remotely. If the affected functions are reachable via web APIs, agents, or integrations, an attacker can exploit the flaw over the network by supplying crafted parameters.

At minimum, the attacker needs the ability to send requests that control the IDs, filters, or other parameters passed into the vulnerable functions. Whether authentication is required depends on how the host application exposes these operations.

Refactor all database interactions in the pandasai-lancedb extension to use parameterized queries or a high-level query builder that strictly separates query structure from data, combined with clear validation and authorization checks around destructive operations like delete and update.

Establish a standard data-access layer that enforces parameterization by design, adopt secure coding guidelines for all query construction, and back these practices with automated checks in CI (static analysis, linters, and mandatory code review for data-access changes).

Find out what's already
exploitable in your codebase.