T09 · Insecure Skill Coding Practices
- Location
scripts/service.py:51- Finding
Forgeable Local Payment Authorization
- Content
View full analysis
Vulnerability Details
File Location:
scripts/service.py, lines 51-59 and 76-91
Vulnerability Type: Payment verification bypass caused by fail-open credential validation
Risk Level: MediumComplete Code Snippet
python def is_credential_valid(order_data: dict) -> bool: credential = order_data.get("payCredential") if not credential: return False credential_ts = order_data.get("credentialTimestamp") if credential_ts and time.time() - credential_ts > CREDENTIAL_TTL: return False return Truepython if not is_credential_valid(order_data): print("PAY_STATUS: ERROR") print("ERROR_INFO: No valid payment credential found. Complete payment via clawtip first.") sys.exit(1) pay_status = order_data.get("payStatus", "SUCCESS") print(f"PAY_STATUS: {pay_status}") if pay_status != "SUCCESS": print(f"ERROR_INFO: Payment status is '{pay_status}', cannot proceed") sys.exit(1) print("AUTHORIZATION_RESULT=verified")Technical Analysis
The payment credential is not cryptographically authenticated. The validation routine only confirms that
payCredentialis non-empty. It does not verify a digital signature or message authentication code, nor does it bind the credential to the expected order number, amount, recipient, indicator, or payment transaction.The expiration check also fails open:
- A missing
credentialTimestampis accepted indefinitely. - A future timestamp is accepted because the calculated age is negative.
- Timestamp type and allowable clock skew are not validated.
- No replay protection or transaction identifier is checked.
- A missing
payStatusdefaults toSUCCESS.
Because the order file is stored in the invoking user's home directory and is intentionally writable by that user, its fields cannot serve as a trusted payment-verification boundary.
Attack Path
- Run `scripts/create_order ...[truncated 1030 chars]
- A missing
- Remediation
View remediation
Remediation Suggestions
- Verify
payCredentialcryptographically through an authenticated clawtip verification API or with a trusted, pinned clawtip public key. - Bind the verified credential to the exact
orderNo, amount, recipient address, indicator, and service slug. - Require
payStatusto be explicitly present and equal toSUCCESS; never supply a successful default. - Require a numeric
credentialTimestampand reject missing, malformed, expired, or unreasonably future timestamps. - Enforce a small, documented clock-skew allowance.
- Validate a unique transaction identifier and maintain replay protection so that one credential cannot authorize multiple orders.
- Treat all values loaded from the local order JSON as untrusted.
- Fail closed on missing fields, parsing errors, unsupported credential versions, and verification-service failures.
- Add negative tests covering forged credentials, absent timestamps, future timestamps, mismatched amounts, mismatched order numbers, missing status fields, and replayed transactions.
- Verify
