AntFleet

Disagreement · cdf9ffa0-anthropic-2

Daily spend circuit breaker compares strings as numbers; awk treats missing/non-numeric values as 0 → cap bypass

mismatch
repo 6f7fc663·PR #4·reviewed 1 week ago

Primary finding

Daily spend circuit breaker compares strings as numbers; awk treats missing/non-numeric values as 0 → cap bypass

highbughigh
  • scripts/postprocess-admanage.sh:60-71
The dailySpendCap and TODAY_SPEND values are interpolated unquoted into the awk program. If TODAY_SPEND is a non-numeric string (e.g., the API returned `{"metadata":{"totalSpend":"$0.00"}}` or `null` or a JSON error blob), jq will produce a string that awk will treat as 0 and the breaker will silently pass — even when the API is broken. Worse, if the API response contains characters like `;` or whitespace, awk will misparse the expression. There is no validation that TODAY_SPEND is numeric and no error-out when the spend endpoint fails (curl|| echo '{}' silently masks failures). For a 'circuit breaker' protecting real spend this fail-open behavior contradicts the stated safety posture ('Hard-fails if ADMANAGE_API_KEY is not set (never silently skips auth)').

Recommendation

Validate the spend response with `jq -e`, fail closed (skip launches + notify) if the value is missing or non-numeric, and validate STRICTEST_CAP is numeric before passing to awk. Quote/escape awk inputs via `awk -v cap="$STRICTEST_CAP" -v spend="$TODAY_SPEND" 'BEGIN{...}'`.

Counterpart finding

Daily spend cap circuit breaker fails open if spend API returns invalid/empty JSON

mediumbughigh
  • scripts/postprocess-admanage.sh:55-69
If SPEND_RESP is non-JSON (or jq fails), TODAY_SPEND becomes empty. The AWK comparison then evaluates an invalid expression (" >= <cap>") and returns non-zero, which makes the if not trigger. The script proceeds to launch despite an unknown/possibly over-cap spend state. A circuit breaker should fail closed for safety.

Recommendation

Harden parsing: default TODAY_SPEND to a safe numeric value and fail closed on parse errors. Example: parsed=$(echo "$SPEND_RESP" | jq -er '.metadata.totalSpend' 2>/dev/null || echo '__ERR__'); if [ "$parsed" = '__ERR__' ]; then block launches with a warning; else compare numerically using bc or awk with explicit numbers. Alternatively, treat any fetch/parse failure as over-cap and exit.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →