AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 59 Bitcoin

Merge rust-bitcoin/rust-bitcoin#7061: hashes: disable SHA256 ARM SIMD on big-endian targets

Public commit record

What the developer wrote

Authored by Andrew Poelstra

100/100 · Strong
Merge rust-bitcoin/rust-bitcoin#7061: hashes: disable SHA256 ARM SIMD on big-endian targets

cad9a03cfc9d6c1eb41d3edd5520db7b33d844de hashes: disable SHA256 ARM SIMD on big-endian targets (russeree)

Pull request description:

The AArch64 SHA2 backend loads message words as native-endian `u32` and then unconditionally applies `vrev32q_u8` for little-endian memory order. On `aarch64_be` the `vld1q_u32` load already yields the correct big-endian words, so the extra reversal corrupts every message word. All SHA256, SHA256d, and SHA256t digests are silently wrong on big-endian AArch64 when SHA2 is detected.

This gates the ARM SIMD backend on `target_endian = "little"` (module declaration, cpuid module, and both the one-block SHA256 and two-way SHA256d dispatch sites). Big-endian targets use the endian-correct software fallback, which decodes words with `u32::from_be_bytes`.

Reproduced with QEMU user-mode (`qemu-aarch64_be-static`) and a static `no_std` AArch64 BE binary running the exact ARM SHA2 block routine over the padded `"abc"` block:

```
current (vrev on BE): 312892d3e4bda55775e12e46320ed33a329b15d73167b830ec07ba0845c7b4cf
without vrev (fixed): ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
expected : ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
```

Testing done locally:

- `cargo check` on `x86_64-unknown-linux-gnu`
- `cargo check --target aarch64-unknown-linux-gnu`
- `cargo check -Zbuild-std=std,panic_abort --target aarch64_be-unknown-linux-gnu`
- known-answer SHA256("abc") on x86_64

I did not add an in-tree BE test because `aarch64_be` has no prebuilt Rust std; a QEMU-based `contrib/` repro can be added if maintainers want one.


ACKs for top commit:
apoelstra:
ACK cad9a03cfc9d6c1eb41d3edd5520db7b33d844de; successfully ran local tests; sure, disabling ASM on an obscure arch is fine.


Tree-SHA512: f072189bd6b83584a9941d3c0329e15b9a9475a4a16681209d04a8a6712594d36ceaa4826a559a2cf675f3301c1b63ea1322195ca7a46db0fda64028d75d752f
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a bug in the SHA-256 hashing code used on 64-bit ARM processors. On rare big-endian ARM systems, the code was accidentally reversing the byte order of data before hashing, producing completely wrong SHA-256 results. The fix disables the fast ARM-specific hashing path on big-endian ARM and falls back to the normal, correct software implementation. Wrong SHA-256 hashes could break digital signatures, transaction IDs, or any security check that relies on correct hashing.

Recommended action

Apply the patch. For users running rust-bitcoin on big-endian AArch64 systems, upgrade to a version containing this fix and re-verify any SHA-256-dependent outputs (addresses, transaction IDs, signatures) generated before the fix. Consider adding a CI or contrib test for aarch64_be with QEMU to prevent regression, as the project currently lacks prebuilt std for that target.

Security signals we found

01

Incorrect cryptographic output on big-endian AArch64

02

SHA-256/SHA-256d/SHA-256t digests silently wrong when SHA2 CPU feature detected

03

Endianness mismatch in SIMD message-word loading

04

Fix gates ARM SIMD backend to little-endian targets only

05

Fallback to verified software implementation on big-endian targets

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 8/25
Stealth signal 12/15
Affected reach 7/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.