Skip to main content

sqlite3-ruby EUVDEUVD-2026-49899

| CVE-2026-54620 LOW
Use After Free (CWE-416)
2026-07-28 https://github.com/sparklemotion/sqlite3-ruby GHSA-j7fr-3v8c-3qc3
2.0
CVSS 4.0 · Vendor: https://github.com/sparklemotion/sqlite3-ruby
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Local code defines aggregate function
  2. Delivery
    Prepare statement, then close database
  3. Exploit
    GC frees aggregator memory
  4. Execution
    Step stale statement dereferences freed pointer
  5. Impact
    Invalid read causes segfault

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Memory lifecycle management
MITRE ATT&CK

2 techniques across 2 tactics: Execution, Privilege Escalation

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Requires all of the following in the host Ruby application itself: an aggregate function defined via Database#create_aggregate, #create_aggregate_handler, or #define_aggregator; a prepared statement that calls that aggregate left open; an explicit Database#close (or #discard); a garbage-collection cycle that frees the aggregator; and then a subsequent step call on the now-stale statement. There is no remote or network vector and no external attacker-supplied input - the trigger is an in-process API misuse pattern (AV:L). Exploitation is limited to sqlite3/sqlite3-ruby gem versions >= 2.1.0 and <= 2.9.4; upgrading to 2.9.5 or avoiding aggregate calls after closing the database eliminates it. Practical impact is a process segfault/crash, not a proven denial-of-service or code-execution primitive.

Impact

All available signals converge on low real-world risk. The vendor-supplied CVSS 4.0 vector (AV:L/AC:H/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L, base score 2.0) describes a local, high-complexity, low-privilege-requiring flaw with only partial impact to each of confidentiality, integrity and availability - consistent with the sqlite3-ruby maintainers' own self-assessment of Low severity. EPSS is 0.11% (1st percentile), SSVC returns Exploitation: none / Automatable: no / Technical Impact: partial, there is no CISA KEV listing, and no public exploit code was identified - no public exploit identified at time of analysis. Critically, the flaw is not remotely triggerable: it requires the affected Ruby application's own code to (1) define an aggregate function, (2) keep an open prepared statement, (3) explicitly close the database, and then (4) step that statement after GC - i.e., the 'attacker' is essentially the application's own buggy call sequence, not an external actor. The vendor explicitly states there is no known general exploit usable as a denial-of-service attack. The 'Memory Corruption' / 'Use After Free' framing is technically accurate (CWE-416) but the practical outcome is an invalid read and segfault (process crash), not a demonstrated code-execution primitive. This is a genuine low-priority bug: fix during normal dependency maintenance, not an emergency.

Exploit ScenarioDerived

A Ruby application defines a SQLite aggregate function via Database#create_aggregate/#create_aggregate_handler/#define_aggregator, prepares a statement that calls it, then explicitly closes the database while the prepared statement remains open. After garbage collection frees the aggregator, calling step on that stale statement dereferences freed memory, causing an invalid read and a segmentation fault that crashes the process. No public exploit exists; triggering requires this specific in-process coding pattern rather than any remote or attacker-supplied input.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
Patch available 0.1% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Sep 16, 2026

Use-after-free in the sqlite3 Ruby gem (published as both sqlite3-ruby and sqlite3) versions 2.1.0 through 2.9.4 lets an aggregate function be invoked through a still-open prepared statement after its Database object has been explicitly closed, producing an invalid memory read and a segmentation fault that crashes the Ruby process. Exploitation requires an in-process API-misuse pattern in the host application itself - local, high-complexity, low-privileged per the assessed CVSS:3.1 vector (AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L) - with no remote or network vector and no attacker-supplied input. No public exploit identified at time of analysis (EPSS 0.11%, CISA SSVC exploitation: none, Automatable: no); the maintainers classify it as Low severity, describing a reliably reproducible crash after garbage collection rather than a proven denial-of-service or code-execution primitive.

RemediationAI

