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

transaction: tx_from_any: rm all whitespaces from str, none from bytes

Public commit record

What the developer wrote

Authored by SomberNight

73/100 · Adequate
transaction: tx_from_any: rm all whitespaces from str, none from bytes

- whitespaces are safe to remove from strings, and is convenient if we do this for users
- bytes-like inputs should be left alone: individual bytes that look like whitespaces can appear in them anywhere
- even stripping the leading/trailing whitespaces is not safe to do: the first byte of the nVersion or the last byte of the nLocktime might look like whitespace too!
- instead, leading/trailing whitespaces can be stripped closer to where they are input, e.g. in the GUI
- e.g. ".txn" files that we ourselves create contain a complete tx as a hex string, with a trailing final newline in the file
- instead of reading that as bytes, we can read it as text
- ".psbt" files OTOH are binary
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a bug in how Electrum reads transaction files. Previously, the program would strip whitespace from both text and raw binary transaction data. For binary data, this is dangerous because a byte that looks like a space or newline can legitimately appear in a transaction. The fix reads text files as text (and strips whitespace) and binary files as raw bytes (without altering them). This prevents certain unusual but valid transactions from being corrupted when loaded from a file.

Recommended action

Review and merge. The change is defensive and corrects a real data-handling bug. Users loading binary transaction files (especially PSBTs or raw transactions containing whitespace-like bytes) should upgrade to avoid potential load failures or silent corruption.

Security signals we found

01

Data integrity / malleability: stripping bytes from binary transaction inputs could silently alter a valid PSBT or raw tx

02

Input validation: clearer separation of text vs binary handling

03

Regression tests added/updated to enforce the new behavior

Risk score

Why this scored 44/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 6/15
Affected reach 7/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.