Attack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessLocal code defines aggregate function
-
DeliveryPrepare statement, then close database
-
ExploitGC frees aggregator memory
-
ExecutionStep stale statement dereferences freed pointer
-
ImpactInvalid 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. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – 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
Affected Packages
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
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
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.
Primary rating from Vendor (https://github.com/sparklemotion/sqlite3-ruby).
CVSS VectorVendor: https://github.com/sparklemotion/sqlite3-ruby
Lifecycle Timeline
2DescriptionCVE.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
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.
What every action level means
SSVC AssessmentENISA
Priority Score
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.
EUVD-2026-49899
GHSA-j7fr-3v8c-3qc3
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB