T09 · Insecure Skill Coding Practices
- Location
scripts/common.py:188- Finding
<![CDATA[HTTPS and credential-boundary validation is not enforced across redirects]]>
- Content
View full analysis
str: url = os.environ.get("MODORA_BASE_URL", DEFAULT_BASE_URL).rstrip("/") parsed = urllib.parse.urlparse(url) hostname = (parsed.hostname or "").lower() is_local = hostname in {"127.0.0.1", "localhost", "::1"} if not is_local and parsed.scheme != "https": raise SystemExit( f"Security error: remote MoDora endpoints must use HTTPS. Current value: {url}" ) return url ``` ```python def request_json( method: str, url: str, data: bytes | None = None, headers: dict[str, str] | None = None, timeout: int = 60, ) -> object: req = urllib.request.Request(url, data=data, method=method) for key, value in (headers or {}).items(): req.add_header(key, value) try: with urllib.request.urlopen(req, timeout=timeout) as resp: return parse_json_bytes(resp.read()) ``` Upload and chat requests pass credentials through this function: ```python headers={ "Content-Type": f"multipart/form-data; boundary={boundary}", **get_credential_headers(), **SKILL_HEADERS, }, ``` ### Technical Analysis `get_base_url()` validates only the initially configured URL. It requires HTTPS for a non-local hostname, but `urllib.request.urlopen()` follows redirects automatically without invoking `get_base_url()` for each redirect destination. Consequently, an initially valid HTTPS endpoint can redirect a request to: - A plaintext HTTP URL, bypassing the documented transport requirement. - A different origin that has not been approved by the user. - An attacker-controlled host. The affected upload and chat requests contain sensitive headers, including `Authorization: Bearer `, `X-Modora-Endpoint`, `X-Modora-Model`, and `X- ...[truncated 1409 chars]- Remediation
View remediation
