T09 · Insecure Skill Coding Practices
- Location
scripts/manage_notes.py:22- Finding
Unrestricted API Endpoint Can Receive Credentials and Sensitive Note Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/manage_notes.py:22-35
Additional Affected Locations:scripts/manage_notes.py:42-55,scripts/manage_notes.py:85-103,scripts/manage_notes.py:107-119
Vulnerability Type: Unvalidated external endpoint and insecure transmission of sensitive data
Risk Level: HighVulnerable Code
python def call_ai(prompt, config): if not config or not config.get("api_key"): return None headers = {"Authorization": f"Bearer {config['api_key']}", "Content-Type": "application/json"} payload = { "model": config.get("model", "google/gemini-3.1-pro-preview"), "messages": [{"role": "user", "content": prompt}], "temperature": 0.1 } try: response = requests.post(f"{config['api_base'].rstrip('/')}/chat/completions", headers=headers, json=payload, timeout=60) return response.json()['choices'][0]['message']['content'].strip() except Exception as e: print(f"⚠️ AI error: {e}") return NoneTechnical Analysis
The
api_basevalue is loaded from configuration and interpolated directly into the request URL without validating the URL scheme, destination host, resolved IP address, or trust status. The request includes the configured API key in anAuthorization: Bearerheader and includes the supplied prompt in the request body.Consequently, an
http://endpoint can expose credentials and note contents over an unencrypted connection. An attacker-controlled HTTPS endpoint would still receive both the credential and the submitted business data. Depending on the command used:addsubmits the new note for entity and quality analysis.analyzesubmits collected note contents for report generation.searchplaces the complete loaded note collection into the AI prompt, rather than first restricting the request to locally selected candidates.
Because arbitrary destinati ...[truncated 1893 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
https://for remote API endpoints and reject plaintext HTTP. - Parse the endpoint with a standard URL parser and reject malformed URLs, embedded credentials, unexpected schemes, fragments, and suspicious redirects.
- Maintain an allowlist of approved API hosts or require explicit, prominent confirmation before trusting a custom provider.
- Resolve the destination and reject loopback, link-local, multicast, and private-network addresses unless private endpoints are an explicitly enabled feature.
- Disable automatic redirects or revalidate every redirect destination before forwarding the authorization header.
- Display a clear disclosure identifying which provider will receive note data.
- Redact likely secrets, passwords, tokens, and other sensitive fields before creating AI prompts.
- For search, perform local keyword or embedding-based candidate selection first and submit only the minimum required records.
- Use provider-specific credentials with minimal permissions, spending limits, and straightforward rotation.
- Update the privacy documentation because transport encryption is not guaranteed by the current implementation.
- Require
