Skip to content

deps: relax cbor2 upper bound to permit >=5.9.0#832

Open
k9ert wants to merge 2 commits intobitcoin-core:masterfrom
k9ert:kn/relax-cbor2-cap
Open

deps: relax cbor2 upper bound to permit >=5.9.0#832
k9ert wants to merge 2 commits intobitcoin-core:masterfrom
k9ert:kn/relax-cbor2-cap

Conversation

@k9ert
Copy link
Copy Markdown

@k9ert k9ert commented Apr 30, 2026

Summary

Relax the cbor2 constraint from >=5.4.6,<5.8 to >=5.4.6,!=5.8.0,<6.0.0, allowing downstreams to install HWI together with cbor2>=5.9.0.

Motivation

The current <5.8 cap was introduced in 38fae57 ("Constrain cbor2 to <5.8") in response to #817cbor2==5.8.0 changes the decoder's stream-read pattern from read(n=1) to read(n=4096), which causes Jade signing to hang on pyserial-style transports.

That fix made sense at the time, but it traps downstream users at a vulnerable version of cbor2:

  • GHSA-3c37-wwvx-h642 (high severity): DoS via uncontrolled recursion in cbor2.loads. Affects all cbor2 < 5.9.0.
  • GHSA-wcj4-jw5j-44wh (medium): CBORDecoder reuse can leak shareable values across decode calls. Fixed in cbor2 >= 5.8.0.

The high-severity advisory is unfixable under the current cap. Downstream projects that pin cbor2>=5.9.0 for security cannot install HWI 3.2.0 without overriding the resolver.

Evidence

I built a hardware-in-the-loop matrix that exercises the full Jade signing path (enumerategetmasterxpubsigntx) under HWI 3.2.0 against cbor2 versions 5.7.1, 5.8.0, and 5.9.0, with and without a candidate read-loop patch.

Test repo (with raw logs and reproduction instructions): https://github.com/al-munazzim/hwi-jade-cbor-repro

mode \ cbor2 5.7.1 5.8.0 5.9.0
stock HWI 3.2.0 PASS FROZEN PASS
with read-loop patch PASS PASS PASS

Tested on macOS 15.4.1, Python 3.9.23, HWI 3.2.0, against an unlocked Jade signer. The key cell: stock HWI 3.2.0 + cbor2 5.9.0 completes Jade signing successfully without any code change in HWI. Whatever changed in cbor2 5.8.0 to break the read pattern appears resolved in 5.9.0 itself.

Scope

This PR is intentionally minimal: cap relax only.

The JadeInterface.read() loop is still fragile — a future cbor2 change could in principle re-trigger the freeze. Hardening that path is a separate concern and a candidate follow-up PR (the patch from the test repo above can be the basis).

cbor2 == 5.8.0 is excluded explicitly (!= 5.8.0) since the FROZEN result there is reproducible and confirmed on real hardware.

Changes

  • pyproject.toml: cbor2 = ">=5.4.6,<5.8"cbor2 = ">=5.4.6,!=5.8.0,<6.0.0"
  • setup.py: same constraint (kept in sync with pyproject)
  • poetry.lock not regenerated in this PR. Happy to add a follow-up commit regenerating it if that is the convention; otherwise it can be regenerated at next release.

Refs

The <5.8 cap from bitcoin-core#817 traps downstreams at cbor2 versions
vulnerable to GHSA-3c37-wwvx-h642 (high-severity DoS in
cbor2.loads), first patched in 5.9.0.

Empirical testing on real Jade hardware shows stock HWI 3.2.0
+ cbor2 5.9.0 completes signing successfully. Whatever broke
in 5.8.0 is fixed in 5.9.0 itself. Test matrix and logs at
https://github.com/al-munazzim/hwi-jade-cbor-repro

Excludes 5.8.0 explicitly (still freezes Jade on pyserial
transports per the test matrix).

poetry.lock not regenerated in this commit; maintainers may
prefer to handle that separately or defer until next release.
@k9ert
Copy link
Copy Markdown
Author

k9ert commented Apr 30, 2026

The pin was IMHO done because @Sjors discovered a timeout of jade-tests and pinned in 38fae57 .
But those are now fixed for some reason, right?!

@Sjors
Copy link
Copy Markdown
Member

Sjors commented Apr 30, 2026

But those are now fixed for some reason, right?

From that commit:

In the Sdist and Wheel test environments, the Jade tests all timed out.

So this would be hard to miss.

@k9ert
Copy link
Copy Markdown
Author

k9ert commented May 1, 2026

  1. I had forgotten to update poetry.lock after relaxing the cbor2 bound in pyproject.toml.
    That mismatch caused early CI failures in lint / Non-device tests / Dist builder / Wine builder.
    After adding the lockfile update, those jobs are green in the latest PR run:

• Dist builder ✅ https://github.com/bitcoin-core/HWI/actions/runs/25211462096/job/73922819687
• Non-device tests ✅ https://github.com/bitcoin-core/HWI/actions/runs/25211462096/job/73922819680
• lint ✅ https://github.com/bitcoin-core/HWI/actions/runs/25211462096/job/73922819673
• Wine builder ✅ https://github.com/bitcoin-core/HWI/actions/runs/25211462096/job/73922819703

Also, regarding the earlier timeout context: Jade jobs are not timing out in this run (they are green), e.g.

• Jade library ✅ https://github.com/bitcoin-core/HWI/actions/runs/25211462096/job/73923444972
• Jade bindist ✅ https://github.com/bitcoin-core/HWI/actions/runs/25211462096/job/73923444980

  1. The remaining red jobs do not appear to be caused by this PR change, since the same failures are present on master:

• Trezor sim builder fails on master with error[E0658]: custom test frameworks are an unstable feature
https://github.com/bitcoin-core/HWI/actions/runs/25012560729/job/73251883660
• Ledger/ledger-legacy jobs fail on master with speculos safe-directory error (fatal: detected dubious ownership ... /test/work/speculos)
https://github.com/bitcoin-core/HWI/actions/runs/25012560729/job/73253524077

So the lockfile issue is fixed in this PR, the remaining failures look like pre-existing CI/environment issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants