---
id: CVE-2026-54620
aliases:
  - GHSA-j7fr-3v8c-3qc3
title: sqlite3-ruby has Use-After-Free in SQLite Aggregate Function Callbacks
summary: sqlite3-ruby has Use-After-Free in SQLite Aggregate Function Callbacks
severity: low
cwe:
  - CWE-416
vendor: sqlite3-ruby
product: sqlite3-ruby
ecosystem: rubygems
affected:
  - 'sqlite3-ruby >= 2.1.0, <= 2.9.4'
  - 'sqlite3 >= 2.1.0, <= 2.9.4'
patched:
  - sqlite3-ruby 2.9.5
  - sqlite3 2.9.5
published: '2026-07-28'
updated: '2026-07-28'
source: GHSA
sourceUrl: 'https://github.com/advisories/GHSA-j7fr-3v8c-3qc3'
references:
  - url: >-
      https://github.com/sparklemotion/sqlite3-ruby/security/advisories/GHSA-j7fr-3v8c-3qc3
  - url: 'https://github.com/sparklemotion/sqlite3-ruby/pull/711'
  - url: >-
      https://github.com/sparklemotion/sqlite3-ruby/commit/b24e1e6076528b7f95f99acf7a81c70d0004c726
  - url: >-
      https://github.com/rubysec/ruby-advisory-db/blob/master/gems/sqlite3/CVE-2026-54620.yml
  - url: 'https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v2.9.5'
  - url: 'https://www.cve.org/CVERecord/SearchResults?query=CVE-2026-54620'
  - url: 'https://github.com/advisories/GHSA-j7fr-3v8c-3qc3'
tags:
  - ghsa
  - rubygems
ingestedAt: '2026-07-28T16:37:04.428Z'
epss: 0.00142
epssPercentile: 0.02843
---

## Overview

## 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.

## Affected packages

- `sqlite3-ruby >= 2.1.0, <= 2.9.4`
- `sqlite3 >= 2.1.0, <= 2.9.4`

## Remediation

Upgrade to a patched release:

- `sqlite3-ruby 2.9.5`
- `sqlite3 2.9.5`
