T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:42- Finding
Plaintext Transmission of Credentials, Tokens, and User Prompts
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py:42-50, 69-90, 98-127, 150-159, 219-230;README.md:77-94, 162-179
Vulnerability Type: Sensitive information transmitted over an unencrypted network connection
Risk Level: HighVulnerable Code
python MAXKB_DOMAIN = os.environ.get("MAXKB_DOMAIN", "<maxkb_domain>") MAXKB_API_PREFIX = os.environ.get("MAXKB_API_PREFIX", "/admin").rstrip("/") MAXKB_TOKEN = os.environ.get("MAXKB_TOKEN", "") MAXKB_WORKSPACE_ID = os.environ.get("MAXKB_WORKSPACE_ID", "default") MAXKB_USERNAME = os.environ.get("MAXKB_USERNAME", "") MAXKB_PASSWORD = os.environ.get("MAXKB_PASSWORD", "")python def _headers() -> dict: return { "Authorization": f"Bearer {MAXKB_TOKEN}", "Content-Type": "application/json", } def _chat_headers(token: str) -> dict: return { "Authorization": f"Bearer {token}", "Content-Type": "application/json", } def _get(path: str, token: str = None) -> dict: api_path = _build_api_path(path) url = f"{MAXKB_DOMAIN}{api_path}" headers = _headers() if token is None else _chat_headers(token) req = request.Request(url=url, headers=headers, method="GET") try: with request.urlopen(req) as resp: charset = resp.headers.get_content_charset() or "utf-8" return json.loads(resp.read().decode(charset, errors="replace"))python def _post_json(path: str, body: dict, token: str = None) -> dict: api_path = _build_api_path(path) url = f"{MAXKB_DOMAIN}{api_path}" data = json.dumps(body).encode("utf-8") headers = _headers() if token is None else _chat_headers(token) req = request.Request(url=url, data=data, headers=headers, method="POST") try: with request.urlopen(req) as resp: charset = resp.headers.get_content_charset() or "utf-8" return json.loads(resp.read().decode(charset, errors="replace"))python def _post_sse(path: ...[truncated 4359 chars]- Remediation
View remediation
Remediation Suggestions
-
Enforce HTTPS by default
- Parse
MAXKB_DOMAINwithurllib.parse.urlparse. - Reject schemes other than
https. - If local development requires HTTP, allow it only for verified loopback addresses such as
127.0.0.1,::1, orlocalhost, behind an explicit development-only option.
- Parse
-
Validate the configured destination
- Require a nonempty hostname.
- Reject embedded URL credentials.
- Consider an administrator-configured hostname and port allowlist.
- Normalize the base URL before appending API paths.
-
Restrict redirects
- Disable automatic redirects for authenticated requests or implement a redirect handler that only permits same-origin HTTPS redirects.
- Never forward authentication headers or sensitive request bodies to a different origin or a downgraded HTTP destination.
-
Use least-privileged authentication
- Replace administrator credentials with a dedicated service account or token limited to listing published agents, obtaining the required application access token, and creating chats.
- Rotate any credentials previously used over plaintext HTTP.
- Prefer short-lived tokens where supported.
-
Correct the documentation
- Replace non-loopback
http://examples withhttps://. - Clearly state that plaintext HTTP is prohibited outside isolated loopback development.
- Avoid recommending administrator credentials where a scoped service token is sufficient.
- Replace non-loopback
-
Add transport-security tests
- Verify that non-loopback HTTP URLs are rejected.
- Verify that HTTPS-to-HTTP downgrade redirects fail.
- Verify that cross-origin redirects do not receive bearer tokens.
- Test malformed URLs, embedded credentials, unexpected ports, and untrusted hostnames.
-
