# GHSA-2j6r-9vv4-6gf5: github.com/bincyber/go-sqlcrypter vulnerable to IV collision

> An attacker with access to ciphertexts can decrypt all messages encrypted with the affected key due to IV collisions in the go-sqlcrypter library.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** No
- **Published:** 20 May 2024
- **Also known as:** GO-2024-2872

## What is GHSA-2j6r-9vv4-6gf5?

GHSA-2j6r-9vv4-6gf5 is a vulnerability in github.com/bincyber/go-sqlcrypter, published on 20 May 2024. 

### Official description

There is a risk of an IV collision using the awskms or aesgcm provider. NIST SP 800-38D section 8.3 states that it is unsafe to encrypt more than 2^32 plaintexts under the same key when using a random IV. The limit could easily be reached given the use case of database column encryption. Ciphertexts are likely to be persisted and stored together. IV collision could enable an attacker with access to the ciphertexts to decrypt all messages encrypted with the affected key.

The aesgcm provider cannot be fixed without a breaking change, so users should not encrypt more than 2^32 values with any key. The awskms package can be fixed without a breaking change by switching to a counter-based IV.

## Which versions are affected by GHSA-2j6r-9vv4-6gf5?

3 open source packages ship an affected version, including github.com/bincyber/go-sqlcrypter.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/bincyber/go-sqlcrypter` | Go | From 0.1.0 | None |
| `github.com/bincyber/go-sqlcrypter` | Go | From 0.1.0 to 0.2.0 | None |
| `github.com/bincyber/go-sqlcrypter` | Go | From 0.1.0 to 0.2.0 | None |

## How do I fix GHSA-2j6r-9vv4-6gf5?

No fix has been published for GHSA-2j6r-9vv4-6gf5 yet. Limit exposure of the affected software until one is available.

## Is GHSA-2j6r-9vv4-6gf5 being exploited?

There is no known exploitation of GHSA-2j6r-9vv4-6gf5 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2j6r-9vv4-6gf5 and fix it if it is affected.

What it is: GHSA-2j6r-9vv4-6gf5 is a vulnerability in github.com/bincyber/go-sqlcrypter, published on 20 May 2024. 
Exploitation: There is no known exploitation of GHSA-2j6r-9vv4-6gf5 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/bincyber/go-sqlcrypter (Go): affected from 0.1.0; no fix listed
- github.com/bincyber/go-sqlcrypter (Go): affected from 0.1.0 up to 0.2.0; no fix listed
- github.com/bincyber/go-sqlcrypter (Go): affected from 0.1.0 up to 0.2.0; no fix listed

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-2j6r-9vv4-6gf5/ (Markdown: https://insights.sbomify.com/GHSA-2j6r-9vv4-6gf5/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2j6r-9vv4-6gf5

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2j6r-9vv4-6gf5/
Summaries are generated and may contain mistakes; the official description above is the record.
