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

fix: return None when decrypting an unknown or non-dict mnemonic id

Public commit record

What the developer wrote

Authored by kkdao

95/100 · Strong
fix: return None when decrypting an unknown or non-dict mnemonic id

MnemonicStorage.decrypt() resolved the id inside a try/except but then
called stored_value.get("b64_kef") outside it, so an unknown id (where
storage.get returns None) raised AttributeError instead of returning None.
A malformed seeds.json that parses to a non-dict (e.g. a JSON list) hit the
same path. Resolve the source dict and return None when the id is missing
or the stored entry isn't a dict -- no bare except, behaviour now tested.

The sole caller wraps the call in try/except, so this changes no on-device
behaviour; it gives decrypt() a clean return contract.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a small bug in how Krux loads saved encrypted seed data. Previously, if the saved file was valid JSON but shaped like a list instead of a dictionary, or if the requested seed ID was missing, the code could crash with an AttributeError instead of cleanly returning None. The fix makes the code treat those cases as 'nothing found' and adds tests to confirm it. The commit message says the on-device behavior is unchanged because the only caller already catches exceptions.

Recommended action

Treat as a routine defensive fix. Review whether any other callers of decrypt() or storage loaders exist outside the patched module and ensure they also handle None returns. No urgent security response is indicated by the commit materials.

Security signals we found

01

Fixes exception-handling bug that could crash decrypt() on missing or malformed storage entries

02

Adds input validation for JSON shape (dict vs list/other) when loading mnemonic storage

03

Adds unit tests covering malformed/non-dict JSON and unknown mnemonic IDs

04

Removes bare except in decrypt() lookup path

Risk score

Why this scored 29/100

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