T09 · Insecure Skill Coding Practices
- Location
scripts/lib.sh:43- Finding
Operator Override Is Silently Ignored by Fallback Calldata
- Content
View full analysis
Vulnerability Details
File Location:
scripts/lib.sh, lines 43–67
Vulnerability Type: Inconsistent ABI encoding caused by hardcoded fallback calldata
Risk Level: MediumVulnerable Code
bash set_pet_operator_calldata() { local approved="$1" case "$approved" in true|false) ;; *) err "approved must be true|false" ;; esac if command -v cast >/dev/null 2>&1; then local data data="$(cast calldata "setPetOperatorForAll(address,bool)" "$AAI_OPERATOR" "$approved" 2>/dev/null || true)" if [[ -n "$data" && "$data" == 0x* ]]; then printf '%s\n' "$data" return 0 fi fi if [[ "$approved" == "true" ]]; then printf '%s\n' "0xcd675d57000000000000000000000000b96b48a6b190a9d509ce9312654f34e9770f21100000000000000000000000000000000000000000000000000000000000000001" else printf '%s\n' "0xcd675d57000000000000000000000000b96b48a6b190a9d509ce9312654f34e9770f21100000000000000000000000000000000000000000000000000000000000000000" fi }Technical Analysis
The Skill documents
AAI_OPERATORas an overridable environment variable. The primary encoding path correctly uses the current value of$AAI_OPERATOR. However, ifcastis unavailable orcast calldatafails, the fallback transaction data embeds the default AAI operator address,0xb96B48a6B190A9d509cE9312654F34E9770F2110, rather than the configured address.The transaction-generation scripts display
$AAI_OPERATORseparately from the generated calldata. Consequently, their human-readable output can identify one operator while the actual calldata grants or revokes permission for another operator. A user who reviews only the displayed operator and destination may sign a transaction whose effective authorization differs from the stated authorization.Although the generated transaction grants pet-operator rights rather than NFT transfer rights, it applies through
setPetOperatorForAllto all of the owner's Aavegotchis. T ...[truncated 1507 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the hardcoded fallback and fail closed if ABI encoding cannot be performed:
bash require_bin cast cast calldata \ "setPetOperatorForAll(address,bool)" \ "$AAI_OPERATOR" \ "$approved"-
If an offline fallback is required, dynamically ABI-encode the validated current value of
$AAI_OPERATORrather than embedding a fixed address. -
Validate
AAI_OPERATORwithis_eth_addressbefore generating transaction data. -
Decode or independently verify the generated calldata before displaying it. Confirm that:
- the selector is for
setPetOperatorForAll(address,bool); - the encoded operator equals
$AAI_OPERATOR; - the encoded Boolean equals the requested operation.
- the selector is for
-
Abort on any encoding or verification failure instead of suppressing the error with
2>/dev/null || true. -
Add automated tests covering default and overridden operator addresses for both approval and revocation, including simulated
castfailure. -
Display a decoded summary derived from the final calldata so the human-readable operator cannot diverge from the actual transaction payload.
