Skip to content

Commit 200d362

Browse files
aamirrasheedclaude
andcommitted
Fix verify: inference curl and TPM permission fallback
- Inference check used `curl -sI -X POST` which is invalid (curl bails with "You can only select one HTTP request method", silenced by 2>/dev/null). Switch to `curl -s -D - -o /dev/null` against /models, which is a real GET that returns the same Attestation-Report header. - SEV-SNP check failed for non-root users because /dev/tpmrm0 is root:tss and the admin user was not in tss group. Add a sudo -n fallback when attestation-cli reports a TPM error, and emit a helpful "add user to tss group" hint when even sudo fails. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c3b589e commit 200d362

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

privateclaw

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,33 @@ cmd_verify() {
165165
-o "$SNP_TMPFILE" 2>&1) || true
166166
fi
167167

168+
# Fallback: TPM device (/dev/tpmrm0) is owned by root:tss. If the current user
169+
# is not in the tss group, the attest call fails with "vtpm::get_report failed:
170+
# tpm error". Retry under sudo if available — most CVM admin users have
171+
# passwordless sudo configured.
172+
if { [ ! -s "$SNP_TMPFILE" ] || ! jq -e . "$SNP_TMPFILE" &>/dev/null; } && command -v sudo &>/dev/null; then
173+
if echo "$SNP_ATTEST_OUT" | grep -qi "tpm error\|permission denied\|EACCES\|get_report failed" || ! [ -s "$SNP_TMPFILE" ]; then
174+
if [ -n "$SNP_REPORT_DATA" ]; then
175+
SNP_ATTEST_OUT=$(sudo -n "$ATTESTATION_CLI" attest \
176+
--platform az-snp \
177+
--report-data-hex "$SNP_REPORT_DATA" \
178+
-o "$SNP_TMPFILE" 2>&1) || true
179+
else
180+
SNP_ATTEST_OUT=$(sudo -n "$ATTESTATION_CLI" attest \
181+
--platform az-snp \
182+
-o "$SNP_TMPFILE" 2>&1) || true
183+
fi
184+
# Fix ownership so subsequent jq/cp work as the current user
185+
sudo -n chown "$(id -u):$(id -g)" "$SNP_TMPFILE" 2>/dev/null || true
186+
fi
187+
fi
188+
189+
# If still failing, give a helpful hint about tss group membership
190+
if { [ ! -s "$SNP_TMPFILE" ] || ! jq -e . "$SNP_TMPFILE" &>/dev/null; } \
191+
&& echo "$SNP_ATTEST_OUT" | grep -qi "tpm error\|permission denied\|EACCES\|get_report failed"; then
192+
SNP_ATTEST_OUT="TPM access denied — add this user to the 'tss' group: sudo usermod -aG tss \$USER (then re-login). Detail: $SNP_ATTEST_OUT"
193+
fi
194+
168195
if [ -f "$SNP_TMPFILE" ] && [ -s "$SNP_TMPFILE" ] && jq -e . "$SNP_TMPFILE" &>/dev/null; then
169196
# Verify the SNP report via attestation-cli (validates VCEK cert chain)
170197
SNP_VERIFY_RESULT=$($ATTESTATION_CLI verify -e "$SNP_TMPFILE" 2>/dev/null) || true
@@ -335,9 +362,11 @@ cmd_verify() {
335362
# Make a minimal request to the inference endpoint and capture response headers
336363
INF_HEADERS=""
337364
if [ "$ENDPOINT" != "not configured" ]; then
338-
INF_HEADERS=$(curl -sI -X POST "$ENDPOINT/chat/completions" \
339-
-H "Content-Type: application/json" \
340-
-d '{"model":"test","messages":[{"role":"user","content":"hi"}],"max_tokens":1}' \
365+
# NOTE: Do NOT use `curl -I -X POST` — `-I` forces HEAD which conflicts
366+
# with `-X POST` and curl bails out producing no output. Use `-D -` to
367+
# dump headers from a real GET request instead. The /v1/models endpoint
368+
# returns the same Attestation-Report header as /chat/completions.
369+
INF_HEADERS=$(curl -s -D - -o /dev/null "$ENDPOINT/models" \
341370
--max-time 10 2>/dev/null) || true
342371
fi
343372

0 commit comments

Comments
 (0)