Vulnerabilities in pkg:gem/sqlite3

PACKAGE
Advisory Summary

GHSA-mwm8-39rw-8826 is a MODERATE use-after-free vulnerability (CWE-416: Use After Free) affecting sqlite3-ruby libraries in the RubyGems ecosystem. The issue involves use-after-free in sqlite aggregate arguments in heap-allocated argument array. Remediation is available by upgrading affected packages to version 2.9.6.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:gem/sqlite3

4 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:gem/sqlite3. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-mwm8-39rw-8826 - MODERATE sqlite3-ruby: Use-After-Free in SQLite Aggregate Arguments in Heap-Allocated Argument Array
GHSA-j7fr-3v8c-3qc3 CVE-2026-54620 LOW sqlite3-ruby has Use-After-Free in SQLite Aggregate Function Callbacks
GHSA-28hh-pr2h-2w89 CVE-2026-54619 LOW sqlite3-ruby has Use-After-Free When Redefining SQLite Functions with Different Arity
GHSA-mgvv-5mxp-xq67 - LOW SQLite3 addresses vulnerability in packaged version of libsqlite

GHSA-mwm8-39rw-8826 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-mwm8-39rw-8826
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-416: Use After Free
Affected Product sqlite3-ruby
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix GHSA-mwm8-39rw-8826

To remediate this vulnerability, upgrade all affected sqlite3-ruby dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

sqlite3 fixed: 2.9.6
Upgrade sqlite3 to 2.9.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for sqlite3

How to Check if You Are Affected

To determine whether your application is affected by GHSA-mwm8-39rw-8826, inspect your project dependencies for sqlite3-ruby:

inspect dependencies for sqlite3

Analyze the terminal output to locate any version of sqlite3-ruby in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.9.6), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. In sqlite3-ruby, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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](https://github.com/jeremy)).

GHSA-mwm8-39rw-8826 Affected sqlite3-ruby Versions

1 component(s)
Fixed Versions:
2.9.6
Product / Package Ecosystem Affected Versions Fixed Version
sqlite3
RubyGems
≥ 1.4.0
< 2.9.6
2.9.6

References

Frequently Asked Questions

What is GHSA-mwm8-39rw-8826?
GHSA-mwm8-39rw-8826 is a security vulnerability in sqlite3-ruby involving Use-After-Free in SQLite Aggregate Arguments in Heap-Allocated Argument Array under CWE-416: Use After Free.
Which sqlite3-ruby versions are affected?
Affected versions include releases prior to 2.9.6 across affected packages: sqlite3.
What version fixes GHSA-mwm8-39rw-8826?
Upgrading to 2.9.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sqlite3 affected?
Yes, sqlite3 is affected in releases prior to 2.9.6. Upgrade your dependency to 2.9.6 or later.
What CWE is associated with GHSA-mwm8-39rw-8826?
GHSA-mwm8-39rw-8826 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check RubyGems dependencies for GHSA-mwm8-39rw-8826?
Run the dependency tree command: 'inspect dependencies for sqlite3'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mwm8-39rw-8826",
  "modified" : "2026-10-02T23:11:51Z",
  "published" : "2026-10-02T23:11:51Z",
  "aliases" : [ ],
  "summary" : "sqlite3-ruby: Use-After-Free in SQLite Aggregate Arguments in Heap-Allocated Argument Array",
  "details" : "## Summary\n\nUsing `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.\n\n## Mitigation\n\nUpgrade to sqlite3 gem v2.9.6 or later.\n\nThere 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.\n\n## Severity\n\nThe 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.\n\n## Credits\n\nReported by Jeremy Daer ([@jeremy](https://github.com/jeremy)).",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "sqlite3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.4.0"
      }, {
        "fixed" : "2.9.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.9.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-mwm8-39rw-8826"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/pull/733"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/commit/cc5ac0cdf05af8148f4363410da0ba32508d9c97"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v2.9.6"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-02T23:11:51Z",
    "nvd_published_at" : null
  }
}