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

Disable Rust Debug formatting

Public commit record

What the developer wrote

Authored by Marko Bencun

66/100 · Adequate
Disable Rust Debug formatting

Pass `-Zfmt-debug=none` in the firmware Rust build.

According to
clippy::no_debug (https://rust-lang.github.io/rust-clippy/master/index.html?search=use_debug):

> It should not be used in user-facing output

This tells rustc not to emit normal `Debug` formatter implementations into
the cross-compiled firmware image. The option also makes `{:?}` print
nothing, so app-visible error status messages must not rely on derived
`Debug`.

Keep the live keystore and backup error status screens explicit by formatting
those errors through small match-based helpers instead of `Debug`. This
preserves the visible diagnostic strings while still allowing derived Debug
formatting to be compiled out of the firmware.

There are still live library `Debug` formatting paths in a no-flag build even
when our callers map those errors to `InvalidInput`. Protobuf and Miniscript
parsers construct detailed errors internally before the caller discards them,
for example `WireType` decode errors and Miniscript `NonTopLevel(format!("{:?}",
...))` errors. `fmt-debug=none` prevents those detailed `Debug` formatters and
their generic formatting helpers from being linked.

Savings: 6464 bytes
✓ Descriptive subject✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit strips out Rust's automatic 'Debug' text-formatting code from the hardware wallet firmware to save space. It replaces a few user-facing error messages that previously relied on Debug formatting with small, hand-written formatters so users still see useful text. The change is primarily a size optimization and code-hardening step, not a fix for an active security bug.

Recommended action

Treat as a defensive hardening/size-optimization change. Review that all remaining user-facing `{:?}` usages in firmware code are covered by the new explicit formatters or are no longer compiled in. Verify that the `-Zfmt-debug=none` flag does not suppress any diagnostic output needed for support or debugging workflows, and confirm clippy::use_debug enforcement catches future regressions in non-cross-compiled builds.

Security signals we found

01

Compiler flag strips Debug formatters from firmware image, reducing attack surface and binary size

02

User-facing error strings no longer depend on derived Debug implementations, avoiding accidental information leakage

03

Third-party library Debug formatting paths identified as still present in no-flag builds are now compiled out

04

Panic message in hex-encoding utility changed from Debug-formatted error to static string

Risk score

Why this scored 25/100

Our methodology →
Potential impact 5/30
Exploitability 2/25
Stealth signal 3/15
Affected reach 4/15
Confidence 7/10
Evidence quality 4/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.