From 32692030fb476d8b9ec23ada5df5a2769f03b142 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 4 Oct 2026 01:10:21 -0400 Subject: [PATCH] =?UTF-8?q?install.sh:=20enrollment=20token=20via=20header?= =?UTF-8?q?=20file=20too=20=E2=80=94=20it=20was=20on=20curl=20argv=20despi?= =?UTF-8?q?te=20the=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3c6afff..c82aafa 100644 --- a/install.sh +++ b/install.sh @@ -442,12 +442,15 @@ do_fresh_enroll() { BODY="$(jq -nc --arg id "$NODE_ID" --arg n "${NODE_NAME:-$NODE_ID}" \ --argjson lat "${NODE_LAT:-0}" --argjson lon "${NODE_LON:-0}" \ '{node_id:$id,name:$n,lat:$lat,lon:$lon}')" - # Token goes in a header from a shell variable — never on a process command - # line, never echoed. + # Token goes in a 0600 header file — never on a process command line (curl's + # argv is visible in `ps`; CISO condition, server-26#61), never echoed. + local _ehdr; _ehdr="$(mktemp)"; chmod 600 "$_ehdr" + printf 'X-Enrollment-Token: %s\n' "$ENROLLMENT_TOKEN" > "$_ehdr" if ! RESP="$(curl -fsS -X POST "$C2_URL/nodes/enroll" \ -H "Content-Type: application/json" \ - -H "X-Enrollment-Token: $ENROLLMENT_TOKEN" \ + -H "@$_ehdr" \ --data "$BODY" 2>&1)"; then + rm -f "$_ehdr" case "$RESP" in *403*) die "enroll refused (403): node '$NODE_ID' is already approved on C2, and this machine has no configs/pickup_secret to collect its key with. A token @@ -461,6 +464,7 @@ do_fresh_enroll() { *) die "enroll failed: $RESP" ;; esac fi + rm -f "$_ehdr" PICKUP="$(printf '%s' "$RESP" | jq -r '.pickup_secret')" STATUS="$(printf '%s' "$RESP" | jq -r '.approval_status')" [ -n "$PICKUP" ] && [ "$PICKUP" != null ] || die "enroll returned no pickup_secret: $RESP"