T09 · Insecure Skill Coding Practices
- Location
scripts/watchlist.py:57- Finding
Configurable API endpoint can redirect credentials and watchlist data to an arbitrary server
- Content
View full analysis
Vulnerability Details
File Location:
scripts/watchlist.py, lines 57-62
Vulnerability Type: Arbitrary API endpoint configuration and credential disclosure
Risk Level: HighVulnerable Code:
python def get_client() -> OpenAI: api_key = os.environ.get("AISA_API_KEY") if not api_key: print("❌ Error: AISA_API_KEY environment variable is not set.", file=sys.stderr) sys.exit(1) base_url = os.environ.get("AISA_BASE_URL", "https://api.aisa.one/v1") return OpenAI(api_key=api_key, base_url=base_url)Technical Analysis
The Skill requires
AISA_API_KEYto access the declared AISA service, but it permitsAISA_BASE_URLto select an arbitrary API endpoint. The supplied URL is not restricted to the expectedapi.aisa.onehost, nor does the code enforce an approved scheme or endpoint allowlist.The
OpenAIclient uses the AISA API key to authenticate requests against the selected base URL. Consequently, changingAISA_BASE_URLcan cause the credential to be presented to an unintended server. During thecheckcommand, the complete ticker list is also included in the API prompt and sent to that endpoint.Supporting request construction occurs in
scripts/watchlist.py, lines 66-95:python def fetch_watchlist_data(tickers: list[str]) -> dict: """Fetch current price + signal for each ticker via AIsa API.""" if not tickers: return {} client = get_client() model = os.environ.get("AISA_MODEL", "gpt-4o") ticker_str = ", ".join(tickers) prompt = ( f"For each of these tickers: {ticker_str}\n\n" "Fetch the current price and generate a quick BUY/HOLD/SELL signal based on " "RSI, trend, and recent price action.\n\n" "Return ONLY a JSON object. Example:\n" "{\n" " \"AAPL\": {\"price\": 195.50, \"signal\": \"BUY\", \"change_1d\": 1.2, \"rsi\": 58},\n" " \"TSLA\ ...[truncated 2146 chars]- Remediation
View remediation
Remediation Suggestions
- Remove
AISA_BASE_URLconfigurability if custom endpoints are not required. - If endpoint customization is necessary, parse the URL and enforce:
- The
httpsscheme. - An explicit allowlist of approved hostnames, such as
api.aisa.one. - An approved port and path prefix.
- Rejection of embedded credentials, redirects to unapproved hosts, and malformed URLs.
- The
- Do not reuse
AISA_API_KEYfor custom endpoints. Require a distinct credential explicitly associated with each approved service. - Ensure HTTP redirects cannot forward authorization headers to an unapproved origin.
- Document in
SKILL.mdthat checking the watchlist transmits all ticker symbols to AISA. - Apply restrictive environment and deployment configuration permissions so untrusted users cannot alter endpoint variables.
- Rotate the API key if the Skill has previously run with an untrusted
AISA_BASE_URL.
- Remove
