From dedfb9188cafd84dadb69fae9e91eff176a9b486 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 15 Nov 2026 11:10:43 -0600 Subject: [PATCH] Fix security finding acf_d908322d5e74752a52568ec815fc1d4e --- CONTRIBUTORS.md | 1 + Makefile | 25 ++++++++++---- argus.lock | 4 --- tests/aienos_lock_source/run.sh | 2 +- tests/argus_lock_validation.sh | 61 +++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 tests/argus_lock_validation.sh diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index aa4a7bd38..00ddd1a67 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,6 +7,7 @@ The current development method is [Human-Directed Agentic Engineering (HDAE)](RE | Model | What it did | |---|---| +| OpenAI Codex | Made `argus.lock` a strict single-commit file, validated it as data before GNU make derives ARGUS paths or recipes, and added static regression coverage for malformed and shell-bearing lock content. | | Grok 4.7 (via Cursor Agent) | Merged main `fd3751b31` (#1020, carrying #1045 and #1050) into #1052. The only conflict was the generated root `.crumb` (child `last_commit` stamps, the `tests` digest, and the root digest). Recompiled with the crumb.lock tool (`d0f0b95d`); `crumb verify .` current. The #525/#962 pins were left as committed: `src/checker2/c2_check.c`, `src/compiler/osc_ir.c` and `src/compiler/osc_ir.h` still hash to the SHA-256s in `ACCEPTED`. | | Claude Opus 5.5 (via omp) | #1020 (actions/cache-4.3.0 ->6.1.0): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | | Claude Opus 5.5 (via omp) | #1018 (actions/upload-artifact-4 ->7): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | diff --git a/Makefile b/Makefile index 7e1426b3b..7fd47bd47 100644 --- a/Makefile +++ b/Makefile @@ -1427,8 +1427,15 @@ test-typed-results: $(RX_TYPED_TEST) # same library as the default targets (with no observer set it # costs one NULL check per admin operation), RX_ARGUS=0 included. ARGUS_REPO ?= ../aienos-argus -ARGUS_COMMIT ?= $(shell head -n 1 argus.lock) -ARGUS_SHORT = $(shell echo $(ARGUS_COMMIT) | cut -c1-7) +# The lock is code-adjacent input: parse it as data and expose only validated +# lowercase commit text to recipes. The second field is derived in the same +# parser so no lock content is ever interpolated into another shell command. +override ARGUS_LOCK_FIELDS := $(shell LC_ALL=C awk 'NR == 1 && length($$0) == 40 && $$0 ~ /^[0-9a-f]+$$/ { commit = $$0; next } { invalid = 1 } END { if (!invalid && NR == 1) printf "%s %s\n", commit, substr(commit, 1, 7); else exit 1 }' argus.lock 2>/dev/null) +ifneq ($(words $(ARGUS_LOCK_FIELDS)),2) +$(error argus.lock must contain exactly one lowercase 40-hex commit) +endif +override ARGUS_COMMIT := $(word 1,$(ARGUS_LOCK_FIELDS)) +override ARGUS_SHORT := $(word 2,$(ARGUS_LOCK_FIELDS)) ARGUS_SRC = $(OUT_DIR)/argus-src/$(ARGUS_SHORT)/native/argus ARGUS_STAMP = $(OUT_DIR)/argus-src/$(ARGUS_SHORT)/.extracted ARGUS_LIB_SRCS = $(addprefix $(ARGUS_SRC)/,argus_event.c argus_ring.c argus_core.c argus_detect.c) @@ -1443,11 +1450,17 @@ ARGUS_CFLAGS = $(CFLAGS) -DRX_ARGUS=$(RX_ARGUS) -I$(ARGUS_SRC) ARGUS_STREAMS ?= $(HOME)/workspace/argus-runtime-streams ARGUS_RUN_ID = $(shell git rev-parse --short HEAD 2>/dev/null)-argus$(ARGUS_SHORT) +.PHONY: check-argus-lock test-argus-lock +check-argus-lock: + @: + +test-argus-lock: + bash tests/argus_lock_validation.sh + $(ARGUS_STAMP): - @test -n "$(ARGUS_COMMIT)" || { echo "argus.lock is empty"; exit 1; } - mkdir -p $(OUT_DIR)/argus-src/$(ARGUS_SHORT) - git -C $(ARGUS_REPO) archive $(ARGUS_COMMIT) native/argus | tar -x -C $(OUT_DIR)/argus-src/$(ARGUS_SHORT) - touch $@ + mkdir -p "$(OUT_DIR)/argus-src/$(ARGUS_SHORT)" + git -C "$(ARGUS_REPO)" archive "$(ARGUS_COMMIT)" -- native/argus | tar -x -C "$(OUT_DIR)/argus-src/$(ARGUS_SHORT)" + touch "$@" $(ARGUS_LIB_SRCS): $(ARGUS_STAMP) diff --git a/argus.lock b/argus.lock index a9b8350ac..99e018202 100644 --- a/argus.lock +++ b/argus.lock @@ -1,5 +1 @@ b375dcaa2887d53cda407d773c2e4e489a0b1365 -# aien-dev/aienux native/argus (ARGUS-0, ABI v1.1), branch feat/argus-0 (integrator round 3 head). -# argus_abi.h is byte-identical at 398cfb9, 03b9f06, be2814d and b375dca (sha256 5ff168ea...). -# On origin (origin/feat/argus-0, origin/feat/argus-1-spec contain it). The branch head a64bc55 -# differs from b375dca in native/argus only by docs (ARGUS0_GATES.md, HOSTILE_REVIEW.md). diff --git a/tests/aienos_lock_source/run.sh b/tests/aienos_lock_source/run.sh index 683ac482d..e4e1033cd 100644 --- a/tests/aienos_lock_source/run.sh +++ b/tests/aienos_lock_source/run.sh @@ -116,7 +116,7 @@ check "dirty checkout of the locked commit: exit 1" '[ "$(rc env AIENOS_LOCK_REP unset OUT_DIR W=$SCR/omega; mkdir -p "$W" cp -r "$HERE/Makefile" "$HERE/mk" "$HERE/tools" "$W/" -cp "$HERE/physics.lock" "$W/" 2>/dev/null || true +cp "$HERE/physics.lock" "$HERE/argus.lock" "$W/" 2>/dev/null || true echo "$GOOD" > "$W/aienos.lock" M() { make -s -C "$W" AIENOS_LOCK_REPO="$LK" "$@" >"$SCR/make.log" 2>&1; echo $?; } check "make: default cache materialized and library built" '[ "$(M build/aienos-cap/$GOOD/libaienos_capability.a)" = 0 ] && [ -f "$W/build/aienos-cap/$GOOD/libaienos_capability.a" ] && [ ! -e "$W/build/aienos-authority/$GOOD/native/capability/out" ]' diff --git a/tests/argus_lock_validation.sh b/tests/argus_lock_validation.sh new file mode 100644 index 000000000..2526b9764 --- /dev/null +++ b/tests/argus_lock_validation.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Drake Stapleton (AIEN / aien-dev) + +set -u +ROOT=$(cd "$(dirname "$0")/.." && pwd) +TMP=$(mktemp -d "${TMPDIR:-/tmp}/omega-argus-lock.XXXXXX") || exit 2 +trap 'rm -rf "$TMP"' EXIT INT TERM +GOOD=$(tr -d '\n' < "$ROOT/argus.lock") +FAILS=0 + +accept() { + local name=$1 content=$2 + printf '%s' "$content" > "$TMP/argus.lock" + if make -s -C "$TMP" -f "$ROOT/Makefile" check-argus-lock >"$TMP/make.log" 2>&1; then + printf 'ok %s\n' "$name" + else + printf 'FAIL %s\n' "$name" + FAILS=$((FAILS + 1)) + fi +} + +reject() { + local name=$1 content=$2 + printf '%s' "$content" > "$TMP/argus.lock" + if make -s -C "$TMP" -f "$ROOT/Makefile" check-argus-lock >"$TMP/make.log" 2>&1; then + printf 'FAIL %s\n' "$name" + FAILS=$((FAILS + 1)) + elif grep -q 'argus.lock must contain exactly one lowercase 40-hex commit' "$TMP/make.log"; then + printf 'ok %s\n' "$name" + else + printf 'FAIL %s (wrong refusal)\n' "$name" + FAILS=$((FAILS + 1)) + fi +} + +accept "one lowercase commit" "$GOOD"$'\n' +accept "commit without final newline" "$GOOD" +reject "empty lock" "" +reject "abbreviated commit" "${GOOD:0:39}"$'\n' +reject "uppercase commit" "${GOOD^^}"$'\n' +reject "leading whitespace" " $GOOD"$'\n' +reject "trailing whitespace" "$GOOD "$'\n' +reject "extra field" "$GOOD extra"$'\n' +reject "option-like value" "--$GOOD"$'\n' +reject "second commit" "$GOOD"$'\n'"$GOOD"$'\n' +reject "trailing blank line" "$GOOD"$'\n\n' +reject "trailing comment" "$GOOD"$'\n# comment\n' + +PWNED="$TMP/shell-metacharacters-ran" +reject "shell metacharacters" "$GOOD ; touch $PWNED"$'\n' +if [ -e "$PWNED" ]; then + echo "FAIL shell metacharacters executed" + FAILS=$((FAILS + 1)) +fi + +if [ "$FAILS" -ne 0 ]; then + echo "argus lock validation: $FAILS FAILED" + exit 1 +fi +echo "argus lock validation: PASS"