Upgrade to the vendor-released fixed version sqlite3 gem 2.9.5 or later (release: https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v2.9.5), which retains aggregator references for the lifetime of the Database object; the fix is carried in PR https://github.com/sparklemotion/sqlite3-ruby/pull/711 and commit https://github.com/sparklemotion/sqlite3-ruby/commit/b24e1e6076528b7f95f99acf7a81c70d0004c726, with full details in advisory GHSA-j7fr-3v8c-3qc3. If an immediate upgrade is not possible, the maintainer-recommended workaround is to avoid invoking aggregate functions after the database has been closed - specifically, finalize or discard every prepared statement that calls an aggregate before calling Database#close or #discard, and never call Statement#step on a statement whose database has been closed; the trade-off is that this requires auditing application and library code for statement-lifecycle ordering, and any missed path can still crash the process. Because there is no remote vector, network-level controls are not applicable; where aggregate callbacks must survive close, keeping a local reference to the aggregator object can also prevent premature freeing, at the cost of a small memory leak.

Affected VersionsENISA

sqlite3-ruby 2.1.0, < 2.9.5

Affected Packages

rubygems sqlite3 fix: 2.9.5
rubygems sqlite3-ruby fix: 2.9.5

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 2 packages in rubygems

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The flaw is a use-after-free (CWE-416) inside the sqlite3-ruby native C extension (ext/sqlite3/database.c and lib/sqlite3/database.rb). Aggregate functions are registered through Database#create_aggregate, #create_aggregate_handler, or #define_aggregator, and their Ruby handler blocks/objects are retained on the Database object (the "-aggregators" instance variable). When the database is explicitly closed via #close or #discard, the extension released those references and set them to nil, and after a subsequent garbage-collection cycle the underlying aggregator callbacks were freed. A prepared statement that was already open and calls that aggregate still holds pointers to the SQLite aggregate context and callback, so a later Statement#step dereferences the freed aggregator, triggering an invalid memory read and segfault. The fix (PR #711, commit b24e1e6076528b7f95f99acf7a81c70d0004c726) removes the nil-ing of the aggregator reference on close/discard so the Ruby blocks are kept alive for the lifetime of the database object, and adds a regression test (test_step_on_statement_whose_database_was_closed_does_not_use_freed_aggregator). Affected packages per CPE data are pkg:rubygems/sqlite3-ruby and pkg:rubygems/sqlite3; this is a purely in-process Ruby/SQLite integration issue with no SQL injection, protocol, or network component.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/sparklemotion/sqlite3-ruby) PRIMARY 2.0 LOW
CVSS:4.0/AV:L/AC:H/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N
vuln.today AI 2.5 LOW

Trigger is in-process API misuse after GC (AV:L, AC:H), needs the app's own code path (PR:L); only a crash results, so A:L and C:N/I:N.

3.1 AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L
4.0 AV:L/AC:H/AT:N/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N

Primary rating from Vendor (https://github.com/sparklemotion/sqlite3-ruby).

CVSS VectorVendor: https://github.com/sparklemotion/sqlite3-ruby

Attack Vector
Local
Attack Complexity
High
Attack Requirements
None
Privileges Required
Low
User Interaction
None
Vulnerable system: Confidentiality
Low
Vulnerable system: Integrity
Low
Vulnerable system: Availability
Low
Subsequent system: Confidentiality
None
Subsequent system: Integrity
None
Subsequent system: Availability
None

Lifecycle Timeline

2
CVSS changed
Jul 28, 2026 - 17:22 NVD
2.0 (LOW)
CVE Published
Jul 28, 2026 - 16:23 cve.org
LOW 2.0

DescriptionCVE.org

Summary

Using Database#create_aggregate, #create_aggregate_handler, or Database#define_aggregator to define an aggregate function, and then using an open statement calling that function after the database has been explicitly closed will result in an invalid memory read and a segmentation fault.

Mitigation

Upgrade to sqlite3 gem v2.9.5 or later.

As a workaround, avoid using an aggregate function after closing the database.

Severity

The sqlite3-ruby maintainers assess this as Low severity. It is reliably triggered after GC when code is structured in a particular way. There is no known general exploit that could be used as a denial of service attack.

Threat Intelligence Overview

EPSS Score
0.1%
Top 99% exploitable
Prevalence
High
sqlite3-ruby is the de facto SQLite binding for Ruby, very widely used
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA GitHub

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity LOW
CISA KEV No
Public POC No
EPSS 0.1%
Patch available Yes
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Defer
Exploitation
None
System Exposure· derived
Small
Automatable
No
Human Impact· derived
Low
Technical Impact
Partial

Priority Score

10
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +10
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Use-after-free vulnerabilities occur when a program continues to access memory through a pointer after that memory has been deallocated.

Memory corruption occurs when a program writes data beyond the boundaries of allocated memory regions or accesses memory in unintended ways, violating the integrity of the process's address space.

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy