T09 · Insecure Skill Coding Practices
Error
- Location
- main.py:52
- Finding
- Caller-Controlled Owner Address Bypasses Transaction Loss Detection<![CDATA[ ## Vulnerability Details **File Location**: `main.py:52-57, 96-111` **Vulnerability Type**: Fail-open transaction validation caused by trusting caller-controlled identity data **Risk Level**: High ### Vulnerable Code ```python for change in balance_changes: if (change.get("owner") == owner_addr or change.get("owner", {}).get("AddressOwner") == owner_addr) \ and change.get("coinType") == "0x2::sui::SUI": amount = int(change.get("amount", 0)) if amount < 0: actual_sui_loss += abs(amount) / 1e9 ``` ```python def main(): if len(sys.argv) < 4: print("Usage: python3 main.py '<ptb_command>' <intended_cost> <owner_address>") sys.exit(1) raw_cmd = sys.argv[1] intended_cost = float(sys.argv[2]) owner_addr = sys.argv[3] # 1. Execute secure simulation raw_output = run_simulation(raw_cmd) # 2. Parse JSON (filtering out potential ASCII warning text from Sui CLI) try: json_start = raw_output.find('{') if json_start == -1: raise ValueError("No JSON found") json_data = json.loads(raw_output[json_start:]) # 3. Perform the audit audit_balance_changes(json_data, intended_cost, owner_addr) ``` ### Technical Analysis The auditor calculates SUI loss only for the address supplied through the `owner_address` command-line argument. It does not derive the transaction sender from authoritative Sui simulation output or verify that the supplied address is the signer. This contradicts the documented claim in `SKILL.md` that the tool detects the sender from simulation output. If an unrelated address is supplied, none of the actual sender's negative balance changes match `owner_addr`. Consequently, `actual_sui_loss` remains zero and the transaction can receive a `SAFE TO SIGN` verdict. The issue is fail-open because the absence of matching balance records is interpreted as zero expenditure rather than an invalid or ambiguous sender. ### Attack Pa ...[truncated 988 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Derive the sender from authoritative transaction or simulation data rather than accepting it as an untrusted argument. - Verify that the derived sender matches the active Sui client address and intended signer. - Treat missing, malformed, ambiguous, or mismatched sender information as a blocking audit failure. - Require at least one validated sender balance record when evaluating a transaction that can incur gas or asset expenditure. - If an owner argument must remain available, use it only as an expected value and compare it against the independently derived sender. - Add tests proving that unrelated, absent, and malformed owner addresses cannot produce `SAFE TO SIGN`. ]]>
