T09 · Insecure Skill Coding Practices
- Location
scripts/service.py:55- Finding
Local Order File Allows Forged Payment Authorization
- Content
View full analysis
Vulnerability Details
File Location:
scripts/service.py, lines 55–88
Vulnerability Type: Insufficient payment credential validation
Risk Level: HighVulnerable Code:
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 True if __name__ == "__main__": parser = argparse.ArgumentParser( description="Verify payment and authorize soft-ip-zijian compliance review" ) parser.add_argument("order_no", help="Order number from Phase 1") args = parser.parse_args() indicator = compute_indicator(SLUG) try: order_data = _load_order(indicator, args.order_no) except Exception as e: print("PAY_STATUS: ERROR") print(f"ERROR_INFO: Order file read failed: {e}") sys.exit(1) if not is_credential_valid(order_data): print("PAY_STATUS: ERROR") print("ERROR_INFO: No valid payment credential found. Please 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)Technical Analysis
Payment authorization is based entirely on fields read from a locally writable JSON order file. The application considers any non-empty
payCredentialvalue valid without cryptographically verifying its origin or contents.The implementation does not verify:
- A digital signature or message authentication code from the payment provider.
- That the credential is bound to the supplied order number.
- The expected payment amoun ...[truncated 1480 chars]
- Remediation
View remediation
Remediation Suggestions
- Require a cryptographically signed payment credential from the trusted payment provider.
- Verify the signature using a pinned, trusted public key or validate a provider-generated MAC using a securely managed secret.
- Bind the credential to the exact order number, amount, currency, recipient, skill identifier, issuance time, and expiration time.
- Require a valid timestamp and reject credentials with missing, malformed, expired, or unreasonably future-dated timestamps.
- Require an explicit
SUCCESSstatus from authenticated credential content; never default a missing status to success. - Do not trust mutable order-file fields as proof of payment.
- Where supported, query the trusted payment provider for order status over an authenticated channel.
- Mark credentials as consumed or otherwise enforce replay protection if each payment should authorize only one delivery.
- Use constant-time cryptographic verification and fail closed on every parsing or validation error.
