T09 · Insecure Skill Coding Practices
- Location
scripts/order_sign.py:409- Finding
Opaque Server-Provided Transactions and Authorization Hashes Are Signed Without Intent Validation
- Content
View full analysis
list[str]: """ Sign all EIP-712 hash signatures in an order-create response. """ from eth_account import Account acct = Account.from_key(private_key) signed_list = [] sigs = order_data.get("signatures", []) if not sigs: raise ValueError("No signatures in order data. Is this a 'txs' mode order?") for item in sigs: api_hash = item.get("hash") if not api_hash: raise ValueError(f"Missing 'hash' field in signature item: {item}") hash_bytes = bytes.fromhex(api_hash[2:]) signed = acct.unsafe_sign_hash(hash_bytes) sig_hex = "0x" + signed.signature.hex() signed_list.append(sig_hex) return signed_list ``` ```python def sign_order_txs_evm(order_data: dict, private_key: str, chain_id: int = None) -> list[str]: from eth_account import Account acct = Account.from_key(private_key) signed_list = [] txs = order_data.get("txs", []) if not txs: raise ValueError("No txs in order data. Is this a 'signatures' mode order?") for tx_item in txs: item_cid = int(tx_item.get("chainId") or (tx_item.get("deriveTransaction") or {}).get("chainId") or 0) if item_cid == _SOLANA_CHAIN_ID: raise ValueError( "One or more tx items are Solana (chainId 501). " "Use --private-key-sol for Solana orders." ) derive = tx_item.get("deriveTransaction") or {} msgs = tx_item.get("msgs") or derive.get("msgs") or [] if msgs and any(m.get("signType") == "eth_sign" for m in msgs): msg_sigs = _sign_m ...[truncated 4881 chars]- Remediation
View remediation
