Skip to content

nvs: scrub — erase dead values from the flash itself - #6

Merged
Ttimmahlax merged 1 commit into
mainfrom
nvs-scrub
Oct 16, 2026
Merged

Ttimmahlax merged 1 commit into
mainfrom
nvs-scrub

Conversation

@Ttimmahlax

Copy link
Copy Markdown
Contributor

NVS rewrites and removes a value by marking its old entry erased in the page bitmap; the old bytes stay on the flash until that page is erased, which only a full partition's compaction does. For a secret that was rewritten (a passphrase sealed where it lay, a key rotated) that leaves the old value readable off a dumped flash.

Found on an ESP32-C6 with flash encryption on (2026-10-15): the extender's settings were sealed in place (rusty_esp_mid seal), yet the network name and passphrase were still in the clear in a raw read of the nvs partition.

Nvs::scrub compacts every page that holds an erased entry (reusing compact, one active page kept), so each is erased once its live entries are copied out. Tests: the hazard shown and removed, live values read back after a fresh open, a reserve page kept, writes still taken; a clean partition is left byte for byte. On the C6: scrubbed 1 pages at boot, and a raw read of the partition afterwards shows neither the name nor the passphrase.

🤖 Generated with Claude Code

… itself. NVS rewrites and removes by marking the old entry erased; the old bytes stay until the page is erased, so a sealed passphrase's plaintext was still readable off an encrypted C6's flash (2026-10-15). scrub compacts each page holding an erased entry; every live value survives it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ttimmahlax
Ttimmahlax merged commit 6126eea into main Oct 16, 2026
7 checks passed
@Ttimmahlax
Ttimmahlax deleted the nvs-scrub branch October 16, 2026 02:50
Ttimmahlax pushed a commit that referenced this pull request Oct 16, 2026
rusty_esp_core 0.1.3 adds Nvs::scrub: replaced and removed values are erased
from the flash itself, not just marked erased (#6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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