T09 · Insecure Skill Coding Practices
- Location
trader.py:281- Finding
Live trades proceed when safeguard context retrieval fails
- Content
View full analysis
dict: """Get market context with safeguards and edge analysis.""" try: if my_probability is not None: return get_client()._request( "GET", f"/api/sdk/context/{market_id}", params={"my_probability": my_probability} ) return get_client().get_market_context(market_id) except Exception: return None def check_safeguards(context: dict) -> tuple[bool, list[str]]: """Check context for safeguards. Returns (should_trade, reasons).""" if not context: return True, [] ``` ### Technical Analysis `get_market_context()` suppresses every exception and returns `None`. `check_safeguards()` then treats a missing or empty context as approval to trade. Consequently, authentication failures, network timeouts, rate limits, malformed API responses, SDK failures, and service outages all bypass the checks for: - Resolved markets - Time remaining before resolution - Minimum liquidity - Maximum slippage - Severe flip-flop warnings This is a fail-open design in a financial execution path. The absence of risk information is treated as evidence that the order is safe, even though none of the advertised safeguards could be evaluated. ### Attack Path 1. The Skill identifies a signal whose calculated edge exceeds the configured threshold. 2. An attacker disrupts the context endpoint, or an ordinary timeout, rate limit, authentication error, malformed response, or SDK exception occurs. 3. `get_market_context()` catches the exception without reporting its cause and returns `None`. 4. `check_safeguards(None)` returns `(True, [])`. 5. When the Skill is running with `--live`, execution continues to `execute_trade()`. 6. A real order ...[truncated 876 chars]- Remediation
View remediation
tuple[bool, list[str]]: if not isinstance(context, dict) or not context: return False, ["Market context unavailable; refusing to trade"] ``` Live execution should require affirmative validation of all mandatory safety conditions rather than relying on the absence of detected warnings. ]]>
