Skip to content

Commit 47eaa59

Browse files
committed
Merge branch 'main' of github.com:flashbots/flashbots-images into kernel-and-docker
2 parents 6ac50b3 + b5b3354 commit 47eaa59

File tree

11 files changed

+1025
-81
lines changed

11 files changed

+1025
-81
lines changed

DEVELOPMENT.md

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Flashbots Images 📦⚡📦
2+
3+
**Reproducible hardened Linux images for confidential computing and safe MEV**
4+
5+
Flashboxes is a toolkit for building minimal, hardened Linux images designed for confidential computing environments and MEV (Maximum Extractable Value) applications. Built on mkosi and Nix, it provides reproducible, security-focused Linux distributions with strong network isolation, attestation capabilities, and blockchain infrastructure support.
6+
7+
It contains our [bottom-of-block searcher sandbox](https://collective.flashbots.net/t/searching-in-tdx/3902) infrastructure and will soon contain our [BuilderNet](https://buildernet.org/blog/introducing-buildernet) infrastructure as well, along with any future TDX projects we implement.
8+
9+
For more information about this repository, see [the Flashbots collective post](https://collective.flashbots.net/t/beyond-yocto-exploring-mkosi-for-tdx-images/4739).
10+
11+
## 🌟 Features
12+
13+
- **Reproducible Builds**: Deterministic image generation using Nix and frozen Debian snapshots
14+
- **Confidential Computing**: Built-in support for Intel TDX and remote attestation
15+
- **Minimal Attack Surface**: Uses very few packages (20Mb base)
16+
- **Flexible Deployment**: Support for Bare Metal TDX, QEMU, Azure, and GCP
17+
18+
## 🚀 Quick Start
19+
20+
### Prerequisites
21+
22+
0. Make sure you're running systemd v250 or greater, or wait for [Docker support](https://github.com/flashbots/flashboxes/pull/11)
23+
24+
1. **Install Nix** (single user mode is sufficient):
25+
```bash
26+
sh <(curl -L https://nixos.org/nix/install) --no-daemon
27+
```
28+
29+
2. **Enable Nix experimental features** in `~/.config/nix/nix.conf`:
30+
```
31+
experimental-features = nix-command flakes
32+
```
33+
34+
3. **Install Debian archive keyring** (temporary requirement):
35+
```bash
36+
# On Ubuntu/Debian
37+
sudo apt install debian-archive-keyring
38+
# On other systems, download via package manager or use Docker approach below
39+
```
40+
41+
### Building Images
42+
43+
1. **Enter the development environment**:
44+
```bash
45+
nix develop -c $SHELL
46+
```
47+
48+
2. **Build a specific image**:
49+
```bash
50+
# Build the BOB (searcher sandbox) image
51+
mkosi --force -I bob.conf
52+
53+
# Build the Buildernet image
54+
mkosi --force -I buildernet.conf
55+
56+
# Build with development tools
57+
mkosi --force -I bob.conf --profile=devtools
58+
59+
# Build with Azure compatibility
60+
mkosi --force -I bob.conf --profile=azure
61+
62+
# Build with both
63+
mkosi --force -I bob.conf --profile=azure,devtools
64+
```
65+
66+
### Running Images
67+
68+
**Create persistent storage** (for stateful applications):
69+
```bash
70+
qemu-img create -f qcow2 persistent.qcow2 2048G
71+
```
72+
73+
**Run QEMU**:
74+
```bash
75+
sudo qemu-system-x86_64 \
76+
-enable-kvm \
77+
-machine type=q35,smm=on \
78+
-m 16384M \
79+
-nographic \
80+
-drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd \
81+
-drive file=/usr/share/edk2/x64/OVMF_VARS.4m.fd,if=pflash,format=raw \
82+
-kernel build/tdx-debian.efi \
83+
-netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:8080 \
84+
-device virtio-net-pci,netdev=net0 \
85+
-device virtio-scsi-pci,id=scsi0 \
86+
-drive file=persistent.qcow2,format=qcow2,if=none,id=disk0 \
87+
-device scsi-hd,drive=disk0,bus=scsi0.0,channel=0,scsi-id=0,lun=10
88+
```
89+
90+
**With TDX confidential computing** (requires TDX-enabled hardware/hypervisor):
91+
```bash
92+
sudo qemu-system-x86_64 \
93+
-accel kvm \
94+
-machine type=q35,kernel_irqchip=split,confidential-guest-support=tdx0 \
95+
-object tdx-guest,id=tdx0 \
96+
-cpu host,-kvm-steal-time,-kvmclock \
97+
-m 16384M \
98+
-nographic \
99+
-kernel build/tdx-debian.efi \
100+
# ... rest of options same as above
101+
```
102+
103+
> Depending on your Linux distro, these commands may require changing the supplied OVMF paths or installing your distro's OVMF package.
104+
105+
## 📖 Documentation
106+
107+
- [Development Guide](DEVELOPMENT.md) - Comprehensive guide for creating new modules and extending existing ones
108+
- [BOB Module Guide](bob/readme.md) - Detailed documentation for the MEV searcher environment

base/base.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Release=trixie
44

55
[Build]
66
PackageCacheDirectory=mkosi.cache
7+
Environment=KERNEL_IMAGE KERNEL_VERSION
8+
WithNetwork=true
9+
Incremental=true
710

811
[Output]
912
Format=uki
@@ -12,9 +15,6 @@ ImageId=tdx-debian
1215
OutputDirectory=build
1316
Seed=630b5f72-a36a-4e83-b23d-6ef47c82fd9c
1417

15-
[Host]
16-
# Incremental=true
17-
1818
[Content]
1919
SourceDateEpoch=0
2020
KernelCommandLine=console=tty0 console=ttyS0,115200n8 mitigations=auto,nosmt spec_store_bypass_disable=on nospectre_v2

base/debloat-systemd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ systemd_svc_whitelist=(
99
"sockets.target"
1010
"local-fs.target"
1111
"local-fs-pre.target"
12+
"network-online.target"
1213
"slices.target"
1314
"systemd-journald.service"
1415
"systemd-journald.socket"

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
devShells.${system}.default = pkgs.mkShell {
3535
nativeBuildInputs = [ pkgs.qemu mkosi ];
3636
shellHook = ''
37-
mkdir -p mkosi.packages mkosi.cache mkosi.builddir
37+
mkdir -p mkosi.packages mkosi.cache mkosi.builddir ~/.cache/mkosi
3838
'';
3939
};
4040
};

mkosi.profiles/devtools/mkosi.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[Content]
22
SkeletonTrees=serial-console.service:/etc/systemd/system/serial-console.service
33
Packages=socat
4+
openssh-server
45
iputils-ping
56
dnsutils
67
strace
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
#!/bin/sh
2+
set -euxo pipefail
3+
24
mkosi-chroot passwd -u root
35
echo "root:dqSPjo4p" | mkosi-chroot chpasswd
6+
7+
if [ -f "$BUILDROOT/etc/default/dropbear" ]; then
8+
# Remove -s, -w, -g flags from dropbear args
9+
sed -i '/^DROPBEAR_EXTRA_ARGS=/s/-[swg] \?//g' "$BUILDROOT/etc/default/dropbear"
10+
else
11+
echo "PermitRootLogin yes" >> "$BUILDROOT/etc/ssh/sshd_config"
12+
echo "PasswordAuthentication yes" >> "$BUILDROOT/etc/ssh/sshd_config"
13+
mkosi-chroot systemctl enable ssh.service
14+
mkosi-chroot systemctl unmask ssh.service ssh.socket
15+
fi

readme.md

Lines changed: 0 additions & 77 deletions
This file was deleted.

verify/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM debian:trixie
2+
3+
# Update and install all required packages
4+
RUN apt-get update && apt-get install -y \
5+
python3-requests \
6+
python3-debian \
7+
equivs \
8+
mmdebstrap \
9+
sbuild \
10+
apt-utils \
11+
wget \
12+
vim \
13+
curl \
14+
gnupg \
15+
devscripts \
16+
dpkg-dev \
17+
&& apt-get clean \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
RUN echo "root:100000:65536" >> /etc/subuid && \
21+
echo "root:100000:65536" >> /etc/subgid
22+
23+
COPY verify.py /usr/local/bin/verify.py
24+
RUN chmod +x /usr/local/bin/verify.py
25+
26+
WORKDIR /workspace
27+
28+
ENTRYPOINT ["python3", "/usr/local/bin/verify.py"]

verify/verify-lite.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
import csv
5+
import requests
6+
from pathlib import Path
7+
from collections import defaultdict
8+
9+
def fetch_status(arch):
10+
"""Fetch package reproducibility status from Debian CI."""
11+
url = f"https://{arch}.reproduce.debian.net/api/v0/pkgs/list"
12+
return {(p['name'], p['architecture']): p for p in requests.get(url).json()}
13+
14+
def main():
15+
# Load manifest
16+
manifest = next(Path("build").glob("*.manifest"))
17+
with open(manifest) as f:
18+
packages = [p for p in json.load(f)["packages"] if p["type"] == "deb"]
19+
20+
# Fetch status from Debian CI
21+
print("Fetching reproducibility status from Debian CI...")
22+
amd64_status = fetch_status("amd64")
23+
all_status = fetch_status("all")
24+
status_data = {**amd64_status, **all_status}
25+
26+
# Analyze packages
27+
results = []
28+
stats = defaultdict(int)
29+
30+
for pkg in packages:
31+
name, version, arch = pkg["name"], pkg["version"], pkg["architecture"]
32+
33+
# Look up status
34+
ci_pkg = status_data.get((name, arch))
35+
36+
if not ci_pkg:
37+
status = "UNKNOWN"
38+
ci_version = "N/A"
39+
else:
40+
status = ci_pkg["status"]
41+
ci_version = ci_pkg["version"]
42+
43+
version_match = version == ci_version
44+
45+
results.append({
46+
"name": name,
47+
"architecture": arch,
48+
"version": version,
49+
"ci_version": ci_version,
50+
"status": status,
51+
"version_match": version_match
52+
})
53+
54+
stats[status] += 1
55+
if not version_match and ci_pkg:
56+
stats["VERSION_MISMATCH"] += 1
57+
58+
# Write CSV report
59+
with open("build/debian-ci-report.csv", 'w', newline='') as f:
60+
writer = csv.DictWriter(f, ["name", "architecture", "version", "ci_version", "status", "version_match"])
61+
writer.writeheader()
62+
writer.writerows(results)
63+
64+
# Print summary
65+
total = len(results)
66+
print(f"\n{'='*50}")
67+
print(f"Total packages: {total}")
68+
for status, count in sorted(stats.items()):
69+
print(f"{status}: {count} ({count/total*100:.1f}%)")
70+
71+
print(f"\nReport saved to: build/debian-ci-report.csv")
72+
73+
if __name__ == "__main__":
74+
main()

0 commit comments

Comments
 (0)