/

CVE-2024-36058

Severity:

CRITICAL RISK

(9.8)

SQL Injection in Koha OPAC Send Basket Functionality

CVE-2024-36058

Awaiting Analysis

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Information Disclosure

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

A time-based SQL injection vulnerability in Koha Library's OPAC Send Basket feature allows malicious input in the bib_list POST parameter to influence SQL queries.

Under certain configurations, an authenticated library user can leverage timing responses to infer and read arbitrary data from the underlying database.

Affected context

This vulnerability appears in Koha Library deployments that expose the OPAC (Online Public Access Catalog) "Send Basket" functionality and construct SQL queries using the bib_list POST parameter without robust input handling.

It is most relevant where:

  • The OPAC is accessible to library users
  • The send-basket endpoint interacts with the database using dynamically built queries
  • Database accounts used by the application have broad access to catalog and user-related tables

Exploit preconditions

  • Attack surface: HTTP POST requests to /cgi-bin/koha/opac-sendbasket.pl
  • Required access: Ability to authenticate or otherwise act as a "library user" in the OPAC interface
  • Trigger point: Submission of a crafted bib_list parameter in the Send Basket request
  • Why exploitation is possible: The server-side code incorporates bib_list directly into SQL without adequate parameterization or validation, enabling an attacker to introduce additional SQL logic and use time-based techniques (e.g., deliberate delays) to infer database contents.

Why this happens

The root cause is the construction of SQL statements by concatenating or interpolating user-controlled input (bib_list) rather than using properly typed, parameterized queries.

This pattern aligns with CWE-89: SQL Injection, where attackers can modify the structure of a query by injecting SQL metacharacters and clauses into untrusted data fields.

In this case, the use of time-based operations makes it possible to exfiltrate information even when direct error messages or query results are not exposed.

Potential impact

  • Reading database records that the current user would not normally be able to access
  • Discovery of sensitive catalog, patron, or configuration data
  • Mapping of database schema, including table and column names
  • Pivoting to additional attacks if the database role has extensive privileges

General mitigation guidance

Effective mitigation centers on eliminating dynamic SQL built from user input and tightening the trust boundary around OPAC parameters.

Common defensive patterns include:

  • Using parameterized queries or prepared statements for all database interactions involving bib_list and similar parameters
  • Restricting inputs to well-defined formats (e.g., numeric IDs separated by approved delimiters) with strict server-side validation
  • Applying least-privilege permissions to the database account used by the OPAC so it can access only what is necessary
  • Centralizing query construction in vetted helper functions or ORM layers to reduce ad-hoc SQL
  • Implementing generic error handling that avoids exposing detailed database behavior, while still logging security-relevant anomalies internally

How teams detect issues like this

Detection typically involves a combination of code-level review and runtime monitoring:

  • Static analysis rules that flag string-based SQL construction using request parameters such as bib_list
  • Manual code review focusing on CGI scripts and modules handling OPAC basket operations, looking for concatenated SQL strings
  • Database query logging and analysis to detect unusual patterns, such as sleep/delay functions or conditional timing constructs
  • Application-level security testing (including automated scanners) configured to exercise the Send Basket endpoint with time-based injection probes

Sources

SourceLink
github.comgithub.com/hacklantic/Research/tree/main/CVE-2024-36058
gitlab.comgitlab.com/koha-community/Koha/-/blob/23.05.x/misc/release_notes/release_notes_23_05_10.md
gitlab.comgitlab.com/koha-community/Koha/-/blob/23.05.x/misc/release_notes/release_notes_23_05_11.md
koha-community.orgkoha-community.org/koha-22-05-22-released/

Frequently asked

questions

Yes, if the OPAC interface is exposed over the network and reachable by users, an attacker with library user-level access can target the vulnerable endpoint remotely.

They typically need the same access as a normal library user who can use the OPAC Send Basket feature. Elevated administrative privileges are not required for the core SQL injection behavior.

Replace any SQL string concatenation involving bib_list with parameterized queries or prepared statements, and enforce strict input validation that only permits expected identifier formats. This should be applied consistently across all similar endpoints.

Adopt a development standard that forbids dynamic SQL built from untrusted data, relies on ORM or query builders with bound parameters, enforces rigorous input validation, and uses automated security checks (static analysis and targeted tests) as part of the CI/CD pipeline.

Find out what's already
exploitable in your codebase.