payloads(7)

Payloads

The payload is the executable Wrong Boot runs on activation. This page covers what it gets from the kernel, how long it lives and how to test it.

8 of 11

Wrong Boot ships no payload. You write it and point exec at it. Archiving evidence, sending an alert, locking the machine and destroying data are all equally valid. Wrong Boot only decides when it runs.

What exec must be

  • An absolute path. The module refuses to load otherwise.
  • The canonical path to a regular executable file. No symlinks and no .. in it. params-check compares it with what realpath prints.
  • At most 4096 bytes long.
  • A program or a script with a #! line. The kernel runs the file directly without a shell and passes no arguments. exec="/bin/rm -rf /data" is one file name with spaces in it and won't run.
options wrong8007 exec=/usr/local/sbin/wipe

A script's interpreter must exist too. A script that names /bin/bash on a system without bash fails to start.

What it runs with

  • Root with full capabilities. The kernel's usermode helper starts it from kernel credentials, not from any user's session. Treat the file and everything it calls as privileged code and keep it writable by root only.
  • A minimal environment. HOME=/ and PATH=/sbin:/bin:/usr/sbin:/usr/bin and nothing else. Set anything else your payload needs inside it.
  • No terminal. It has no standard input or output and anything it prints is lost. Write to a log file or use logger.

When and how often it runs

The first trigger to fire starts the payload once. Later activations do nothing until the module is loaded again.

The core waits only until the payload has started. From there it runs on its own:

  • Its exit status is never collected.
  • It may run as long as it needs. It holds no kernel worker while it runs.
  • Unloading the module neither waits for it nor stops it.
  • A payload that started is never run again, even when it fails. It may already have done part of its job.

Write it to finish in one run and to cope with a previous run that stopped halfway.

Retries

A payload that fails to start is retried. That covers a missing or non-executable file, a missing interpreter, low memory and usermode helpers disabled while the system suspends or resumes.

Up to 8 attempts are made. The wait between them starts at 1 second and doubles up to 30 seconds (1, 2, 4, 8, 16, 30 and 30), about a minute and a half in total. Then Wrong Boot gives up.

wrong8007: payload failed to start (err=-2), retrying in 1s (attempt 1/8)
wrong8007: payload failed to start (err=-2), retrying in 2s (attempt 2/8)
wrong8007: payload started

Unloading the module during a wait drops the pending attempt and logs pending payload attempt dropped.

Testing

Test the whole chain on a machine you can afford to lose. Point exec at a harmless script first, fire your trigger and look for payload started in the kernel log:

$ sudo dmesg | grep wrong8007

Wrap the payload while you test it to see its exit status in the journal:

#!/bin/sh
/usr/local/sbin/wipe
logger -t wrong8007 "payload exited with status $?"

Point exec at the wrapper while testing and back at the real payload once it works. The kernel runs both the same way.

The module fires once per load. Run make remove and load it again between tests.

Example

The repository's actions/wipe-example.sh erases the partition tables, filesystem signatures and first megabytes of every /dev/sdX and /dev/nvmeXnY disk. It is a bash script and uses wipefs and sgdisk when they are installed.

It destroys data on every matching disk the moment it runs. Read it before you use it and never test it on a machine you care about.

docs/dd.md in the repository covers the background on data destruction. It takes apart the multi-pass overwrite myth, walks through the US government wiping standards and lists established wiping tools a payload can call.