CVE-2026-54620: Sqlite3 ruby Sqlite3-ruby Has Use-After-Free Vulnerability

LOW
Advisory Identifier: GHSA-j7fr-3v8c-3qc3
CWE-416
Published
Advisory Summary

CVE-2026-54620 is a LOW sqlite3-ruby has use-after-free vulnerability (CWE-416: Use After Free) affecting Sqlite3 ruby libraries in the RubyGems ecosystem. The issue involves sqlite3-ruby has use-after-free in sqlite aggregate function callbacks. Remediation is available by upgrading affected packages to version 2.9.5.

CVE-2026-54620 at a Glance

CVE Identifier CVE-2026-54620
GHSA Identifier GHSA-j7fr-3v8c-3qc3
Severity LOW
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 CVE-2026-54620

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-ruby fixed: 2.9.5
Upgrade sqlite3-ruby to 2.9.5
sqlite3 fixed: 2.9.5
Upgrade sqlite3 to 2.9.5
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-ruby

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-54620, inspect your project dependencies for Sqlite3 ruby:

inspect dependencies for sqlite3-ruby

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.5), 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, 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.

CVE-2026-54620 Affected Sqlite3 ruby Versions

2 component(s)
Fixed Versions:
2.9.5
Product / Package Ecosystem Affected Versions Fixed Version
sqlite3-ruby
RubyGems
≥ 2.1.0
< 2.9.5
2.9.5
sqlite3
RubyGems
≥ 2.1.0
< 2.9.5
2.9.5

References

Frequently Asked Questions

What is CVE-2026-54620?
CVE-2026-54620 is a security vulnerability in Sqlite3 ruby involving sqlite3-ruby has Use-After-Free in SQLite Aggregate Function Callbacks under CWE-416: Use After Free.
Which Sqlite3 ruby versions are affected?
Affected versions include releases prior to 2.9.5 across affected packages: sqlite3-ruby, sqlite3.
What version fixes CVE-2026-54620?
Upgrading to 2.9.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sqlite3-ruby affected?
Yes, sqlite3-ruby is affected in releases prior to 2.9.5. Upgrade your dependency to 2.9.5 or later.
Is sqlite3 affected?
Yes, sqlite3 is affected in releases prior to 2.9.5. Upgrade your dependency to 2.9.5 or later.
What CWE is associated with CVE-2026-54620?
CVE-2026-54620 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 CVE-2026-54620?
Run the dependency tree command: 'inspect dependencies for sqlite3-ruby'. 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-j7fr-3v8c-3qc3",
  "modified" : "2026-07-28T16:23:57Z",
  "published" : "2026-07-28T16:23:57Z",
  "aliases" : [ "CVE-2026-54620" ],
  "summary" : "sqlite3-ruby has Use-After-Free in SQLite Aggregate Function Callbacks",
  "details" : "## Summary\n\nUsing `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.\n\n## Mitigation\n\nUpgrade to sqlite3 gem v2.9.5 or later.\n\nAs a workaround, avoid using an aggregate function after closing the database.\n\n## Severity\n\nThe 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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "sqlite3-ruby"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0"
      }, {
        "fixed" : "2.9.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.9.4"
    }
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "sqlite3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.1.0"
      }, {
        "fixed" : "2.9.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.9.4"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-j7fr-3v8c-3qc3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/pull/711"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/commit/b24e1e6076528b7f95f99acf7a81c70d0004c726"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/sqlite3/CVE-2026-54620.yml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v2.9.5"
  }, {
    "type" : "WEB",
    "url" : "https://www.cve.org/CVERecord/SearchResults?query=CVE-2026-54620"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-28T16:23:57Z",
    "nvd_published_at" : null
  }
}