mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-09-27 16:51:12 -07:00
The way through the extension sandbox's deny rules is an allowlist, and an allowlist names addresses. The machine's own LAN address is not a fact anybody can pin: a new DHCP lease can turn a peer's address on some package's list into the machine's, and with it open the Grbl port or forgectrl's listeners to that package. ffx.nft now refuses it structurally. Everything a host sends to one of its own addresses, the LAN one included, leaves through lo, so chain pool refuses `oifname "lo"` before it looks at the allow map; the two refusals (a reset for TCP, a drop for the rest, both counted) move into chain refuse, which pool jumps to from both places. No kernel option is new: oifname is in the nf_tables core. scripts/sandbox-rules-test.py gets a destination that is not the machine: a second network namespace joined by a veth pair, with listeners of its own. A pool uid is refused on loopback, IPv6 loopback, its own LAN address, and the peer; an allow chain opens one port of the peer to one uid and nothing else; with loopback, IPv6 loopback, and the machine's own address added to that list the uid is still refused at all three while the peer still answers; a reload closes it. It needs ip and nsenter now. exthost.platform reads its counters from chain refuse, holds the rule's place ahead of the map, and adds the case on the machine: an allow chain for the last pool uid that names forgectrl on loopback and on the LAN address opens neither, and the chain is removed. Proven. The rules test passes with nft 1.0.9, and four controls each fail it: the range one uid short, the TCP reject turned to accept, the delete-table line removed, and the lo rule removed (the uid then reaches all three of the machine's addresses). On the bench reference, image 20260920211625, this rule file loaded from /tmp with nft -f and this suite file mounted: exthost.platform PASS, uid 831 refused at 127.0.0.1:443 and 172.16.1.97:443 with both on its allowlist, the counters [0, 0] to [12, 4]. Against the image's own rules the same test fails on the rule's absence, which is the control. The image's rules were reloaded after. The unit suite passes (422). Acceptance. exthost.platform gates the rule on the machine; sandbox-ci gates the file. The rule file is layer content, in the platform identity of every fingerprint.
40 lines
1.4 KiB
YAML
40 lines
1.4 KiB
YAML
# The extension sandbox's deny rules, proven on real traffic.
|
|
#
|
|
# scripts/sandbox-rules-test.py loads meta-forgefirm's ffx.nft into a network
|
|
# namespace of its own, joins a second namespace to it with a veth pair (a
|
|
# peer that is not the machine), and sends from real uids: a pool uid is
|
|
# refused on loopback, at its own LAN address, and at the peer (TCP at once,
|
|
# UDP with EPERM), the uids on either side of the pool and root are not
|
|
# touched, an allowlist chain opens one port of the peer to one uid, the
|
|
# machine's own addresses stay shut even on an allowlist, and loading the
|
|
# file again takes the allowlist away. The
|
|
# runner's nft is the version the image carries or newer; the kernel side is
|
|
# the image's own business and is proven on the machine (exthost.platform).
|
|
|
|
name: sandbox-ci
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- 'meta-forgefirm/recipes-forgefirm/forgefirm-sandbox/**'
|
|
- 'scripts/sandbox-rules-test.py'
|
|
- '.github/workflows/sandbox-ci.yml'
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
rules:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: nft
|
|
run: sudo apt-get update && sudo apt-get install -y nftables
|
|
|
|
- name: The deny rules on real traffic
|
|
run: |
|
|
# 77 is the script's "could not run here": on this runner that is a failure.
|
|
sudo python3 -B scripts/sandbox-rules-test.py
|