T09 · Insecure Skill Coding Practices
- Location
fastloop_trader.py:153- Finding
Unrestricted API Base Override Can Exfiltrate the Simmer API Key
- Content
View full analysis
Vulnerability Details
File Location:
fastloop_trader.py, lines 153 and 190–194
Vulnerability Type: Unvalidated authenticated API endpoint override
Risk Level: HighVulnerable Code
python SIMMER_BASE = os.environ.get("SIMMER_API_BASE", "https://api.simmer.markets")python def simmer_request(path, method="GET", data=None, api_key=None): """Make a Simmer API request.""" headers = {} if api_key: headers["Authorization"] = f"Bearer {api_key}" return _api_request(f"{SIMMER_BASE}{path}", method=method, data=data, headers=headers)Authenticated requests may include sensitive account and transaction operations:
python def execute_trade(api_key, market_id, side, amount): """Execute a trade on Simmer.""" return simmer_request("/api/sdk/trade", method="POST", data={ "market_id": market_id, "side": side, "amount": amount, "venue": "polymarket", "source": TRADE_SOURCE, }, api_key=api_key)Technical Analysis
The
SIMMER_API_BASEenvironment variable controls the destination of every Simmer API request. The value is accepted without validating its scheme, hostname, port, or TLS requirements. At the same time,simmer_request()attaches the secretSIMMER_API_KEYas a bearer token to requests sent to that destination.The declared functionality only requires authenticated communication with
https://api.simmer.markets. Allowing an undocumented, unrestricted endpoint override exceeds that minimum requirement and creates a credential-exfiltration channel.The affected calls include portfolio retrieval, position retrieval, market import, and real trade execution. Consequently, an attacker-controlled endpoint can receive the bearer credential as well as market identifiers, order direction, order amount, venue, and strategy source metadata. It can also return crafted JSON responses that the ...[truncated 1779 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the production runtime override and use a fixed trusted endpoint:
python SIMMER_BASE = "https://api.simmer.markets" -
If endpoint overrides are necessary for development or testing, require an explicit development-mode flag and enforce a strict allowlist:
python from urllib.parse import urlparse ALLOWED_SIMMER_HOSTS = {"api.simmer.markets"} def validate_simmer_base(value): parsed = urlparse(value) if parsed.scheme != "https": raise ValueError("SIMMER API endpoint must use HTTPS") if parsed.hostname not in ALLOWED_SIMMER_HOSTS: raise ValueError("Untrusted SIMMER API hostname") if parsed.username or parsed.password: raise ValueError("User information is not permitted in the endpoint") if parsed.port not in (None, 443): raise ValueError("Unexpected SIMMER API port") if parsed.query or parsed.fragment: raise ValueError("Query strings and fragments are not permitted") return value.rstrip("/") -
Do not attach authorization headers until the final request URL has been verified as HTTPS and matched against the exact trusted hostname.
-
Disable or strictly validate cross-origin redirects for authenticated requests so credentials cannot be forwarded to another host.
-
Use narrowly scoped, revocable API tokens. Separate read-only credentials from credentials capable of executing trades where supported.
-
Document every supported endpoint override and ensure production cron jobs, containers, and launch wrappers define environments from trusted, access-controlled configuration.
-
Rotate the API key if the script has previously run with an untrusted or unknown
SIMMER_API_BASEvalue.
-
