T09 · Insecure Skill Coding Practices
- Location
run.py:16- Finding
Bearer API credential can be transmitted to an unrestricted network endpoint
- Content
View full analysis
Vulnerability Details
File Location:
run.py:16-18,run.py:59-90
Vulnerability Type: Unrestricted credential destination and unsafe endpoint configuration
Risk Level: HighVulnerable Code
python BASE = os.environ["SIMMER_API_URL"].rstrip("/") KEY = os.environ.get("SIMMER_API_KEY", "sk_replay") HEADERS = {"Authorization": f"Bearer {KEY}"}python def get_held_market_ids(): r = requests.get(f"{BASE}/api/sdk/positions", headers=HEADERS, timeout=30) r.raise_for_status() return {p["market_id"] for p in r.json().get("positions", [])} def get_balance(): r = requests.get(f"{BASE}/api/sdk/balance", headers=HEADERS, timeout=30) r.raise_for_status() return r.json().get("balance", 1000.0) def get_markets(): r = requests.get(f"{BASE}/api/sdk/markets", params={"limit": 100}, headers=HEADERS, timeout=30) r.raise_for_status() return r.json().get("markets", []) def place_trade(market_id: str, side: str, action: str, amount: float, reasoning: str): """Place a trade via Simmer API""" resp = requests.post( f"{BASE}/api/sdk/trade", json={ "market_id": market_id, "side": side, "action": action, "amount": amount, "reasoning": reasoning, "skill_slug": "polymarket-fast-loop", "source": "fast-loop-enhanced" }, headers=HEADERS, timeout=30 ) return resp.json() if resp.ok else {"error": resp.text}Technical Analysis
The value of
SIMMER_API_URLis accepted without validating its scheme, hostname, port, or destination network. The same bearer token is then attached to requests for positions, account balance, market data, and trade submission.Network access is necessary for the declared trading functionality, but sending a financial API credential to an arbitrary configurable destinatio ...[truncated 2270 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse
SIMMER_API_URLusingurllib.parse.urlparseand reject malformed URLs. - Require
httpsand reject URLs containing user information, unexpected ports, fragments, or query strings. - Maintain an explicit allowlist of approved API hostnames rather than accepting arbitrary destinations.
- Resolve the hostname and reject loopback, private, link-local, multicast, reserved, and unspecified addresses unless internal access is explicitly required.
- Disable automatic redirects for authenticated requests, or validate the scheme, hostname, port, and resolved destination of every redirect before forwarding credentials.
- Remove the
"sk_replay"fallback and fail closed whenSIMMER_API_KEYis absent. - Use a narrowly scoped credential that cannot perform live financial actions unless live operation has been explicitly authorized.
- Separate read-only market-data credentials from trade-execution credentials where supported.
- Avoid logging authorization headers, and redact credentials from exceptions and diagnostic output.
- Add automated tests proving that HTTP URLs, unapproved hosts, IP literals, private addresses, and cross-origin redirects are rejected.
- Parse
