# GHSA-5j8w-r7g8-5472: Arrow2 allows double free in `safe` code

> A double free vulnerability in the Arrow2 Rust library allows attackers to cause a segmentation fault and denial of service via cloning specific structs.

- **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:** 4 Mar 2022
- **Also known as:** RUSTSEC-2022-0012

## What is GHSA-5j8w-r7g8-5472?

GHSA-5j8w-r7g8-5472 is an use after free vulnerability in arrow2, published on 4 Mar 2022. 

### Official description

The struct `Ffi_ArrowArray` implements `#derive(Clone)` that is inconsistent with
its custom implementation of `Drop`, resulting in a double free when cloned.

Cloning this struct in `safe` results in a segmentation fault, which is unsound.

This derive was removed from this struct. All users are advised to either:
* bump the patch version of this crate (for versions `v0.7,v0.8,v0.9`), or
* migrate to a more recent version of  the crate (when using `<0.7`).

Doing so elimitates this vulnerability (code no longer compiles).

## Which versions are affected by GHSA-5j8w-r7g8-5472?

7 open source packages ship an affected version, including arrow2.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `arrow2` | crates.io | All versions | 0.7.1 |
| `arrow2` | crates.io | All versions | 0.7.1 |
| `arrow2` | crates.io | From 0.0.0-0 | 0.7.1, 0.8.2, 0.9.2, 0.10.0 |
| `arrow2` | crates.io | From 0.8.0 | 0.8.2 |
| `arrow2` | crates.io | From 0.8.0 | 0.8.2 |
| `arrow2` | crates.io | From 0.9.0 | 0.9.2 |
| `arrow2` | crates.io | From 0.9.0 | 0.9.2 |

## How do I fix GHSA-5j8w-r7g8-5472?

Upgrade arrow2 to a fixed version for your release line: 0.7.1, 0.8.2, 0.9.2 or 0.10.0.

## Is GHSA-5j8w-r7g8-5472 being exploited?

There is no known exploitation of GHSA-5j8w-r7g8-5472 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-5j8w-r7g8-5472 and fix it if it is affected.

What it is: GHSA-5j8w-r7g8-5472 is an use after free vulnerability in arrow2, published on 4 Mar 2022. 
Exploitation: There is no known exploitation of GHSA-5j8w-r7g8-5472 in the wild and no public exploit code.

Affected packages and fixed versions:
- arrow2 (crates.io): affected all versions; fixed in 0.7.1
- arrow2 (crates.io): affected all versions; fixed in 0.7.1
- arrow2 (crates.io): affected from 0.0.0-0; fixed in 0.7.1, 0.8.2, 0.9.2, 0.10.0
- arrow2 (crates.io): affected from 0.8.0; fixed in 0.8.2
- arrow2 (crates.io): affected from 0.8.0; fixed in 0.8.2
- arrow2 (crates.io): affected from 0.9.0; fixed in 0.9.2
- arrow2 (crates.io): affected from 0.9.0; fixed in 0.9.2

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-5j8w-r7g8-5472/ (Markdown: https://insights.sbomify.com/GHSA-5j8w-r7g8-5472/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-5j8w-r7g8-5472

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