T09 · Insecure Skill Coding Practices
- Location
trader.py:49- Finding
Cached Live Client Can Bypass Requested Paper-Trading Mode
- 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 global YES_THRESHOLD, NO_THRESHOLD, MIN_TRADE, STREAK_LENGTH 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 ``` ### Technical Analysis The module stores one `SimmerClient` in the global `_client` variable. The selected venue and live-trading state are established only when `_client` is `None`. Subsequent calls return the existing client without checking whether its venue matches the newly requested `live` argument. Consequently, after the client has been initialized with `live=True`, a later call to `get_client(live=False)` or `run(live=False)` in the same Python process reuses the live Polymarket client. The second execution may print that it is in paper mode while still submitting orders through a client configured for real trading. This is especially relevant in managed runtimes, notebooks, test processes, or embedding applications where the module can remain loaded and `run()` can be invoked more than once. ### Attack Path 1. A process imports `trader.py`. 2. The process invokes `run(live=True)` or `get_cli ...[truncated 837 chars]- Remediation
View remediation
