# GHSA-mgvv-5mxp-xq67: SQLite3 addresses vulnerability in packaged version of libsqlite

> An integer overflow in the FTS3 extension of the packaged libsqlite allows code execution if an attacker has full SQL access and can create a large corrupt database.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 3 Oct 2022

## What is GHSA-mgvv-5mxp-xq67?

GHSA-mgvv-5mxp-xq67 is a vulnerability in sqlite3, published on 3 Oct 2022. 

### Official description

### Summary

The rubygem sqlite3 v1.5.1 upgrades the packaged version of libsqlite from v3.39.3 to [v3.39.4](https://sqlite.org/releaselog/3_39_4.html).

libsqlite v3.39.4 addresses a vulnerability described as follows in the release notification:

> Version 3.39.4 is a minimal patch against the prior release that addresses issues found since the
> prior release. In particular, a potential vulnerability in the FTS3 extension has been fixed, so
> this should be considered a security update.
>
> In order to exploit the vulnerability, an attacker must have full SQL access and must be able to
> construct a corrupt database with over 2GB of FTS3 content. The problem arises from a 32-bit
> signed integer overflow.

This vulnerability has not been assigned a CVE and does not have a severity declared.

Please note that this advisory only applies to the sqlite3 gem v1.5.0, and only if the packaged libsqlite is being used. If you've overridden defaults at installation time to use system libraries instead of packaged libraries, you should instead pay attention to your distro's libsqlite release announcements.

### Mitigation

Upgrade to the rubygem sqlite3 v1.5.1 or later.

Users who are unable to upgrade the sqlite3 gem may also choose a more complicated mitigation: compile and link sqlite3 against external libsqlite >= 3.39.4 which will also address these same issues.

### References

- Upstream release notes: https://sqlite.org/releaselog/3_39_4.html
- Instructions for compiling against system libraries: https://github.com/sparklemotion/sqlite3-ruby

## Which versions are affected by GHSA-mgvv-5mxp-xq67?

2 open source packages ship an affected version, including sqlite3.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `sqlite3` | RubyGems | From 1.5.0 | 1.5.1 |
| `sqlite3` | RubyGems | From 1.5.0 | 1.5.1 |

## How do I fix GHSA-mgvv-5mxp-xq67?

Upgrade sqlite3 to 1.5.1 or later.

## Is GHSA-mgvv-5mxp-xq67 being exploited?

There is no known exploitation of GHSA-mgvv-5mxp-xq67 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-mgvv-5mxp-xq67 and fix it if it is affected.

What it is: GHSA-mgvv-5mxp-xq67 is a vulnerability in sqlite3, published on 3 Oct 2022. 
Exploitation: There is no known exploitation of GHSA-mgvv-5mxp-xq67 in the wild and no public exploit code.

Affected packages and fixed versions:
- sqlite3 (RubyGems): affected from 1.5.0; fixed in 1.5.1
- sqlite3 (RubyGems): affected from 1.5.0; fixed in 1.5.1

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-mgvv-5mxp-xq67/ (Markdown: https://insights.sbomify.com/GHSA-mgvv-5mxp-xq67/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-mgvv-5mxp-xq67

---
From sbomify Insights: https://insights.sbomify.com/GHSA-mgvv-5mxp-xq67/
Summaries are generated and may contain mistakes; the official description above is the record.
