T09 · Insecure Skill Coding Practices
Error
- Location
- discipline_scanner.py:23
- Finding
- Automated trading uses an unverified hardcoded wallet identity<![CDATA[ ## Vulnerability Details **File Location**: `discipline_scanner.py:23-29, 60-65, 100-103` **Vulnerability Type**: Wallet and signer identity mismatch **Risk Level**: High ### Vulnerable Code ```python wallet = "0x2aacf919270Ae303fD3FE8e27D96CBA250936B9F" ctx = ssl.create_default_context() req = urllib.request.Request( f"https://data-api.polymarket.com/positions?user={wallet}&sizeThreshold=0", headers={"User-Agent": "Mozilla/5.0"} ) with urllib.request.urlopen(req, timeout=15, context=ctx) as r: positions = json.loads(r.read()) ``` ```python from trade_tor import patch_httpx_for_tor, get_client import httpx from py_clob_client.clob_types import OrderArgs, OrderType from py_clob_client.order_builder.constants import SELL as SELL_SIDE patch_httpx_for_tor() client = get_client() ``` ```python order = client.create_order( OrderArgs(token_id=token_id, price=best_bid, size=sell_size, side=SELL_SIDE) ) result = client.post_order(order, OrderType.FOK) ``` ### Technical Analysis The scanner obtains positions for a fixed wallet, but the authenticated trading client is created independently by `trade_tor.get_client()`. The code does not verify that the client's signer and funder correspond to the wallet used to select positions. This violates a critical invariant for automated trading: the position owner, signing account, and funding account must be the same expected identity. If the configured private key belongs to another wallet, the scanner can select token IDs and quantities using unrelated account data before attempting authenticated sell orders. The referenced `trade_tor` module is absent from the supplied artifact, so this path cannot execute as packaged. Nevertheless, the identity-validation defect is explicit in the available scanner and would become reachable when the missing module is supplied. ### Attack Path 1. The operator configures a private key whose address differs from the hardcoded wallet. 2. The cron task queries p ...[truncated 812 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Derive the queried wallet address directly from the configured private key. - Require `queried_wallet == signer_address == funder_address` before loading positions or creating orders. - Remove the hardcoded wallet address. - Abort rather than trade when any identity cannot be verified. - Add chain-ID and CLOB-host validation. - Add tests that configure mismatched wallets and confirm that no order can be created or posted. - Package and audit the referenced `trade_tor` module before enabling the scanner. ]]>
