docs(core): Document absence of SD salt overwrite.
What changed, and why it matters
This commit only adds comments explaining why the code does not overwrite SD card salt files with random data before deleting them. It changes no behavior, logic, or security controls. The documentation argues that overwriting is unnecessary because the encrypted data key stored inside the device is already wiped when the salt is changed, so an old recovered salt cannot decrypt anything.
No action required. This is a documentation-only change. If the project later decides secure deletion of SD salt files is desirable, that would require a separate code change, not this commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff in core/src/storage/sd_salt.py is purely documentation. It removes three TODO markers about possibly overwriting salt files with random data and replaces them with explanatory comments. The comments state that, during SD salt regeneration, the old Encrypted Data Encryption Key (EDEK) in internal storage is zeroed, so recovery of the old salt from the SD card is useless. No functional code paths, file-system operations, or cryptographic handling were altered.
Changed components
core/src/storage/sd_salt.pyInspect captured patch +10 / −4
diff --git a/core/src/storage/sd_salt.py b/core/src/storage/sd_salt.py
index 8f5b3499..67c3f9ae 100644
--- a/core/src/storage/sd_salt.py
+++ b/core/src/storage/sd_salt.py
@@ -83,10 +83,10 @@ def load_sd_salt() -> bytearray | None:
# No valid salt file on this SD card.
raise WrongSdCard
- # Normal salt file does not exist, but new salt file exists. That means that
- # SD salt regeneration was interrupted earlier. Bring into consistent state.
- # TODO Possibly overwrite salt file with random data.
+ # Normal salt file is no longer valid or does not exist, but new salt file exists. Meaning
+ # that SD salt regeneration was interrupted earlier. Bring into consistent state.
try:
+ # No need to overwrite the salt file before unlinking, see commit_sd_salt().
fatfs.unlink(salt_path)
except fatfs.FatFSError:
pass
@@ -112,6 +112,12 @@ def commit_sd_salt() -> None:
salt_path = _get_salt_path(new=False)
new_salt_path = _get_salt_path(new=True)
+ # No need to overwrite the old salt with random data before unlinking:
+ # A recovered old salt is useless because changing the SD salt zeroes out the old EDEK in
+ # internal storage, rendering data encrypted under the old salt unrecoverable. The threat
+ # model for regenerating the SD salt is that it has already leaked, not that it might be
+ # forensically recovered from the card later. If it has leaked, the only meaningful
+ # response is securely wiping the EDEK.
try:
fatfs.unlink(salt_path)
except fatfs.FatFSError:
@@ -122,5 +128,5 @@ def commit_sd_salt() -> None:
@with_filesystem
def remove_sd_salt() -> None:
salt_path = _get_salt_path()
- # TODO Possibly overwrite salt file with random data.
+ # No need to overwrite the salt file before unlinking, see commit_sd_salt().
fatfs.unlink(salt_path)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.