# GHSA-gmx7-gr5q-85w5: magic-crypt uses insecure cryptographic algorithms

> The magic-crypt Rust library uses insecure DES encryption and lacks integrity checks, allowing attackers to decrypt data via padding oracle attacks.

- **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:** 28 Dec 2024
- **Also known as:** RUSTSEC-2024-0430

## What is GHSA-gmx7-gr5q-85w5?

GHSA-gmx7-gr5q-85w5 is a vulnerability in magic-crypt, published on 28 Dec 2024. 

### Official description

This crate uses a number of cryptographic algorithms that are no longer considered secure and it uses them in ways that do not guarantee the integrity of the encrypted data.

`MagicCrypt64` uses the insecure DES block cipher in CBC mode without authentication. This allows for practical brute force and padding oracle attacks and does not protect the integrity of the encrypted data. Key and IV are generated from user input using CRC64, which is not at all a key derivation function.

`MagicCrypt64`, `MagicCrypt128`, `MagicCrypt192`, and `MagicCrypt256` are all vulnerable to padding-oracle attacks. None of them protect the integrity of the ciphertext. Furthermore, none use password-based key derivation functions, even though the key is intended to be generated from a password.

Each of the implementations are unsound in that they use uninitialized memory without `MaybeUninit` or equivalent structures.

For more information, visit the [issue](https://github.com/magiclen/rust-magiccrypt/issues/17).

## Which versions are affected by GHSA-gmx7-gr5q-85w5?

3 open source packages ship an affected version, including magic-crypt.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `magic-crypt` | crates.io | All versions to 4.0.1 | None |
| `magic-crypt` | crates.io | All versions to 4.0.1 | None |
| `magic-crypt` | crates.io | From 0.0.0-0 | None |

## How do I fix GHSA-gmx7-gr5q-85w5?

No fix has been published for GHSA-gmx7-gr5q-85w5 yet. Limit exposure of the affected software until one is available.

## Is GHSA-gmx7-gr5q-85w5 being exploited?

There is no known exploitation of GHSA-gmx7-gr5q-85w5 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-gmx7-gr5q-85w5 and fix it if it is affected.

What it is: GHSA-gmx7-gr5q-85w5 is a vulnerability in magic-crypt, published on 28 Dec 2024. 
Exploitation: There is no known exploitation of GHSA-gmx7-gr5q-85w5 in the wild and no public exploit code.

Affected packages and fixed versions:
- magic-crypt (crates.io): affected all versions up to 4.0.1; no fix listed
- magic-crypt (crates.io): affected all versions up to 4.0.1; no fix listed
- magic-crypt (crates.io): affected from 0.0.0-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-gmx7-gr5q-85w5/ (Markdown: https://insights.sbomify.com/GHSA-gmx7-gr5q-85w5/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-gmx7-gr5q-85w5

---
From sbomify Insights: https://insights.sbomify.com/GHSA-gmx7-gr5q-85w5/
Summaries are generated and may contain mistakes; the official description above is the record.
