Skip to content

fix(pin): check final attempt before wiping - #149

Merged
odudex merged 1 commit into
odudex:masterfrom
Jdelg718:fix/pin-final-attempt-wipe
Aug 26, 2026
Merged

fix(pin): check final attempt before wiping#149
odudex merged 1 commit into
odudex:masterfrom
Jdelg718:fix/pin-final-attempt-wipe

Conversation

@Jdelg718

Copy link
Copy Markdown
Contributor

Summary

  • compare the entered PIN before applying the wipe threshold
  • allow a correct PIN on the final configured attempt to unlock and reset the counter
  • keep incorrect attempts at the threshold fail-closed
  • fail closed when the persisted maximum-attempt value is outside the supported 5–50 range
  • add host regression coverage for normal, boundary, and every invalid uint8_t threshold

Closes #148

Security behavior

The failure counter is still pre-incremented and committed before PBKDF2, preserving the existing power-cut-safe accounting. Salt/PBKDF2 and stored-hash failures retain their existing fail-closed threshold behavior.

Test plan

  • Regression test demonstrated RED under threshold-first behavior
  • Invalid-threshold tests demonstrated RED before remediation
  • make -C main/core/test -B test_pin_attempt && ./main/core/test/test_pin_attempt
  • ./scripts/test.sh
  • ./scripts/format.sh --check
  • clean/incremental ESP-IDF v6.0.2 wave_43 firmware build
  • git diff --check

Scope

This PR intentionally does not change the pre-existing NVS read/write/commit error policy; it is limited to the final-attempt ordering bug and corrupted threshold handling.

Compare the entered PIN before applying the wipe threshold so a correct PIN on the final allowed attempt still unlocks. Fail closed for corrupted threshold values and add host regression coverage.
@odudex
odudex merged commit 048da3b into odudex:master Aug 26, 2026
11 checks passed
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.

Correct PIN on final allowed attempt wipes device before hash comparison

2 participants