Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
# excluded from the default pytest run. A claim nothing executes is not a
# measurement.
#
# Requires network-sandbox-engine >= 2.5.2. Below 2.1.0, the engine could
# Requires network-sandbox-engine >= 2.6.0, the floor of the whole nse extra. Below 2.1.0, the engine could
# report a clean result from an oracle that observed nothing, so a green run
# here would prove nothing about the firewall; below 2.1.2, its capture
# filter hid routable ICMPv6; below 2.2.0, a capture could start before it
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/lifecycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ on:
- "tests/leak/oracle.py"
- "tests/test_chaos_capture.py"
- "tests/test_automap_capture.py"
- "tests/test_lifecycle_observer.py"
schedule:
- cron: "17 4 * * 1"
workflow_dispatch:
Expand Down Expand Up @@ -108,10 +109,21 @@ jobs:
sudo apt-get update -q
sudo apt-get install -y -q --no-install-recommends qemu-system-x86 qemu-utils genisoimage

# The host-side observer (scripts/vm/lifecycle/observer.py) judges each
# phase with network-sandbox-engine, from the reviewed lock.
- name: Set up Python for the observer
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: "3.12"

- name: Install the observer's locked dependencies
run: bash scripts/install_locked.sh python ci

- name: Run the lifecycle scenarios
env:
VM_WORK: ${{ runner.temp }}/vm
VM_DISTRO: ${{ matrix.distro }}
NSE_PYTHON: python
run: scripts/vm/lifecycle/run.sh

