GHSA-mwm8-39rw-8826 — sqlite3-ruby: Use-After-Free in sqlite3
sqlite3-ruby: Use-After-Free in SQLite Aggregate Arguments in Heap-Allocated Argument Array
Does your project use an affected sqlite3 version?
Paste your Gemfile.lock to check it for GHSA-mwm8-39rw-8826 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
Using Database#create_aggregate, #create_aggregate_handler, or Database#define_aggregator to define an aggregate function that takes two or more arguments, and then evaluating it over TEXT or BLOB column values, can free the Ruby objects holding those arguments while a later argument is still being converted, during ordinary garbage collection. The aggregate's step method then receives an incorrect object, or the process crashes with a segmentation fault.
Mitigation
Upgrade to sqlite3 gem v2.9.6 or later.
There is no reliable workaround. If you cannot upgrade, avoid defining aggregate functions that take two or more arguments. Restricting column value sizes is not a mitigation: smaller values make the defect fire less often but do not prevent it.
Severity
The sqlite3-ruby maintainers assess this as Medium severity (CVSS 4.0 score 6.3). It is reached through ordinary garbage collection without any unusual code structuring: an application is exposed whenever it evaluates a multi-argument aggregate over TEXT or BLOB values whose size an attacker can influence. The demonstrated impact is an incorrect value passed to the aggregate's step method, or a process crash; no controlled memory write or general denial-of-service exploit has been demonstrated.
Credits
Reported by Jeremy Daer (@jeremy).
Advisory Timeline
- First published October 2, 2026 (55 days ago).
- Last revised October 2, 2026 — 0 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
gem install sqlite3 -v 2.9.6
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: RubyGems (1).
| Package | Fixed In |
|---|---|
| sqlite3 RubyGems · Affected: 1.4.0, 1.4.1, 1.4.2, 1.4.3 (+57 more) | 2.9.6 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-416Use After FreeMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 6.8 score means for each attack dimension.
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N
References
- https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-mwm8-39rw-8826WEB
- https://github.com/sparklemotion/sqlite3-ruby/pull/733WEB
- https://github.com/sparklemotion/sqlite3-ruby/commit/cc5ac0cdf05af8148f4363410da0ba32508d9c97WEB
- https://github.com/sparklemotion/sqlite3-rubyPACKAGE
- https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v2.9.6WEB
Frequently Asked Questions
- What is GHSA-mwm8-39rw-8826?
- sqlite3-ruby: Use-After-Free in SQLite Aggregate Arguments in Heap-Allocated Argument Array. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 6.8/10).
- How do I check if my project is affected by GHSA-mwm8-39rw-8826?
- GHSA-mwm8-39rw-8826 affects sqlite3. Use GeekWala's free vulnerability scanner to check your dependencies against GHSA-mwm8-39rw-8826 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation requires specific conditions, or the impact is limited.
Related CVEs
- CVE-2026-128084MEDIUM
sqlite3-ruby: Possible SQL query truncation when a string is 4 GiB or larger
- CVE-2026-128068MEDIUM
rails-html-sanitizer: Possible regular expression denial of service with certain configurations
- CVE-2026-115472MEDIUM
Doorkeeper: When using public clients, any client can revoke any access token
- CVE-2026-54619LOW
sqlite3-ruby has Use-After-Free When Redefining SQLite Functions with Different Arity
- CVE-2026-54620LOW
sqlite3-ruby has Use-After-Free in SQLite Aggregate Function Callbacks