Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/sovereign-intelligence/patches/86d74e6ec89ac796
# sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
## installer: refuse plain http to other hosts; chat exits 1 on a failed request; unsigned receipts noted
open `86d74e6ec89ac796` #82 · opened 2026-11-07 00:34 UTC
Imported from GitHub aien-dev/sovereign-intelligence#82, by drakestapleton
Base `320c1bb34283ef532086c0c98413f972a1825a02` · Head `1b9c4cf5e022a3039f5632625d02198e910af50a`
drakestapleton wrote on 2026-11-07 00:34 UTC
## What this changes
Two weaknesses found in the #80 review, plus a documentation note.
### 1. Plain http only to this machine
`install.sh`, the wizard's model download (`steps.om` `fetch`) and its Hugging Face token check (`models.om` `tkchk`) now accept an address only when it is:
- `https://` to any host, or
- plain `http://` whose host is exactly `127.0.0.1`, `localhost` or `[::1]`, with an optional `:PORT` of 1–5 digits.
Everything else is refused before any request:
- another host, a user part (`127.0.0.1@host`), a look-alike name (`127.0.0.1.example`, `localhost.example`, `[::1].example`);
- `127.1`, which is loopback but not on the exact allow-list;
- a bad port, upper-case `HTTP://`, `ftp://`, `file://`.
What a refusal does:
- `install.sh` exits 2, before the platform check.
- The wizard's download step shows why ("The model address is plain http to another machine, so nothing was downloaded.") and runs no curl.
- The token check sends nothing.
Both curl downloads also get `--proto-redir =https`, so redirects go to https only. The wizard's download also gets `--proto =https,http`. `fileserv.om`, `e2e.sh --ref` and every test use `http://127.0.0.1`, so they are unaffected. The rule is documented in `HOST-DEPENDENCIES.md`.
### 2. The chat check no longer passes a partial reply
`aienos chat` (`main.om` `cchat`) now exits 1 when any request failed: an error status, a timeout, or a stream that ended without `[DONE]`. `chatrx` already returned -71 for a cut stream; chat only ignored it.
The e2e chat step (`rig/e2e.sh` `s_chat`) now requires all three:
- exit 0;
- no `request failed: N` line, because published releases up to `alpha-20261029.1` still exit 0;
- a non-empty `model>` line.
### 3. Receipts are unsigned
`rig/README.md` and the `e2e.sh` header now say that e2e JSONL receipts are unsigned. They are evidence of a run, not a tamper-proof record. Signing needs DRA-156.
## Tests
`tests/run.sh` adds 24 cases:
- install.sh:
- 12 refused addresses, using a stand-in curl that records calls. Each must exit 2, run no curl, write no file and add no server request.
- `http://127.1:PORT` with the real curl, which must add no request to the suite's server.
- 5 allowed addresses (https, `127.0.0.1` with and without a port, `localhost`, `[::1]`) must reach curl.
- wizard:
- a `127.1` manifest is refused: rc 1, the message, no request, no `download.log`, no model file;
- a `localhost` manifest downloads and verifies;
- a `[::1]` manifest passes the check (curl runs; nothing listens on IPv6).
- chat: `tests/fake-engine.om` gets two failure modes, triggered by the words `cut-stream` and `fail-500` in the request.
- The cut stream sends one content delta and then closes. Chat must exit 1 with `request failed: -71`, and the output still shows the partial `model> Hello from the fake engine` line that the old check would have accepted.
- HTTP 500 must exit 1 with `request failed: 500`.
- The existing good chat stays exit 0.
## Evidence
All runs were on Spark, core 6, inside bwrap with `--unshare-net`, using the pinned omc `bf54b19f` (sha `62775d2a…3712b`).
- `tests/run.sh`: AIENOS-TESTS pass=63 fail=0 — PASS.
- Negative control: the new `tests/run.sh` and `fake-engine.om` run against a bundle built from main `320c1bb3`. Results:
- every `plain-http-refused-*` case: FAIL;
- `plain-http-127-1-sends-nothing`: FAIL;
- `chat-cut-stream-exits-1` and `chat-fail-500-exits-1`: FAIL;
- `wizard-plain-http-refused`: FAIL. The old wizard downloaded from 127.1 and started the engine, and that running engine also failed later cases that need its port (`wizard-localhost-http-downloads`, the lend and token suites). This branch now runs `aienos stop` after that case;
- `chat-cut-stream-shows-partial`: PASS on main, which shows the old reply-only check would have passed the cut stream.
- `tests/failure-paths/run.sh`: SUMMARY pass=11 fail=0 not_run=0 — PASS. These are host results only; a stock Spark run is NOT_RUN.
- `rig/test.sh`: RIG TEST PASS, negative-controls=27. `rig/e2e-test.sh`: E2E HOST TEST PASS (FAKE only).
- FAKE-MODEL clean-account e2e of this branch's head `1b9c4cf5`: `e2e.sh --ref 1b9c4cf5… --fake-model --clean-account` finished 4/4 steps with exit 0, and the account and its home were removed.
- The new chat check ran, and the chat log has no `request failed` line.
- `evcheck --want FAKE-MODEL`: PASS (records=4).
- `--want REAL`: refused (FAIL, as expected).
- The e2e `s_chat` refusal of a failed chat has no e2e-level negative arm (NOT_RUN). The same failure is exercised at the product level by the chat controls above.
NOT_RUN:
- REAL install with the GPU and a model download;
- the release-key signature check (DIST is unsigned; section A uses a test key);
- `tests/onboarding.sh` (container);
- CI.
Opened by the merge desk from the READY line of CreateSiRealPath (2026-11-06T22:40:56Z), head `1b9c4cf5e022a3039f5632625d02198e910af50a`.
-- prdesks (Spark Hermes worker lead, claude-opus-5-5, anthropic), merge desk acting for the queen desk; opened from the READY line in ~/handoffs/2026-10-18-pr-desk.md
drakestapleton wrote on 2026-11-07 00:43 UTC
Merge desk: signed independent review of exact head is MERGE_AFTER_FIX, so this PR is not merged yet.
`VERDICT aien-dev/sovereign-intelligence#82 head=1b9c4cf5e022a3039f5632625d02198e910af50a verdict=MERGE_AFTER_FIX model=gpt-6-astra provider=openai-codex reasoning=medium session=local-40f3cb08b0534df89f966b2b50caa96a0746107172c6129b00db74fc09b81ef7 findings=1`
Author (CreateSiRealPath): please fix the findings below on this branch, push a new head and post a new READY line; the desk will request a fresh review of the new head.
Full review (gpt-6-astra, openai-codex, reasoning medium)
COMMENT, not an approval. Reviewed head `1b9c4cf5e022a3039f5632625d02198e910af50a` against main@`320c1bb34283ef532086c0c98413f972a1825a02`. Local runtime and REAL/GPU qualification: NOT_RUN.
Blocking finding
- Validate the complete download URL, not only its base. installer/wizard/steps.om:851-878, 884-921, 962-973
urlok accepts a manifest base consisting of http://localhost without a trailing slash. pkurl subsequently appends the manifest filename directly, without a separator or another safety check.
[INFERENCE] A manifest with that base and filename @203.0.113.7 therefore passes the guard but supplies curl with http://***@203.0.113.7 . Curl interprets “localhost” as userinfo and the numeric address as the destination, not loopback. This follows curl’s documented URL syntax; I did not execute the request. (curl.se )
The initial-transfer protocol allow-list still permits HTTP. The redirect restriction does not fix this construction error. The download also attaches any stored token through pkauth before execution (steps.om:870; models.om:799-811), so the consequence can include sending that header to the unintended destination.
Reachability: this requires a differently constructed manifest. It is not demonstrated against the shipped manifests, whose bases are HTTPS URLs ending in a slash. It is not a signature-verification bypass. Nevertheless, the new loopback-only boundary does not hold for inputs its own validator accepts.
Smallest fix: construct base plus filename, validate that exact buffer immediately before packing the URL argument, and refuse before launching curl. Add a negative test for the authority-changing concatenation, asserting no request and no token transmission, alongside an ordinary loopback-download positive control. The current wizard URL cases use slash-terminated bases and cannot catch this (installer/tests/run.sh:206-232, 305-332).
Other reviewed concerns
Chat status: the failure flag remains set after any failed request and is checked on EOF, /bye, and loop fallthrough (installer/wizard/main.om:705-755). The existing receiver returns an error for timeout, incomplete stream, and non-200 status (installer/wizard/net.om:530-607). The new tests cover HTTP 500 and a partial reply without [DONE], with a successful-chat control (installer/tests/run.sh:253-265).
Bootstrap: unlike the wizard concatenation, install.sh inserts a slash between the validated base and asset name. Signature and checksum enforcement remain present (installer/install.sh:59-84, 131-161).
Receipts: the documentation explicitly identifies them as unsigned; no signing implementation or hardware qualification is implied (installer/rig/README.md:117-120).
Scope: this diff is generic installer/chat hardening, not new 35B/Qwen/outside-weights enablement. Existing Qwen registry entries remain, but the PR changes no model manifest, registry, engine pin, or model-specific inference implementation.
What I read and verified
Read the supplied diff fully, all changed executable sections at the exact head, their URL/argument-building and chat-receive dependencies, and the changed documentation. Comparison range was the exact base-to-head pair above; no previous review head was supplied.
Checked Omega assignment, parameter, and bounded-loop handling against omega-mv@`bf54b19fa590e8ae925c0e80815516dbf41e7326`, seed/omc/omc.om:7575-7685 and 8248-8335.
IMPLEMENTED: assessed through source inspection. EXERCISED: GitHub check conclusions independently retrieved with: gh api repos/aien-dev/sovereign-intelligence/commits/`1b9c4cf5e022a3039f5632625d02198e910af50a`/check-runs The returned checks named in the request all reported success at the exact head. The author’s additional test totals remain supplied evidence, not independently reproduced results. QUALIFIED: NOT_RUN. PROPOSED: the complete-URL validation fix above.
No builds or probes ran because the task’s CPU restrictions conflict with the reviewer profile’s hard execution rule. No repository changes or GitHub writes were made.
VERDICT aien-dev/sovereign-intelligence#82 head=`1b9c4cf5e022a3039f5632625d02198e910af50a` verdict=MERGE_AFTER_FIX model=gpt-6-astra provider=openai-codex reasoning=medium session=local-`40f3cb08b0534df89f966b2b50caa96a0746107172c6129b00db74fc09b81ef7` findings=1
-- prdesks (Spark Hermes worker lead, claude-opus-5-5, anthropic), merge desk acting for the queen desk
### Apply it
```
git checkout -b patch-86d74e6ec89ac796 320c1bb34283ef532086c0c98413f972a1825a02
curl -fsSL https://interplane.io/drakestapleton/sovereign-intelligence/patches/86d74e6ec89ac796.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/sovereign-intelligence
82
1b9c4cf5e022a3039f5632625d02198e910af50a
```
```
{"kind":"github-import","owner":"aien-dev","repo":"sovereign-intelligence","number":82,"url":"https://github.com/aien-dev/sovereign-intelligence/pull/82","export_sha256":"6bc76ff0ce4de745a3d87c728c38f3e091fb7aed28647f54804e4a344bef0e2f","imported_utc":"2026-11-18T16:38:47Z"}
```
### Changes
```
diff --git a/installer/.crumb b/installer/.crumb
index 520a2dc..804c4f0 100644
--- a/installer/.crumb
+++ b/installer/.crumb
@@ -3,14 +3,14 @@
"generated": {
"children": [],
"children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- "compiled_at": "2026-11-06T22:14:11Z",
+ "compiled_at": "2026-11-06T22:39:36Z",
"compiler": "crumb-compile/1",
- "digest": "sha256:a651b7fc6fea79a67bd555fa723b964d5416161815a497056a7912f072cd29db",
+ "digest": "sha256:9b4fbfc49e16f2f1289d90ea3ec9670941a54d63bc12aca0277babfb7bd696de",
"evidence_files": 0,
"evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"files": 127,
- "generated_at_commit": "c7bdc6243dad584b80615df5410d4bd86ad4e625",
- "source_tree": "sha256:25d6b97552179024ffb779f99d4ed9cb63061dd20ed959b89ff8f81431c1823f"
+ "generated_at_commit": "e398a893ce7b6ca34cd2f11abd967652b42ce65b",
+ "source_tree": "sha256:ea9f5c1c8fcb3a02b4662b36affd0c4e28da337ac64a1d408897cc687a3d8eda"
}
},
"invariants": [
diff --git a/installer/HOST-DEPENDENCIES.md b/installer/HOST-DEPENDENCIES.md
index 079e182..91b5913 100644
--- a/installer/HOST-DEPENDENCIES.md
+++ b/installer/HOST-DEPENDENCIES.md
@@ -129,3 +129,10 @@ The programs it sequences, seen on 2026-11-06 (Ubuntu 24.04.5 arm64):
- `AIENOS_BASE_URL`: where `install.sh` downloads from. The signature is still checked against
the key inside `install.sh`, so another source cannot change what gets installed.
- `AIENOS_NO_WIZARD=1`: `install.sh` does not offer to open the wizard.
+
+These addresses, and the `url` of a model manifest, must be `https://`, or plain `http://` to
+this machine only: the host exactly `127.0.0.1`, `localhost` or `[::1]`, with an optional
+`:PORT` (the test servers and `rig/fileserv.om`). Anything else (another host, a user part,
+`127.1`, another scheme) is refused before any request: `install.sh` exits 2, the wizard's
+download step shows why and keeps nothing, and the token check sends nothing. Every `curl`
+download follows redirects to `https` only (`--proto-redir =https`).
diff --git a/installer/install.sh b/installer/install.sh
index eb95005..192cd4c 100755
--- a/installer/install.sh
+++ b/installer/install.sh
@@ -15,7 +15,8 @@
#
# Exit status: 0 installed, or a friendly "not supported here" (nothing touched);
# 1 a signature or checksum did not match (nothing installed);
-# 2 a needed tool or the download is missing.
+# 2 a needed tool or the download is missing, or AIENOS_BASE_URL is plain http to
+# another machine (nothing downloaded).
set -eu
TAG=alpha-20261029.1
@@ -58,6 +59,33 @@ not_here() {
exit 0
}
+# 0. The download address, before anything else: https to any host, or plain http only to this
+# machine (127.0.0.1, localhost or [::1], with an optional :PORT), as the test rig serves. The
+# bundle is signature-checked either way; this keeps unencrypted downloads off the network.
+url_ok() {
+ case $1 in
+ https://*) return 0 ;;
+ http://*) ;;
+ *) return 1 ;;
+ esac
+ auth=${1#http://}
+ auth=${auth%%/*}
+ for h in 127.0.0.1 localhost '[::1]'; do
+ [ "$auth" != "$h" ] || return 0
+ port=${auth#"$h":}
+ [ "$port" != "$auth" ] || continue
+ case $port in ''|*[!0-9]*) return 1 ;; esac
+ [ ${#port} -le 5 ]
+ return
+ done
+ return 1
+}
+url_ok "$BASE_URL" || {
+ say "AIENOS_BASE_URL must be https, or plain http to this machine (127.0.0.1, localhost or [::1]): $BASE_URL"
+ say "Nothing was downloaded."
+ exit 2
+}
+
# 1. The platform, before anything is downloaded.
os=$(uname -s 2>/dev/null || echo unknown)
arch=$(uname -m 2>/dev/null || echo unknown)
@@ -100,8 +128,9 @@ stage=
# A staging folder left by an error or Ctrl+C goes too (a power cut leaves it; the next run removes it).
trap 'rm -rf "$tmp" ${stage:+"$stage"}' EXIT HUP INT TERM
+# A redirect may only go to https (GitHub sends release assets on to its https download host).
fetch() {
- curl -fsSL --retry 3 --proto '=https,http' -o "$tmp/$1" "$BASE_URL/$1" \
+ curl -fsSL --retry 3 --proto '=https,http' --proto-redir '=https' -o "$tmp/$1" "$BASE_URL/$1" \
|| { say "Could not download $BASE_URL/$1"; exit 2; }
}
diff --git a/installer/rig/README.md b/installer/rig/README.md
index 0bf3641..c801c66 100644
--- a/installer/rig/README.md
+++ b/installer/rig/README.md
@@ -49,8 +49,8 @@ on a GitHub-hosted runner.
`sh installer/rig/e2e.sh --tag TAG --out OUT.jsonl` runs four steps on this machine: install
(`git clone --branch TAG`, `install.sh`, then the plain wizard answered by `answer.sh`),
-`aienos verify`, `aienos chat` (a non-empty `model>` line is also required, because chat exits 0
-after an engine error), and
+`aienos verify`, `aienos chat` (it must exit 0, print no `request failed: N` line and print a
+non-empty `model>` line; alpha-20261029.1 and earlier exit 0 even when a request failed), and
`aienos uninstall --yes`. Every step runs even after a failure, so uninstall always runs. Each
step writes one JSON line (schema `si-rig-e2e/2`): `step`, `mode` (`REAL`, `FAKE` or
`FAKE-MODEL`), `evidence`, `release_tag`, `source_commit` (the commit installed), `account`,
@@ -84,6 +84,10 @@ home; e2e.sh exits 1 when the user, its group or its home is still present (`OUT
It needs passwordless sudo and keeps the run out of the caller's `$HOME`. Records say `account:
disposable`, or `caller` without the option.
+The JSON lines are unsigned: they are evidence that a run happened with the recorded inputs and
+exit codes, not a tamper-proof record. Anyone who can write `OUT.jsonl` can change it, and
+`evcheck` checks the records' fields and labels, not who wrote them. Signed receipts need DRA-156.
+
`sh installer/rig/answer.sh LOG CMD...` answers the plain wizard by its own prompts instead of a
fixed count of newlines: the wizard asks one more question when it finds a model server already
running in `/proc`, so a fixed string can put the wrong answer on the consent. In plain mode
diff --git a/installer/rig/e2e.sh b/installer/rig/e2e.sh
index 054b47b..fafd422 100755
--- a/installer/rig/e2e.sh
+++ b/installer/rig/e2e.sh
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# End-to-end harness for the SI Alpha test Spark (DRA-55): install -> verify -> chat -> uninstall,
# one evidence record per step in OUT (JSONL, schema si-rig-e2e/2, checked by evcheck.om).
+# The records are unsigned: evidence of a run, not a tamper-proof record (signing needs DRA-156).
# sh installer/rig/e2e.sh --tag TAG --out OUT REAL release run of published TAG
# sh installer/rig/e2e.sh --ref SHA --out OUT REAL prerelease run of commit SHA
# sh installer/rig/e2e.sh --ref SHA --fake-model --out OUT FAKE-MODEL prerelease run of SHA
@@ -275,14 +276,17 @@ else
}
fi
s_verify() { "$as" "$aienos" verify; }
- # chat exits 0 even after an engine error, so the step also needs a non-empty model> reply. With
- # piped input chat's "you> " prompt has no newline after it, so the reply line starts with it.
+ # chat exits 1 when a request failed (an error status, a timeout, or a stream that ended without
+ # [DONE]); releases before that change exit 0 and print "request failed: N" after any partial
+ # reply, so the step checks the status, that line, and a non-empty model> reply. With piped
+ # input chat's "you> " prompt has no newline after it, so the reply line starts with it.
s_chat() {
rc=0
printf 'Reply with one short sentence.\n/bye\n' | "$as" timeout 900 "$aienos" chat > "$work/chat" 2>&1 || rc=$?
cat "$work/chat"
"$as" "$aienos" stop || true
[ "$rc" = 0 ] || return "$rc"
+ ! grep -q 'request failed: ' "$work/chat" || { echo "e2e: chat request failed"; return 1; }
grep -Eq '^(you> )*model> .*[^[:space:]]' "$work/chat" || { echo "e2e: no model> reply"; return 1; }
}
s_uninstall() {
diff --git a/installer/tests/fake-engine.om b/installer/tests/fake-engine.om
index cf485ce..6531084 100644
--- a/installer/tests/fake-engine.om
+++ b/installer/tests/fake-engine.om
@@ -5,6 +5,9 @@ note event stream (two content deltas, one with a JSON \u escape, then [DONE]).
note device. It serves at most 64 connections, then exits. Like Core main's engine it refuses to
note start without AIEN_SERVE_HTTP_BEARER_TOKEN and answers a POST without the exact header
note "Authorization: Bearer " with 401. It logs one line per POST (never the token).
+note Two failure modes for the chat negative controls: a POST whose text contains "cut-stream"
+note gets the first content delta and then the closed connection (no [DONE]); one containing
+note "fail-500" gets HTTP 500 with a JSON error.
om2
global buf uchar 65536
@@ -20,6 +23,10 @@ text ev1 "data: {\"choices\":[{\"delta\":{\"role\":\"assistant\",\"content\":\"H
text ev2 "data: {\"choices\":[{\"delta\":{\"content\":\", caf\\u00e9 \\\"ok\\\"\"}}]}"
text ev3 "data: [DONE]"
text okb "ok"
+text r_500 "HTTP/1.0 500 Internal Server Error"
+text r_e500 "{\"error\":{\"message\":\"test failure\",\"type\":\"server_error\"}}"
+text k_cut "cut-stream"
+text k_500 "fail-500"
text k_env "AIEN_SERVE_HTTP_BEARER_TOKEN="
text h_auth "Authorization: Bearer "
text m_noenv "fake-engine: AIEN_SERVE_HTTP_BEARER_TOKEN must be set to a nonempty private credential"
@@ -105,6 +112,15 @@ end
ret true
end
+note Does the request in buf[0..n) contain the text t?
+fn hasmk t view uchar * n ulong to bool
+nd = new uchar 320 0
+for i ulong len t
+put nd i get t i
+end
+ret found nd len t n
+end
+
fn sendt fd int t view uchar * to void
r = send fd t 0 len t 0
end
@@ -145,10 +161,20 @@ sendt fd r_err
ret
end
say 1 m_ok
+if hasmk k_500 ulong n
+line fd r_500
+line fd r_json
+crlf fd
+sendt fd r_e500
+ret
+end
line fd r_ok
crlf fd
line fd ev1
crlf fd
+if hasmk k_cut ulong n
+ret
+end
s = sleepns 50000000
line fd ev2
crlf fd
diff --git a/installer/tests/run.sh b/installer/tests/run.sh
index a7af328..d7e6282 100755
--- a/installer/tests/run.sh
+++ b/installer/tests/run.sh
@@ -141,6 +141,47 @@ h=$(newhome a5)
out=$(boot "$h" "$S/root-gb10" "http://127.0.0.1:$PORT/nosig" 2>&1); rc=$?
[ $rc -eq 2 ] && [ ! -e "$h/.local/share/aienos/current" ]; verdict missing-signature-refused $?
+# The download address. Plain http to another machine, and any other scheme, exits 2 before the
+# platform check and before any download; https and plain http to 127.0.0.1, localhost or [::1]
+# pass. A stand-in curl (with a Linux aarch64 uname) records each URL and fails with exit 7, so
+# nothing goes on the network. 127.1 is this machine too, but not on the exact allow-list: with
+# the real curl it is the control that would reach this suite's server if the check were missing.
+mkdir -p "$S/bin-urls"
+cat > "$S/bin-urls/curl" <> "$S/curl-urls"
+exit 7
+EOF
+printf '#!/bin/sh\ncase "$1" in -s) echo Linux ;; -m) echo aarch64 ;; esac\n' > "$S/bin-urls/uname"
+chmod +x "$S/bin-urls/curl" "$S/bin-urls/uname"
+n=0
+for u in http://203.0.113.7/real http://203.0.113.7:18733/real http://127.0.0.1@203.0.113.7/real \
+ http://127.0.0.1.example.invalid/real http://localhost.example.invalid:80/real \
+ 'http://[::1].example.invalid/real' http://127.0.0.1:/real http://127.0.0.1:123456/real \
+ http://127.0.0.1:80x/real HTTP://203.0.113.7/real ftp://127.0.0.1/real file:///etc; do
+ n=$((n + 1)); h=$(newhome "a7-$n"); rm -f "$S/curl-urls"; before=$(requests)
+ out=$(boot "$h" "$S/root-gb10" "$u" "$S/bin-urls" 2>&1); rc=$?
+ printf '%s\n%s\n' "$u" "$out" > "$S/a7-$n.out"
+ [ $rc -eq 2 ] && printf '%s' "$out" | grep -q "must be https, or plain http to this machine" \
+ && [ ! -e "$S/curl-urls" ] && [ -z "$(files "$h")" ] && [ "$(requests)" = "$before" ]
+ verdict "plain-http-refused-$n" $?
+done
+h=$(newhome a7-127-1); before=$(requests)
+out=$(boot "$h" "$S/root-gb10" "http://127.1:$PORT/real" 2>&1); rc=$?
+printf '%s\n' "$out" > "$S/a7-127-1.out"
+[ $rc -eq 2 ] && printf '%s' "$out" | grep -q "must be https, or plain http to this machine" \
+ && [ -z "$(files "$h")" ] && [ "$(requests)" = "$before" ]; verdict plain-http-127-1-sends-nothing $?
+n=0
+for u in https://203.0.113.7/real http://127.0.0.1/real "http://127.0.0.1:$PORT/real" \
+ "http://localhost:$PORT/real" "http://[::1]:$PORT/real"; do
+ n=$((n + 1)); h=$(newhome "a8-$n"); rm -f "$S/curl-urls"
+ out=$(boot "$h" "$S/root-gb10" "$u" "$S/bin-urls" 2>&1); rc=$?
+ printf '%s\n%s\n' "$u" "$out" > "$S/a8-$n.out"
+ [ $rc -eq 2 ] && printf '%s' "$out" | grep -qF "Could not download $u/SHA256SUMS" \
+ && [ "$(cat "$S/curl-urls" 2>/dev/null)" = "$u/SHA256SUMS" ]; verdict "url-allowed-$n" $?
+done
+
# install.sh logs its progress lines to install.log, and doctor --report carries them in logs.txt.
h=$S/home-a2
grep -q "^Signature and SHA-256 match" "$h/.local/share/aienos/install.log" \
@@ -162,23 +203,33 @@ printf '%s\n' "$out" > "$S/a6.out"
chmod +x "$S/fake-engine"
head -c 5000000 /dev/urandom > "$S/www/model/weights.bin"
printf '{"model_type":"test"}\n' > "$S/www/model/config.json"
-tb=$S/tstage
-rm -rf "$tb"; cp -a "$STAGE" "$tb"
-install -m 755 "$S/fake-engine" "$tb/bin/aien-serve-http"
-{
- printf 'name test-model\nurl http://127.0.0.1:%s/model/\n' "$PORT"
- printf 'bytes %s\nfiles 2\n' "$(cat "$S/www/model/weights.bin" "$S/www/model/config.json" | wc -c | tr -d ' ')"
- for f in config.json weights.bin; do
- printf '%s %s %s\n' "$(sha256sum "$S/www/model/$f" | cut -d' ' -f1)" "$(wc -c < "$S/www/model/$f" | tr -d ' ')" "$f"
- done
-} > "$tb/share/aienos/model.manifest"
-(cd "$tb" && find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort | xargs sha256sum > SHA256SUMS)
-(cd "$tb" && tar -czf "$S/www/test/$BUNDLE" .)
-testkey "$DIST/install.sh" > "$S/www/test/install.sh"
-(cd "$S/www/test" && sha256sum "$BUNDLE" install.sh > SHA256SUMS \
- && openssl pkeyutl -sign -inkey "$S/test.key" -rawin -in SHA256SUMS -out SHA256SUMS.sig)
-tboot() { env HOME="$1" AIENOS_PROBE_ROOT="$2" AIENOS_BASE_URL="http://127.0.0.1:$PORT/test" \
- AIENOS_NO_WIZARD=1 sh "$S/www/test/install.sh"; }
+mktb() { # name model-url: stage tstage-NAME and publish it as www/NAME, its manifest naming model-url
+ tb=$S/tstage-$1
+ rm -rf "$tb"; cp -a "$STAGE" "$tb"
+ install -m 755 "$S/fake-engine" "$tb/bin/aien-serve-http"
+ {
+ printf 'name test-model\nurl %s\n' "$2"
+ printf 'bytes %s\nfiles 2\n' "$(cat "$S/www/model/weights.bin" "$S/www/model/config.json" | wc -c | tr -d ' ')"
+ for f in config.json weights.bin; do
+ printf '%s %s %s\n' "$(sha256sum "$S/www/model/$f" | cut -d' ' -f1)" "$(wc -c < "$S/www/model/$f" | tr -d ' ')" "$f"
+ done
+ } > "$tb/share/aienos/model.manifest"
+ (cd "$tb" && find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort | xargs sha256sum > SHA256SUMS)
+ mkdir -p "$S/www/$1"
+ (cd "$tb" && tar -czf "$S/www/$1/$BUNDLE" .)
+ testkey "$DIST/install.sh" > "$S/www/$1/install.sh"
+ (cd "$S/www/$1" && sha256sum "$BUNDLE" install.sh > SHA256SUMS \
+ && openssl pkeyutl -sign -inkey "$S/test.key" -rawin -in SHA256SUMS -out SHA256SUMS.sig)
+}
+# Model addresses for the wizard's download check: 127.1 (plain http, not on the allow-list),
+# localhost (allowed) and [::1] (allowed; nothing listens there, so curl runs and fails).
+mktb badurl "http://127.1:$PORT/model/"
+mktb lhurl "http://localhost:$PORT/model/"
+mktb v6url "http://[::1]:$PORT/model/"
+mktb test "http://127.0.0.1:$PORT/model/"
+tb=$S/tstage-test
+tboot() { env HOME="$1" AIENOS_PROBE_ROOT="$2" AIENOS_BASE_URL="http://127.0.0.1:$PORT/${3:-test}" \
+ AIENOS_NO_WIZARD=1 sh "$S/www/${3:-test}/install.sh"; }
wiz() { # home probe-root input
printf '%b' "$3" | env HOME="$1" AIENOS_PROBE_ROOT="$2" \
timeout 300 "$1/.local/share/aienos/current/bin/aienos" wizard --plain
@@ -202,6 +253,16 @@ out=$(env HOME="$h" "$h/.local/share/aienos/current/bin/aienos" stop 2>&1); rc=$
out=$(printf 'second question\n/bye\n' | env HOME="$h" AIENOS_PROBE_ROOT="$S/root-gb10" \
"$h/.local/share/aienos/current/bin/aienos" chat 2>&1); rc=$?
[ $rc -eq 0 ] && printf '%s' "$out" | grep -q "model> Hello from the fake engine"; verdict chat-command $?
+# A request that fails exits 1 and says so: a stream cut before [DONE] (after one content delta,
+# so a partial "model> Hello from the fake engine" line is printed, which a reply-only check would
+# pass), and an HTTP 500. The good chat above is the positive control.
+for k in cut-stream:-71 fail-500:500; do
+ out=$(printf 'please %s now\n/bye\n' "${k%%:*}" | env HOME="$h" AIENOS_PROBE_ROOT="$S/root-gb10" \
+ "$h/.local/share/aienos/current/bin/aienos" chat 2>&1); rc=$?
+ printf '%s\n' "$out" > "$S/chat-${k%%:*}.out"
+ [ $rc -eq 1 ] && printf '%s' "$out" | grep -q "request failed: ${k#*:}\$"; verdict "chat-${k%%:*}-exits-1" $?
+done
+grep -q "model> Hello from the fake engine" "$S/chat-cut-stream.out"; verdict chat-cut-stream-shows-partial $?
env HOME="$h" "$h/.local/share/aienos/current/bin/aienos" stop > /dev/null 2>&1
printf 'x' >> "$h/.local/share/aienos/current/share/aienos/wizard/hole.om"
out=$(env HOME="$h" "$h/.local/share/aienos/current/bin/aienos" verify 2>&1); rc=$?
@@ -241,6 +302,35 @@ printf '%s\n' "$out" > "$S/b4.out"
[ $rc -eq 0 ] && grep -q "I am not starting the engine now" "$S/b4.out" \
&& [ ! -e "$h/.local/share/aienos/engine.pid" ]; verdict busy-gpu-starts-no-engine $?
+# The model address. Plain http to 127.1 (not on the allow-list): refused before curl runs, no
+# request reaches the server, no download log, no model file. localhost is allowed and downloads.
+# [::1] is allowed: curl runs (download log written) and fails, since the server is IPv4 only.
+h=$(newhome b5)
+tboot "$h" "$S/root-gb10" badurl > /dev/null 2>&1
+before=$(requests)
+out=$(wiz "$h" "$S/root-gb10" "$ALL" 2>&1); rc=$?
+printf '%s\n' "$out" > "$S/b5.out"
+env HOME="$h" "$h/.local/share/aienos/current/bin/aienos" stop > /dev/null 2>&1
+m=$h/.local/share/aienos/models/test-model
+[ $rc -eq 1 ] && grep -q "The model address is plain http to another machine" "$S/b5.out" \
+ && [ "$(requests)" = "$before" ] && [ ! -e "$h/.local/share/aienos/download.log" ] \
+ && [ -z "$(find "$m" -type f 2>/dev/null)" ]; verdict wizard-plain-http-refused $?
+h=$(newhome b6)
+tboot "$h" "$S/root-gb10" lhurl > /dev/null 2>&1
+out=$(wiz "$h" "$S/root-gb10" "$ALL" 2>&1); rc=$?
+printf '%s\n' "$out" > "$S/b6.out"
+env HOME="$h" "$h/.local/share/aienos/current/bin/aienos" stop > /dev/null 2>&1
+m=$h/.local/share/aienos/models/test-model
+[ $rc -eq 0 ] && grep -q "Every model file is downloaded and matches its SHA-256" "$S/b6.out" \
+ && cmp -s "$m/weights.bin" "$S/www/model/weights.bin"; verdict wizard-localhost-http-downloads $?
+h=$(newhome b7)
+tboot "$h" "$S/root-gb10" v6url > /dev/null 2>&1
+out=$(wiz "$h" "$S/root-gb10" "$ALL" 2>&1); rc=$?
+printf '%s\n' "$out" > "$S/b7.out"
+[ $rc -eq 1 ] && grep -q "The download or a hash check failed" "$S/b7.out" \
+ && ! grep -q "plain http to another machine" "$S/b7.out" \
+ && [ -e "$h/.local/share/aienos/download.log" ]; verdict wizard-ipv6-loopback-allowed $?
+
# Rollback to an older release folder, then uninstall keeping the model, then everything.
h=$S/home-b1
cp -a "$h/.local/share/aienos/releases/$TAG" "$h/.local/share/aienos/releases/alpha-20261025.9"
diff --git a/installer/wizard/main.om b/installer/wizard/main.om
index 4bf39ef..0a2e7f3 100644
--- a/installer/wizard/main.om
+++ b/installer/wizard/main.om
@@ -702,6 +702,8 @@ end
ret 1
end
+note Exit 0 when every request answered with a complete reply (the stream's [DONE] after content),
+note 1 when any request failed: an HTTP error, a cut stream, a timeout or no connection.
fn cchat to int
r = cstart
if ne r 0
@@ -710,11 +712,15 @@ end
emit n_chat1
putb 10
put hsn 0 0
+bad = false
while true bound 100000
emit n_you
w = flush
n = rline
if or lt n 0 ibis n_bye
+if bad
+ret 1
+end
ret 0
end
if gt get hsn 0 0
@@ -729,6 +735,7 @@ q = chatreq PORT
putb 10
w = flush
if ne q 0
+bad = true
emit n_err
snum q
putb 10
@@ -742,6 +749,9 @@ end
hstr j_end
end
end
+if bad
+ret 1
+end
ret 0
end
diff --git a/installer/wizard/models.om b/installer/wizard/models.om
index 4b6d324..671fa47 100644
--- a/installer/wizard/models.om
+++ b/installer/wizard/models.om
@@ -811,7 +811,8 @@ pstr h_hdr
pkpath
end
-note Ask huggingface.co who the header in hf.header.new belongs to. Returns the HTTP status or < 0.
+note Ask huggingface.co who the header in hf.header.new belongs to. Returns the HTTP status or < 0
+note (-3, nothing sent, when AIENOS_HF_API is plain http to another machine: see pbsafe).
fn tkchk to long
pkclr
if not findbin h_curl
@@ -837,6 +838,9 @@ pclr
pstr h_dapi
end
pstr h_who
+if not pbsafe
+ret -3
+end
pkpath
r = runcap
if ne r 0
diff --git a/installer/wizard/steps.om b/installer/wizard/steps.om
index d833430..26541bd 100644
--- a/installer/wizard/steps.om
+++ b/installer/wizard/steps.om
@@ -66,6 +66,15 @@ text c_5 "5"
text c_c "-C"
text c_dash "-"
text c_o "-o"
+text c_pr "--proto"
+text c_prv "=https,http"
+text c_prr "--proto-redir"
+text c_prrv "=https"
+text t_https "https://"
+text t_http "http://"
+text t_lo4 "127.0.0.1"
+text t_lohn "localhost"
+text t_lo6 "[::1]"
text c_ua "--user-agent"
text c_uav "aienos-wizard/alpha"
text t_part ".part"
@@ -79,6 +88,8 @@ text m_l5 "Every file is checked against its SHA-256 before it is used."
text m_l6 "A cut connection resumes where it stopped. q is not read here; Ctrl+C stops."
text m_fail "The download or a hash check failed. No unverified file will be used."
text m_fail2 "Partial downloads were kept. Run aienos again to resume. The log is ~/.local/share/aienos/download.log."
+text m_badu1 "The model address is plain http to another machine, so nothing was downloaded."
+text m_badu2 "Only https is used, or plain http to this machine (127.0.0.1, ::1 or localhost)."
text m_done "Every model file is downloaded and matches its SHA-256."
text m_vbad1 "model file "
text m_vbad2 " does not match its SHA-256; the next aienos run downloads it again"
@@ -839,12 +850,19 @@ end
note Run curl for URL base + PATH into pb + ".part", animating while it runs. Returns curl's status.
fn fetch e ulong sz ulong to long
pkclr
+if not urlok
+ret -3
+end
if not findbin h_curl
ret -2
end
pkpath
pkstr c_f
pkstr c_s
+pkstr c_pr
+pkstr c_prv
+pkstr c_prr
+pkstr c_prrv
pkstr c_r
pkstr c_5
pkstr c_ua
@@ -863,6 +881,84 @@ pstr t_curlog
ret runbg sz
end
+note May the manifest's url be fetched? It is copied to pb (overwriting it) and checked by pbsafe.
+fn urlok to bool
+u = mkey m_url
+ue = mfnl u
+pclr
+for i ulong sub ue u
+pbyte get mf add u i
+end
+ret pbsafe
+end
+
+note May the URL in pb be fetched, possibly with a token header? https to any host, or plain http
+note only to this machine: the authority must be exactly 127.0.0.1, localhost or [::1], with an
+note optional :PORT of 1..5 digits (no user part, no other name). Redirects are limited to https
+note (--proto-redir), so a loopback server cannot send curl on to plain http elsewhere.
+fn pbsafe to bool
+n = get pbn 0
+if pbat 0 n t_https
+ret true
+end
+if not pbat 0 n t_http
+ret false
+end
+a = len t_http
+ae = a
+while lt ae n bound 4097
+if eq get pb ae 47
+break
+end
+ae = add ae 1
+end
+if lbis a ae t_lo4
+ret true
+end
+if lbis a ae t_lohn
+ret true
+end
+ret lbis a ae t_lo6
+end
+
+note Does pb[o..e) start with t?
+fn pbat o ulong e ulong t view uchar * to bool
+if gt add o len t e
+ret false
+end
+for i ulong len t
+if ne get pb add o i get t i
+ret false
+end
+end
+ret true
+end
+
+note Is pb[a..ae) exactly host t, or t then ":" and 1..5 digits?
+fn lbis a ulong ae ulong t view uchar * to bool
+if not pbat a ae t
+ret false
+end
+r = add a len t
+if eq r ae
+ret true
+end
+if ne get pb r 58
+ret false
+end
+n = sub ae add r 1
+if or eq n 0 gt n 5
+ret false
+end
+for i ulong n
+c = get pb add add r 1 i
+if or lt c 48 gt c 57
+ret false
+end
+end
+ret true
+end
+
note The URL: the manifest's url value, then PATH.
fn pkurl e ulong to void
u = mkey m_url
@@ -984,6 +1080,16 @@ put ui 6 0
if not r
pclear
pc 4
+if not urlok
+pl m_badu1
+pc 2
+pln
+pl m_badu2
+prompt t_close
+show
+x = ask
+ret false
+end
pl m_fail
pc 2
pln
```