T09 · Insecure Skill Coding Practices
- Location
trader.py:47- Finding
Cached Live Client Can Be Reused During Paper-Mode Execution
- Content
View full analysis
SimmerClient: """ live=False → venue="sim" (paper trades — safe default). live=True → venue="polymarket" (real trades, only with --live flag). """ global _client, MAX_POSITION, MIN_VOLUME, MAX_SPREAD, MIN_DAYS, MAX_POSITIONS, YES_THRESHOLD, NO_THRESHOLD, MIN_TRADE if _client is None: venue = "polymarket" if live else "sim" _client = SimmerClient( api_key=os.environ["SIMMER_API_KEY"], venue=venue, ) # Load tunable overrides set via the Simmer UI (SIMMER_* vars only). if live: _client.live = True try: _client.apply_skill_config(SKILL_SLUG) except AttributeError: pass # apply_skill_config only available in Simmer runtime return _client ``` The resulting client is subsequently used to submit trades: ```python r = client.trade( market_id=m.id, side=side, amount=size, source=TRADE_SOURCE, skill_slug=SKILL_SLUG, reasoning=reasoning, ) ``` ### Technical Analysis The module stores one `SimmerClient` instance in the global `_client` variable. The selected venue is determined only when `_client` is initially created. Later calls return that same instance without verifying that its venue agrees with the current `live` argument. Consequently, after `get_client(live=True)` creates a client for the live Polymarket venue, a later call to `run(live=False)` in the same Python process receives the previously cached live client. The application prints that it is operating in paper mode, but trade requests can still be routed through the live client. This breaks the documented safety boundary that real trades require a ...[truncated 1034 chars]- Remediation
View remediation
SimmerClient: venue = "polymarket" if live else "sim" if venue not in _clients: client = SimmerClient( api_key=os.environ["SIMMER_API_KEY"], venue=venue, ) client.live = live _clients[venue] = client client = _clients[venue] if bool(getattr(client, "live", False)) != live: raise RuntimeError("Client execution mode does not match requested mode") return client ``` ]]>
