# GHSA-q8x8-jrhj-fh9p: Diesel: Possible unaligned data access for implementations of `SqliteAggregate`

> Unaligned memory access in Diesel's SQLite aggregate implementation can cause crashes or code execution when using custom aligned types.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 24 Apr 2026
- **Also known as:** RUSTSEC-2026-0137

## What is GHSA-q8x8-jrhj-fh9p?

GHSA-q8x8-jrhj-fh9p is a memory corruption vulnerability in diesel, published on 24 Apr 2026. 

### Official description

Diesel allows to register custom aggregate SQL functions for SQLite via the `SqliteAggregate` interface.

To store an instance of the custom aggregate processor Diesel relied on the `sqlite3_aggregate_context` function provided by sqlite. This function doesn't provide any guarantees about alignment of the returned allocation, which in turn can lead to problems if the type implementing requires a special alignment, e.g. via a custom `#[align(x)]` attribute on the type implementing this trait. This affects any user of `SqliteAggregate` that registers the custom aggregate function with an SQLite connection, while using a non-standard alignment on the type implementing this trait.

## Mitigation

The preferred mitigation to the outlined problem is to update to a Diesel version 2.3.8 or newer, which includes fixes for the problem.

## Resolution

Diesel now allocates the corresponding memory on Rust side to get a correctly aligned allocation.

## Which versions are affected by GHSA-q8x8-jrhj-fh9p?

3 open source packages ship an affected version, including diesel.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `diesel` | crates.io | All versions | 2.3.8 |
| `diesel` | crates.io | All versions | 2.3.8 |
| `diesel` | crates.io | From 0.0.0-0 | 2.3.8 |

## How do I fix GHSA-q8x8-jrhj-fh9p?

Upgrade diesel to 2.3.8 or later.

## Is GHSA-q8x8-jrhj-fh9p being exploited?

There is no known exploitation of GHSA-q8x8-jrhj-fh9p in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-q8x8-jrhj-fh9p and fix it if it is affected.

What it is: GHSA-q8x8-jrhj-fh9p is a memory corruption vulnerability in diesel, published on 24 Apr 2026. 
Exploitation: There is no known exploitation of GHSA-q8x8-jrhj-fh9p in the wild and no public exploit code.

Affected packages and fixed versions:
- diesel (crates.io): affected all versions; fixed in 2.3.8
- diesel (crates.io): affected all versions; fixed in 2.3.8
- diesel (crates.io): affected from 0.0.0-0; fixed in 2.3.8

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-q8x8-jrhj-fh9p/ (Markdown: https://insights.sbomify.com/GHSA-q8x8-jrhj-fh9p/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-q8x8-jrhj-fh9p

---
From sbomify Insights: https://insights.sbomify.com/GHSA-q8x8-jrhj-fh9p/
Summaries are generated and may contain mistakes; the official description above is the record.
