omnet
aien-dev/omnet
Brought by drakestapleton
omnet / README.md
| 1 | # omnet |
| 2 | |
| 3 | Security-critical network code, rewritten in [Omega](https://github.com/aien-dev/omega-mv). |
| 4 | |
| 5 | Most serious vulnerabilities in network software over the last several decades come from a short list |
| 6 | of bug classes: out-of-bounds reads and writes, integer overflow, unbounded reads and loops, |
| 7 | use-after-free, and check-then-use races. omnet rewrites security-critical parts of network |
| 8 | infrastructure in a language where the first group cannot happen silently. Its design rules target |
| 9 | the rest. |
| 10 | |
| 11 | The first project is **Tailnet Lock for self-hosted Tailscale (Headscale) control servers**. Tailnet Lock (TKA) |
| 12 | lets the devices of a tailnet, not the control server, decide which devices may join. The stock |
| 13 | Tailscale client already implements the device side. The open-source control server |
| 14 | [headscale](https://github.com/juanfont/headscale) does not implement the server side |
| 15 | ([headscale#1307](https://github.com/juanfont/headscale/issues/1307)). omnet builds that server-side |
| 16 | logic in Omega. |
| 17 | |
| 18 | ## Install |
| 19 | |
| 20 | [`docs/install.md`](docs/install.md) builds and runs it on a Headscale server, and shows the stock |
| 21 | `tailscale lock` command working against your own server. |
| 22 | [`docs/runbook.md`](docs/runbook.md) turns the lock on over a tailnet already in use, step by step, |
| 23 | with a rollback; `integration/e2e/run.sh --scenario runbook` rehearses every step on a private tailnet. |
| 24 | |
| 25 | ## What the language rules out, and what it does not |
| 26 | |
| 27 | Facts below are from the Omega language reference, `docs/one_layer/OMEGESE.md` ยง9, at the pinned |
| 28 | commit in [`omega.pin`](omega.pin). |
| 29 | |
| 30 | | Bug class | Omega behaviour | |
| 31 | |---|---| |
| 32 | | Out-of-bounds array access | Every index that is not a constant is checked when it runs: trap 3. Constant indices outside the array are refused at compile time. Kernel I/O checks its buffer range before the call. | |
| 33 | | Signed integer overflow | Signed `add sub mul neg div shl` trap 1 when the exact result does not fit. | |
| 34 | | Lossy conversion | A conversion to a type that cannot hold the value traps 5. There are no implicit conversions. | |
| 35 | | Bad shifts, division by zero | A shift outside `0 .. width-1` traps 7; division by zero traps 2. | |
| 36 | | Unbounded loops | Every loop has a bound (default 1,000,000 passes); passing it traps 4. | |
| 37 | | Heap corruption, use-after-free | There is no heap allocator and no exposed pointer. Arrays have a fixed length that travels with the name. Local arrays are freed under compile-time ownership checks. | |
| 38 | | Stack exhaustion | A call or local array that would overrun the fixed 8 MiB stack traps 6 before writing. | |
| 39 | |
| 40 | An unsized `view T *` / `edit T *` parameter is a pointer plus a count. Every index into it is checked |
| 41 | at run time and the count travels with it, so the bounds rule above holds for slices as well |
| 42 | ([OM-2 guarantee matrix](https://github.com/aien-dev/omega-mv/blob/2d6ea129b5fc12c29472e79b20c3e225a1cedef4/docs/one_layer/OM2-TUTORIAL.md) |
| 43 | lives in the Omega repository; it was added in omega-mv `2d6ea129`, after the commit in `omega.pin`). |
| 44 | A trap stops the program. That turns memory corruption into a crash, so a reachable trap is still a |
| 45 | denial-of-service bug. |
| 46 | |
| 47 | **Bounded by the code, with a test that shows it:** |
| 48 | |
| 49 | - Store record sizes and running totals are charged with checked arithmetic and held under a 65536 |
| 50 | record cap and a 33554432 byte cap; an over-capacity write is refused and the registry stays |
| 51 | readable (registry capacity guard test). |
| 52 | - A file path is used to open a descriptor, and the work then continues on the descriptor, never on a |
| 53 | path checked earlier (design rule 2). Rename, short-write and crash paths are exercised by fault |
| 54 | tests. |
| 55 | |
| 56 | **Still open, and handled by review:** |
| 57 | |
| 58 | - Logic and protocol errors, including wrong authorization decisions. |
| 59 | - Timing side channels. omnet code is **not** constant-time-audited; the secret comparison bounds how |
| 60 | many bytes are read, not how long it takes. |
| 61 | - Unsigned arithmetic wraps by definition. Checked arithmetic applies only where a module uses it. |
| 62 | |
| 63 | **Reduced but not eliminated:** |
| 64 | |
| 65 | - Resource exhaustion at the service level: too many clients or too much stored state. |
| 66 | |
| 67 | ## Design rules for omnet code |
| 68 | |
| 69 | 1. **Bounded input.** Every read has an explicit capacity, and every message has a maximum size that |
| 70 | is checked before it is parsed. |
| 71 | 2. **No check-then-use on names.** Act on an opened descriptor, never on a path checked earlier. |
| 72 | 3. **Fail closed.** Parse errors and signature failures reject. Compatibility behavior must match |
| 73 | the pinned protocol: unknown signed AUM kinds advance the hash chain as no-ops, as Tailscale |
| 74 | specifies; they never bypass authorization. |
| 75 | 4. **Least privilege.** A component that parses untrusted input runs without the privileges of the |
| 76 | component that acts on the result. |
| 77 | 5. **Two referees.** Each algorithm is checked against published test vectors and against an |
| 78 | independent implementation used only as a test oracle (never shipped). Every test harness has a |
| 79 | mutant check that proves it can fail. |
| 80 | |
| 81 | ## Layout |
| 82 | |
| 83 | | Path | Content | |
| 84 | |---|---| |
| 85 | | `om/<unit>/<unit>.om` | Omega library: functions only, no globals, no `main` | |
| 86 | | `om/<unit>/test/` | Program-mode test driver, vectors, `run.sh` | |
| 87 | | `cmd/tkad/` | Native Omega local daemon, RPC handlers, recovery and real-socket tests | |
| 88 | | `tools/build-tkad.sh` | Builds the daemon with the pinned compiler | |
| 89 | | `integration/headscale/` | Pinned Headscale v0.29.6 adapter patch, build script and trust contract | |
| 90 | | `integration/e2e/` | Unmodified Tailscale v1.102.0 client builds and isolated lifecycle harness | |
| 91 | | `docs/design/` | Design documents | |
| 92 | | `tools/omc.sh` | Builds the pinned seed-born Omega compiler and verifies its digest | |
| 93 | | `tools/test.sh` | Runs library and daemon suites | |
| 94 | |
| 95 | ## Build and test |
| 96 | |
| 97 | Requirements: Linux on ARM64 (the Omega compiler emits AArch64 Linux programs), `git`, POSIX `sh`, |
| 98 | Python 3, and Go >=1.26.5 for the TKA differential oracle. Omega holds all TKA logic; |
| 99 | the optional Headscale adapter is Go glue and uses Go1.27.3. |
| 100 | |
| 101 | ```sh |
| 102 | tools/test.sh # builds the pinned compiler on first use, then runs every unit's tests |
| 103 | ``` |
| 104 | |
| 105 | `.github/workflows/test.yml` runs `tools/test.sh` on every pull request and push to `main`, on a |
| 106 | GitHub-hosted Ubuntu 24.04 arm64 runner with Go 1.26.8. |
| 107 | |
| 108 | ## Status |
| 109 | |
| 110 | The Omega daemon implements all eight TKA RPCs, node registry/map operations, durable |
| 111 | snapshots, and validated restart recovery over a private Unix socket. Its local adapter is trusted |
| 112 | and must run as the same UID; the daemon does not authenticate remote Tailscale clients. |
| 113 | |
| 114 | The current profile supports one tailnet, 64 nodes, 128 authority updates and 64-KiB JSON messages. |
| 115 | The Headscale adapter and stock-client control-plane lifecycle have passed isolated |
| 116 | end-to-end verification, including unsigned-peer filtering, authenticated rotation, |
| 117 | authority-key removal, persistence, owner authorization, outage rejection and disablement. |
| 118 | This is not deployed tailnet protection, data-plane qualification or a production security audit. |
| 119 | Build with `tools/build-tkad.sh`; see [`cmd/tkad/README.md`](cmd/tkad/README.md) and |
| 120 | [`integration/headscale/README.md`](integration/headscale/README.md) before running. |
| 121 | |
| 122 | See [`docs/design/tailnet-lock.md`](docs/design/tailnet-lock.md) for the implementation limits, |
| 123 | verification plan, and remaining stages. |
| 124 | |
| 125 | ## License |
| 126 | |
| 127 | Apache-2.0. See [LICENSE](LICENSE). |
| 128 | |
| 129 | ## Human-Directed Agentic Engineering |
| 130 | |
| 131 | Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, |
| 132 | architecture, constraints, acceptance criteria, and stopping points; agents implement, |
| 133 | execute checks, diagnose failures, and revise within those boundaries. Human review |
| 134 | retains responsibility for claims, acceptance, and release decisions. |
| 135 | |
| 136 | For the documented method and a systems-software case study, see Gregory M. Kurtzer, |
| 137 | *Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed |
| 138 | Agentic Engineering* (2026), https://doi.org/10.5281/zenodo.23682548. |