T09 · Insecure Skill Coding Practices
- Location
trader.py:45- Finding
Paper-mode invocation can reuse a cached live trading client
- Content
View full analysis
SimmerClient: global _client, MAX_POSITION, MIN_VOLUME, MAX_SPREAD, MIN_DAYS, MAX_POSITIONS global YES_THRESHOLD, NO_THRESHOLD, MIN_TRADE, MIN_SUB_INTERVALS if _client is None: venue = "polymarket" if live else "sim" _client = SimmerClient( api_key=os.environ["SIMMER_API_KEY"], venue=venue, ) if live: _client.live = True try: _client.apply_skill_config(SKILL_SLUG) except AttributeError: pass # apply_skill_config only available in Simmer runtime MAX_POSITION = float(os.environ.get("SIMMER_MAX_POSITION", str(MAX_POSITION))) MIN_VOLUME = float(os.environ.get("SIMMER_MIN_VOLUME", str(MIN_VOLUME))) MAX_SPREAD = float(os.environ.get("SIMMER_MAX_SPREAD", str(MAX_SPREAD))) MIN_DAYS = int(os.environ.get( "SIMMER_MIN_DAYS", str(MIN_DAYS))) MAX_POSITIONS = int(os.environ.get( "SIMMER_MAX_POSITIONS", str(MAX_POSITIONS))) YES_THRESHOLD = float(os.environ.get("SIMMER_YES_THRESHOLD", str(YES_THRESHOLD))) NO_THRESHOLD = float(os.environ.get("SIMMER_NO_THRESHOLD", str(NO_THRESHOLD))) MIN_TRADE = float(os.environ.get( "SIMMER_MIN_TRADE", str(MIN_TRADE))) MIN_SUB_INTERVALS = int(os.environ.get( "SIMMER_MIN_SUB_INTERVALS", str(MIN_SUB_INTERVALS))) return _client ``` ### Technical Analysis The module stores a single `SimmerClient` in the global `_client` variable. The requested execution mode is used only when `_client` is initially created. Subsequent calls return the existing client without verifying that ...[truncated 1550 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 return _clients[venue] ``` - Before every trade, assert that the client's effective venue and live status match the mode requested by `run`. - Derive displayed mode information from the validated client configuration rather than only from the caller-provided Boolean. - Add a regression test that invokes live mode followed by paper mode in the same process and verifies that the second trade is simulated. - Consider requiring an additional explicit confirmation or separately scoped credential for live trading. ]]>
