Skip to content

fix(wipe): harden verify_wipe and host_info audit safety#38

Merged
Avicennasis merged 1 commit into
mainfrom
fix/rescue-wipe-safety
Jul 16, 2026
Merged

fix(wipe): harden verify_wipe and host_info audit safety#38
Avicennasis merged 1 commit into
mainfrom
fix/rescue-wipe-safety

Conversation

@Avicennasis

Copy link
Copy Markdown
Member

Summary

Fixes six confirmed correctness bugs in the NIST 800-88 wipe library (autorun/wipe-lib.sh). All were verified by real execution before fixing, and are covered by a new test.

Resolves: FR-076, FR-077, FR-078, FR-092, FR-093, FR-094, FR-098 (Redmine #48104, #48105, #48106, #48084, #48085, #48086, #48090).

verify_wipe

  • Method-aware pattern (FR-077/093): overwrite methods (nwipe random → hdd/usb-flash/fallback) leave random data; the old all-zeros/0xFF check always failed on them (false negative). Overwrite types now verify the sample is not an unwritten all-0x00 block; erase types (nvme-ssd/sata-ssd + SED crypto variants) still require zeros/0xFF.
  • Full-width offset (FR-076/092): RANDOM is 15 bits, so RANDOM*RANDOM (max ~1.07e9 blocks ≈ 550 GB) never sampled the tail of larger drives — a 2 TB drive sampled only ~27 %. Now combines three draws for 45 bits of range.
  • Read-failure detection (FR-098): a failed dd read is no longer silently treated as a passing sample. (wipe-lib.sh already sets pipefail; the actual defect was the swallowed read in verify_wipe, not a wipe_drive dd call — wipe_drive uses nwipe.)
  • od -v fix (found during testing): without it, od collapses repeated 16-byte lines to a * marker, so even a correctly all-zeroed drive never matched the pattern — the original verify would have false-negatived on zeroed drives too.
  • Signature gains a dtype arg; wipe-now.sh and wipe-wizard.sh pass it through.

host_info (FR-078/094)

  • Builds the host JSON via python3 json.dumps instead of raw printf. A DMI value containing a " produced invalid JSON that crashed init_audit's json.loads() and aborted audit initialization. Values are passed as argv (no code injection).

Testing

tests/test_verify_wipe.sh (new) covers host_info escaping, method-aware pattern logic, read-failure handling, and full-range offset coverage on a simulated 2 TB drive. Full suite green; shellcheck --severity=warning clean on all changed files.

Notes / out of scope

  • wipe-lib.sh has 4 pre-existing SC2034 warnings (YELLOW/CYAN used by sourcing scripts; remainder/method_cmd dead vars) — not introduced here; left untouched to keep this change surgical.
  • FR-075/091 (autorun0 local rc=$?) and FR-099 (shred pass count) were investigated and are not bugs — see the respective Redmine tickets for the evidence.

Fixes several correctness bugs in the NIST 800-88 wipe library that could
cause the post-wipe verification and audit log to silently misreport.

verify_wipe (FR-076/077/092/093/098):
- Method-aware pattern check. Overwrite methods (nwipe random, used for
  hdd/usb-flash/fallback) leave RANDOM data; the old all-zeros/0xFF check
  ALWAYS failed on them (false negative). Now overwrite types verify that
  a sample is not an unwritten all-0x00 block, while erase types
  (nvme-ssd/sata-ssd and SED crypto variants) still require zeros/0xFF.
- Full-width sample offset. RANDOM is only 15 bits, so RANDOM*RANDOM
  (max ~1.07e9 blocks ≈ 550GB) never sampled the tail of larger drives;
  a 2TB drive sampled only ~27% of its capacity. Combine three draws for
  45 bits of range, covering any real drive.
- Detect read failures. A failed dd read is no longer silently treated as
  a passing sample; with pipefail the I/O error fails verification.
- Add od -v. Without it, od collapses repeated 16-byte lines to a "*"
  marker, so even a correctly all-zeroed drive never matched the pattern.
- verify_wipe now takes the drive type; wipe-now.sh and wipe-wizard.sh
  pass it through.

host_info (FR-078/094):
- Build the host JSON with python3 json.dumps instead of raw printf. A DMI
  value containing a double-quote produced invalid JSON that crashed
  init_audit's json.loads() and aborted audit initialization. Values are
  passed as argv so they cannot inject code.

Adds tests/test_verify_wipe.sh covering host_info escaping, the
method-aware pattern logic, read-failure handling, and full-range offset
coverage on a simulated 2TB drive.
@Avicennasis
Avicennasis merged commit 553e3fe into main Jul 16, 2026
3 checks passed
@Avicennasis
Avicennasis deleted the fix/rescue-wipe-safety branch July 16, 2026 13:51
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.

1 participant