Files
CASAN/AINative_OKR_CASAN5/.specify/scripts/bash/agent-identity-sign.sh
T
thanhnvandClaude Opus 4.8 3432ae59e1 feat: plan 16 P1 complete (SEC-07 approval + SEC-10 agent identity)
- SEC-07 (M-08): real approval verification via approval-verify.sh in enforced mode
  (CASAN_PROFILE=prod / CASAN_APPROVAL_STRICT=1) for control-plane `set` (sensitive
  keys), kill-switch `clear`, and self-improve (inherits control-plane). A bare or
  forged approval string is now denied; dev mode stays backward-compatible.
- SEC-10 (M-05): non-spoofable agent identity. tool-registry-gate least-privilege no
  longer trusts CASAN_AGENT env in enforced mode (CASAN_IDENTITY_STRICT=1) — the
  caller must present a signed token (agent-identity-sign.sh) bound to agent id +
  run id, verified against agent-identities.registry. Blocks env spoofing + replay.

Verify: SEC+integrity gate 18/0, run-casan4 0-FAIL, adversarial 44/44 (H2 intact),
control-plane 9/0, h5-approval 12/0, c7-incident 15/0, self-improve 7/0, track-c 29/0.

Plan-16 P0 + P1 now complete; remaining: P2 (SEC-12/13/14/15/22..30).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 22:31:57 +09:00

25 lines
1.0 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# CASAN Plan-16 SEC-10 — mint a signed agent-identity token.
#
# Proves a caller really IS a given agent (instead of just setting CASAN_AGENT).
# The signed assertion is bound to the agent id AND the run id, so a token cannot
# be replayed for a different run:
# casan-agent|v1|<agent-id>|<run-id>
#
# Usage: agent-identity-sign.sh <agent-id> <run-id> <private-key> <sig-out>
# The matching PUBLIC key must be registered in agent-identities.registry.
AGENT="${1:-}"; RUN="${2:-}"; PRIV="${3:-}"; SIG_OUT="${4:-}"
if [[ -z "$AGENT" || -z "$RUN" || -z "$PRIV" || -z "$SIG_OUT" ]]; then
echo "Usage: agent-identity-sign.sh <agent-id> <run-id> <private-key> <sig-out>" >&2
exit 64
fi
command -v openssl >/dev/null 2>&1 || { echo "openssl_unavailable" >&2; exit 1; }
TMP="$(mktemp)"; trap 'rm -f "$TMP"' EXIT
printf '%s' "casan-agent|v1|$AGENT|$RUN" > "$TMP"
openssl dgst -sha256 -sign "$PRIV" -out "$SIG_OUT" "$TMP"
echo "AGENT_IDENTITY_SIGNED agent=$AGENT run=$RUN sig=$SIG_OUT"