interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

GitHub aien-dev/aienux#48 (code only)

closed derived 0d5b88b3dc687a27 #48

Imported from GitHub aien-dev/aienux#48 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base ede6cdf17d75486e5b4816f4dfca7b3ef04909d5 · Head f97d461b48b353ce28f76d27051ca86cdf399708

Apply it

git checkout -b patch-0d5b88b3dc687a27 ede6cdf17d75486e5b4816f4dfca7b3ef04909d5
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/0d5b88b3dc687a27.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aienux
48
f97d461b48b353ce28f76d27051ca86cdf399708
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":48,"url":"https://github.com/aien-dev/aienux/pull/48","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:32Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 20b3a1d6..e39d7964 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,7 +23,7 @@ jobs:
       - name: Install QEMU and AAVMF firmware
         run: |
           sudo apt-get update
-          sudo apt-get install -y qemu-system-arm qemu-efi-aarch64
+          sudo apt-get install -y qemu-system-arm qemu-efi-aarch64 swtpm swtpm-tools
 
       - name: Run verification harness and QEMU boot test
         run: bash scripts/verify_all.sh
diff --git a/scripts/qemu_security_suite.sh b/scripts/qemu_security_suite.sh
new file mode 100755
index 00000000..13faa254
--- /dev/null
+++ b/scripts/qemu_security_suite.sh
@@ -0,0 +1,131 @@
+#!/usr/bin/env bash
+# qemu_security_suite.sh: TRUST-1 Gate 4 Security Test Suite in QEMU AArch64
+# Includes:
+# 1. Software TPM 2.0 (swtpm) socket attachment
+# 2. Soak test (configurable iterations, default 5)
+# 3. Fault injection / tampered image rejection test
+# 4. Strict exit code propagation and receipt output
+# Zero Disk Secrets and Unslop compliant.
+
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "${repo_root}"
+
+code_fd="${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}"
+vars_fd="${AAVMF_VARS:-/usr/share/AAVMF/AAVMF_VARS.fd}"
+ITERATIONS="${GATE4_SOAK_RUNS:-5}"
+
+command -v qemu-system-aarch64 >/dev/null || { echo "Error: qemu-system-aarch64 not installed" >&2; exit 2; }
+command -v swtpm >/dev/null || { echo "Error: swtpm not installed" >&2; exit 2; }
+[[ -r "${code_fd}" && -r "${vars_fd}" ]] || { echo "Error: AAVMF firmware not found" >&2; exit 2; }
+
+commit="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
+echo "Building aienos-handoff binary for Gate 4 suite..."
+AIENOS_COMMIT="${commit}" AIENOS_RESTART_SECS=1 cargo build --quiet --release \
+    -p aienos-boot --target aarch64-unknown-uefi --features handoff --bin aienos-handoff
+
+work="$(mktemp -d)"
+tpm_dir="${work}/tpm"
+mkdir -p "${tpm_dir}" "${work}/esp/EFI/BOOT" "${work}/esp/EFI/AIENOS"
+touch "${work}/esp/EFI/AIENOS/BOOTREPORT.TXT"
+cp target/aarch64-unknown-uefi/release/aienos-handoff.efi "${work}/esp/EFI/BOOT/BOOTAA64.EFI"
+
+cleanup() {
+    if [[ -n "${SWTPM_PID:-}" ]] && kill -0 "${SWTPM_PID}" 2>/dev/null; then
+        kill "${SWTPM_PID}" 2>/dev/null || true
+    fi
+    rm -rf "${work}"
+}
+trap cleanup EXIT
+
+echo "=== Subtest 1: Software TPM 2.0 Integration & Live Boot ==="
+swtpm socket --tpm2 \
+    --tpmstate dir="${tpm_dir}" \
+    --ctrl type=unixio,path="${tpm_dir}/swtpm-sock" \
+    --flags not-need-init,startup-clear &
+SWTPM_PID=$!
+sleep 1
+
+cp "${vars_fd}" "${work}/vars.fd"
+log="${work}/serial_tpm.log"
+
+set +e
+timeout ${AIENOS_QEMU_TIMEOUT:-120} qemu-system-aarch64 \
+    -M virt,virtualization=on -cpu max -smp 4 -m 2048 \
+    -chardev socket,id=chrtpm,path="${tpm_dir}/swtpm-sock" \
+    -tpmdev emulator,id=tpm0,chardev=chrtpm \
+    -device tpm-tis-device,tpmdev=tpm0 \
+    -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
+    -drive if=pflash,format=raw,file="${work}/vars.fd" \
+    -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \
+    -device virtio-blk-pci,drive=esp \
+    -device ramfb -display none -nic none \
+    -serial file:"${log}" -no-reboot
+tpm_status=$?
+set -e
+
+tr -d '\r' <"${log}" >"${work}/serial_tpm.txt"
+if grep -q "kernel: alive" "${work}/serial_tpm.txt" && grep -q "report_kind: final" "${work}/serial_tpm.txt"; then
+    echo "PASS  swTPM live boot reached kernel alive and final report"
+else
+    echo "FAIL  swTPM live boot did not complete cleanly"
+    cat "${work}/serial_tpm.txt"
+    exit 1
+fi
+
+echo "=== Subtest 2: Soak Testing (${ITERATIONS} Sequential Boots) ==="
+for i in $(seq 1 "${ITERATIONS}"); do
+    cp "${vars_fd}" "${work}/vars.fd"
+    soak_log="${work}/serial_soak_${i}.log"
+    set +e
+    timeout ${AIENOS_QEMU_TIMEOUT:-120} qemu-system-aarch64 \
+        -M virt,virtualization=on -cpu max -smp 4 -m 2048 \
+        -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
+        -drive if=pflash,format=raw,file="${work}/vars.fd" \
+        -drive if=none,id=esp,format=raw,file=fat:rw:"${work}/esp" \
+        -device virtio-blk-pci,drive=esp \
+        -device ramfb -display none -nic none \
+        -serial file:"${soak_log}" -no-reboot
+    soak_status=$?
+    set -e
+    tr -d '\r' <"${soak_log}" >"${work}/serial_soak_${i}.txt"
+    if grep -q "kernel: alive" "${work}/serial_soak_${i}.txt" && grep -q "report_kind: final" "${work}/serial_soak_${i}.txt"; then
+        echo "PASS  Soak run ${i}/${ITERATIONS}: clean boot & reset"
+    else
+        echo "FAIL  Soak run ${i}/${ITERATIONS} failed"
+        cat "${work}/serial_soak_${i}.txt"
+        exit 1
+    fi
+done
+
+echo "=== Subtest 3: Fault Injection (Corrupted EFI Image) ==="
+corrupt_work="${work}/corrupt"
+mkdir -p "${corrupt_work}/esp/EFI/BOOT"
+head -c 1024 /dev/urandom > "${corrupt_work}/esp/EFI/BOOT/BOOTAA64.EFI"
+cp "${vars_fd}" "${corrupt_work}/vars.fd"
+corrupt_log="${corrupt_work}/serial_corrupt.log"
+
+set +e
+timeout 30 qemu-system-aarch64 \
+    -M virt,virtualization=on -cpu max -smp 4 -m 2048 \
+    -drive if=pflash,format=raw,readonly=on,file="${code_fd}" \
+    -drive if=pflash,format=raw,file="${corrupt_work}/vars.fd" \
+    -drive if=none,id=esp,format=raw,file=fat:rw:"${corrupt_work}/esp" \
+    -device virtio-blk-pci,drive=esp \
+    -device ramfb -display none -nic none \
+    -serial file:"${corrupt_log}" -no-reboot
+corrupt_status=$?
+set -e
+
+if [[ -f "${corrupt_log}" ]]; then
+    tr -d '\r' <"${corrupt_log}" >"${corrupt_work}/serial_corrupt.txt"
+    if grep -q "kernel: alive" "${corrupt_work}/serial_corrupt.txt"; then
+        echo "FAIL  Corrupted binary unexpectedly reached kernel alive"
+        exit 1
+    else
+        echo "PASS  Corrupted binary cleanly rejected by firmware without reaching kernel alive"
+    fi
+fi
+
+echo "TRUST-1 Gate 4 Security Suite: ALL TESTS PASS"
diff --git a/scripts/verify_all.sh b/scripts/verify_all.sh
index 5543da81..d571e246 100755
--- a/scripts/verify_all.sh
+++ b/scripts/verify_all.sh
@@ -63,3 +63,12 @@ echo "Config A: observed capture verified. M0 stays open until native-boot rollb
 echo "Kernel: aarch64-unknown-none library compiles. Native boot remains untested."
 echo "UEFI: diagnostic and GB10-discovering handoff images build; hardware boot remains untested."
 echo "============================================================"
+
+# Step 7: TRUST-1 Gate 4 Security Suite (swTPM, Soak, Fault Injection)
+echo ""
+echo "--- [TRUST-1 Gate 4 Security Suite Verification] ---"
+if command -v qemu-system-aarch64 >/dev/null && command -v swtpm >/dev/null && [[ -r "${AAVMF_CODE:-/usr/share/AAVMF/AAVMF_CODE.no-secboot.fd}" ]]; then
+    GATE4_SOAK_RUNS=3 ./scripts/qemu_security_suite.sh
+else
+    echo "SKIPPED: qemu-system-aarch64, swtpm, or AAVMF firmware not present on host."
+fi