- name: Upload captures, state and logs
Expand All @@ -122,6 +134,7 @@ jobs:
path: |
${{ runner.temp }}/vm/*.pcap
${{ runner.temp }}/vm/*.txt
${{ runner.temp }}/vm/observer/
${{ runner.temp }}/vm/cloud-init.json
${{ runner.temp }}/vm/*.log
if-no-files-found: warn
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Tests

- The lifecycle VM judges its phases with NSE 2.6.0, and the `nse` extra
requires `network-sandbox-engine>=2.6.0`. In the guest, NSE's stimulus streams
run as the non-bypassed user between two beacons that carry the guest's clocks.
`scripts/vm/lifecycle/observer.py` reads QEMU's capture. An attempt on the wire
always counts. An absence counts only when:

- the capture is intact and holds both beacons;
- the beacons place every attempt inside it;
- each stream's log is complete;
- no time went untested, except a gap NSE measured as a suspend.

The control, the active session and the reboot now share one continuous
capture. Previously each phase had its own file. The suspend/resume phase runs
its streams through the suspend. Before, nothing was measured until after the
move to the new network. `vm_swap_network` now hands the capture to the new
network before its NIC exists, after QEMU confirms the old NIC is gone. The
power-off phase stays on `egress.py`: a stream its machine kills never has a
complete log, so NSE cannot vouch for its absences.
[Tests](https://github.com/onyks-os/TransparentTorProxy/blob/main/tests/test_lifecycle_observer.py)
run the real agents against loopback and break one instrument at a time: a
missing beacon, a cut or joined capture, a killed stream, attempts outside the
beacons, a gap while the guest ran. Packets captured before a phase's opening
beacon are not read as its attempts. The first VM run counted an earlier
cleartext phase's packet as a leak, because NSE 2.6.0 matched it by a reused
source port although it carried another stream's probe ID.

- The `nse` extra requires `network-sandbox-engine>=2.5.2`. Each rule load in
the zero-leak suite used to add another copy of NSE's trace rules to the
namespace, so every traced packet repeated them once per load. The
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ These are required only for building package distributions (`.deb`, `.rpm`, whee
| [twine](https://pypi.org/project/twine/) | `dev` | `>=7.0.0` | Apache-2.0 | Checking and publishing distributions. 7.0.0 is the first to accept Metadata-Version 2.5. |
| [bump-my-version](https://pypi.org/project/bump-my-version/) | `dev` | `>=1.4.1` | MIT | Version management tool to automate release numbering. |
| [cyclonedx-python-lib](https://pypi.org/project/cyclonedx-python-lib/) | `dev` | `>=11.0.0` | Apache-2.0 | Validates each release SBOM against the official CycloneDX schema (`packaging/validate_sbom.py`). |
| [network-sandbox-engine](https://pypi.org/project/network-sandbox-engine/) | `nse` | `>=2.5.2,<3` | MIT | Isolated netns/Scapy nftables rules validation engine for `tests/test_nse_rules.py`. The floor is a correctness requirement, not a preference: see `pyproject.toml`. |
| [network-sandbox-engine](https://pypi.org/project/network-sandbox-engine/) | `nse` | `>=2.6.0,<3` | MIT | Isolated netns/Scapy nftables rules validation engine for `tests/test_nse_rules.py`. The floor is a correctness requirement, not a preference: see `pyproject.toml`. |
| [pyroute2](https://pypi.org/project/pyroute2/) | `nse` | unpinned | Apache-2.0 | Netlink-based route management inside network namespaces (avoids `/sys` mount in Docker). |

### 1.2 System-Level Dependencies
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ What backs those claims, as of this release:

| Evidence | Where it runs |
| :------- | :------------ |
| **Zero-leak ruleset suite.** TTP's real ruleset in a network namespace (NSE 2.5.2, incomplete captures and windows without their closing beacon rejected, probes and canaries matched by probe ID, round trip answered by a logging receiver in an isolated host namespace), every containment test preceded by a positive control, alongside Docker-, ufw-, firewalld- and WireGuard-shaped competing rulesets. | CI, every push and PR (`make test-nse`) |
| **Zero-leak ruleset suite.** TTP's real ruleset in a network namespace (NSE 2.6.0, incomplete captures and windows without their closing beacon rejected, probes and canaries matched by probe ID, round trip answered by a logging receiver in an isolated host namespace), every containment test preceded by a positive control, alongside Docker-, ufw-, firewalld- and WireGuard-shaped competing rulesets. | CI, every push and PR (`make test-nse`) |
| **Lifecycle transitions.** Shutdown, reboot and suspend/resume onto a new network, judged from a packet capture taken outside the guest, under systemd-networkd (Debian 13) and NetworkManager (Fedora 44, SELinux enforcing). | CI, in a VM, when firewall, lifecycle, DNS or watchdog code changes, and weekly |
| **Watchdog chaos sweep.** Every fault once, each audit paired with a canary, TCP and UDP, in three variants. | CI, in a VM, same trigger |
| **Required VPN gates.** Real Tor through WireGuard in a Debian 13 VM with an external observer: six IPv4/IPv6 topologies, a private obfs4 bridge, suspend/resume and reboot. ParrotOS Home 7.4 (AppArmor enforcing) qualified by hand on the release candidate. | CI, in a VM, when VPN, firewall or lifecycle code changes, and weekly |
Expand Down
12 changes: 8 additions & 4 deletions docs/security-assessment.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,14 @@ reader should not have to guess which.
**Measured in a VM.** `scripts/vm/lifecycle/run.sh` boots a disposable guest - Debian 13,
whose network is brought up by systemd-networkd, and Fedora 44, by NetworkManager - under
QEMU and records every packet it sends with QEMU's `filter-dump`, outside
the guest and below TTP's own firewall. A probe inside the guest, running as an
ordinary non-bypassed user, keeps trying to reach `198.51.100.7` (TEST-NET-2, never a
Tor relay) over UDP/53 and TCP/80. A packet to that address in a capture is a leak,
and a capture with TTP stopped must contain the probe or the run is void. It runs in
the guest and below TTP's own firewall. Inside the guest, NSE stimulus streams
running as an ordinary non-bypassed user keep trying to reach `198.51.100.7`
(TEST-NET-2, never a Tor relay) over UDP/53 and TCP/80, between two beacons that
carry the guest's clocks. An attempt in a capture is a leak. An absence counts only
when the capture is intact, holds both beacons and covers every attempt, and no
time went untested except a measured suspend. With TTP stopped, every attempt must
be in the capture, or the run is void. Shutdown still uses a plain probe and a
stdlib reader, because a stream that its machine kills has no complete log. It runs in
`.github/workflows/lifecycle.yml` when the firewall, lifecycle or DNS code changes,
weekly, and on demand.

Expand Down
2 changes: 1 addition & 1 deletion docs/security/leak-testing-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ runtime leak blocks the affected release regardless of its original priority.
| ID / priority | Extend | Experiment | Required evidence / calibration |
| :--- | :--- | :--- | :--- |
| O01 / P0 | DNS oracle and unit tests | Deliver a direct DNS request to a receiver that drops replies or returns error rcodes; add unrelated concurrent redirected DNS | External packet still means leak; timeout/error/counter alone stays inconclusive; old inference fails the regression |
| O02 / P0 | Capture readers and classifier tests (lifecycle reader: [tests](../../tests/test_lifecycle_egress.py)) | Empty, reply-only, truncated and corrupt capture; wrong NIC; absent stimulus; hidden IP family; unsupported Ethernet/IPv6 layout | No false clean verdict. Distinguish intentional snap length from missing required bytes; correct stimulus is detected in the control |
| O02 / P0 | Capture readers and classifier tests (lifecycle readers: [power-off reader tests](../../tests/test_lifecycle_egress.py), [NSE observer tests](../../tests/test_lifecycle_observer.py)) | Empty, reply-only, truncated and corrupt capture; wrong NIC; absent stimulus; hidden IP family; unsupported Ethernet/IPv6 layout | No false clean verdict. Distinguish intentional snap length from missing required bytes; correct stimulus is detected in the control |
| D01 / P1 | NSE DNS + controlled integration | UDP/TCP 53 to public and LAN resolvers, port rewrites and competing DNAT priorities, IPv4/IPv6 | Unique query/flow observed externally when unprotected; blocked or attributed to Tor when protected; mutate the relevant safeguard |
| D02 / P1 | DNS overlay / resolved integration | After managed Tor has bootstrapped, disable non-Tor resolver paths and clear caches; request fresh names through libc, direct DNS and resolved IPC | Permitted resolution still works through Tor, or documented failure is contained; restored alternative path is a calibrated leak control |
| D03 / P1 | DNS functional tests | A/AAAA/PTR and unsupported TXT/MX/DNSKEY; UDP/TCP requests; explicit per-link DNSSEC policy | Separate supported answers from safe refusal and connectivity loss; verify DNSSEC preflight refusal happens before network changes |
Expand Down
13 changes: 10 additions & 3 deletions docs/web/explanation/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ code changes, and weekly:

- **Lifecycle transitions**: shutdown, reboot and suspend/resume onto a new
network, judged from a packet capture QEMU writes outside the guest, under
systemd-networkd and under NetworkManager.
systemd-networkd and under NetworkManager. Each phase runs NSE's stimulus
streams in the guest between two beacons that carry the guest's clocks. A
probe seen on the wire always counts. An absence counts only when the capture
is intact, holds both beacons, and covers every attempt, and when no stretch
of time went untested except a measured suspend. The power-off phase is still
judged by a stdlib reader, because a stream its machine kills never has a
complete log.
- **The watchdog chaos sweep**: every fault once against a live session. Each audit
is paired with a **canary**, a bypassed user audited the same way in the same
pass, which must be seen - the same positive-control rule, applied to a running
Expand All @@ -132,7 +138,7 @@ What they assert and what they found is in section 4.3 of the

## The dependency, and why it is pinned hard

`network-sandbox-engine>=2.5.2,<3`. The floor is not a preference.
`network-sandbox-engine>=2.6.0,<3`. The floor is not a preference.

Before 2.1.0 the engine's own test runner reported PASSED when its oracle had
observed nothing, and its kernel trace monitor could stop reading mid-run without
Expand Down Expand Up @@ -160,7 +166,8 @@ so the DNAT positive controls require their own packet, and traces the rules a
process's own packets meet, with readiness proven by a canary's own trace. Before
2.5.2 every rule load into a namespace added another copy of NSE's trace rules,
so each traced packet repeated them, and a readiness that could not be proven
did not say why. A green result from an engine below
did not say why. Before 2.6.0 nothing NSE could read judged a phase inside a
VM. A green result from an engine below
the floor would not have been evidence of
anything - the same defect as the one described at the top of this page, one
layer down. TTP refuses to run this suite against an older engine rather than
Expand Down
46 changes: 34 additions & 12 deletions docs/web/how-to/vm-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,49 @@ For full kernel-level, DNS mount, and `systemd` integration testing, use the pro

`scripts/vm/lifecycle/run.sh` takes a TTP session through shutdown, reboot and
suspend/resume onto a new network, and judges each from a packet capture QEMU writes
outside the guest. It needs KVM, `qemu-system-x86_64`, `genisoimage` and `curl`, and
no root:
outside the guest. It needs KVM, `qemu-system-x86_64`, `genisoimage`, `curl` and a
host Python with `network-sandbox-engine>=2.6.0` (`NSE_PYTHON`, default `python3`),
and no root:

```bash
VM_WORK=~/.cache/ttp-lifecycle-vm scripts/vm/lifecycle/run.sh
NSE_PYTHON=venv/bin/python VM_WORK=~/.cache/ttp-lifecycle-vm scripts/vm/lifecycle/run.sh
# the same on a guest whose network is managed by NetworkManager
VM_DISTRO=fedora VM_WORK=~/.cache/ttp-lifecycle-vm-fedora scripts/vm/lifecycle/run.sh
```

`VM_DISTRO` is `debian` (default; Debian 13, systemd-networkd) or `fedora` (Fedora 44,
NetworkManager, SELinux enforcing). It downloads that cloud image once (verified against
the distribution's published checksum list; the list's signature is not checked),
installs TTP from the working tree, and writes `results.txt`, one capture per phase
and state snapshots into `$VM_WORK`. `scripts/vm/lifecycle/egress.py <file.pcap>`
summarises a capture by destination; it streams the file, so size is not a concern.
A capture it cannot vouch for is never summarised as clean: an empty, cut-short or
non-Ethernet file, a frame snapped below its addresses, or a layout it does not parse
(a VLAN tag, an unknown EtherType) prints `INCONCLUSIVE: <reason>` and exits 2. Each
scenario also requires the guest's own SSH traffic in the same window
(`--require-control`), so a window that saw only replies, or nothing, fails as
inconclusive instead of passing as contained.
installs TTP from the working tree, and writes `results.txt`, one capture per QEMU
process, state snapshots and the observer's files (`observer/`) into `$VM_WORK`.

Each phase is observed with NSE's portable agents, run in the guest over SSH:
a clocked beacon, then a UDP and a TCP stimulus stream to `198.51.100.7` as the
unprivileged, non-bypassed user, then a second beacon once the streams have
stopped. `scripts/vm/lifecycle/observer.py` judges the phase once its capture is
closed. An attempt on the wire always counts. An absence counts only when all of
these hold:

- the pcap is intact and holds both beacons;
- the beacons place every attempt on the capture's clock, so the capture was open
for all of them;
- each stream's log is complete;
- no stretch of time went untested, except a gap NSE measured as the guest being
suspended (`CLOCK_BOOTTIME` advancing while `CLOCK_MONOTONIC` stops).

Anything else is inconclusive, which fails the check. When the guest moves to a new
network, `vm_swap_network` waits until QEMU no longer lists the old NIC, stops the
capture, and starts the next one on the new network before its NIC exists. The
observer joins the two files.

The power-off phase is still judged by `scripts/vm/lifecycle/egress.py`, with
`probe.py`: a stream its machine kills never has a complete log, so NSE cannot vouch
for its absences. `egress.py <file.pcap>` summarises a capture by destination and
streams the file. A capture it cannot vouch for is never summarised as clean: an
empty, cut-short or non-Ethernet file, a frame snapped below its addresses, or a
layout it does not parse (a VLAN tag, an unknown EtherType) prints
`INCONCLUSIVE: <reason>` and exits 2. With `--require-control` it also needs the
guest's own SSH traffic in the window.
Transient download errors receive up to three retries. Downloads remain bounded
by connection/transfer timeouts; checksum mismatches still fail the run.
Guest readiness requires successful `cloud-init` completion. A timeout or error
Expand Down
2 changes: 1 addition & 1 deletion docs/web/reference/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ the session starts.

| Group | Package | Constraint | Purpose |
|---|---|---|---|
| `nse` | [network-sandbox-engine](https://pypi.org/project/network-sandbox-engine/) | `>=2.5.2,<3` | Isolated network namespace testing & Scapy rule validation. |
| `nse` | [network-sandbox-engine](https://pypi.org/project/network-sandbox-engine/) | `>=2.6.0,<3` | Isolated network namespace testing & Scapy rule validation. |
| `nse` | [pyroute2](https://pypi.org/project/pyroute2/) | unpinned | Netlink route & interface management inside sandbox namespaces. |
| `dev` | [pytest](https://pypi.org/project/pytest/) | `>=9.1.1` | Unit & integration test runner. |
| `dev` | [hypothesis](https://pypi.org/project/hypothesis/) | `>=6.0.0` | Property-based fuzz testing. |
Expand Down
26 changes: 26 additions & 0 deletions docs/web/release-notes/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Tests

- The lifecycle VM judges its phases with NSE 2.6.0, and the `nse` extra
requires `network-sandbox-engine>=2.6.0`. In the guest, NSE's stimulus streams
run as the non-bypassed user between two beacons that carry the guest's clocks.
`scripts/vm/lifecycle/observer.py` reads QEMU's capture. An attempt on the wire
always counts. An absence counts only when:

- the capture is intact and holds both beacons;
- the beacons place every attempt inside it;
- each stream's log is complete;
- no time went untested, except a gap NSE measured as a suspend.

The control, the active session and the reboot now share one continuous
capture. Previously each phase had its own file. The suspend/resume phase runs
its streams through the suspend. Before, nothing was measured until after the
move to the new network. `vm_swap_network` now hands the capture to the new
network before its NIC exists, after QEMU confirms the old NIC is gone. The
power-off phase stays on `egress.py`: a stream its machine kills never has a
complete log, so NSE cannot vouch for its absences.
[Tests](https://github.com/onyks-os/TransparentTorProxy/blob/main/tests/test_lifecycle_observer.py)
run the real agents against loopback and break one instrument at a time: a
missing beacon, a cut or joined capture, a killed stream, attempts outside the
beacons, a gap while the guest ran. Packets captured before a phase's opening
beacon are not read as its attempts. The first VM run counted an earlier
cleartext phase's packet as a leak, because NSE 2.6.0 matched it by a reused
source port although it carried another stream's probe ID.

- The `nse` extra requires `network-sandbox-engine>=2.5.2`. Each rule load in
the zero-leak suite used to add another copy of NSE's trace rules to the
namespace, so every traced packet repeated them once per load. The
Expand Down
Loading