T09 · Insecure Skill Coding Practices
- Location
scripts/webdav_sync.py:215- Finding
Cleartext WebDAV Transport Permits Credential and Archive Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
scripts/webdav_sync.py, lines 119-166 and 215
Vulnerability Type: Missing enforcement of encrypted transport for sensitive WebDAV operations
Risk Level: HighVulnerable Code
python def ensure_remote_dir(base_url: str, remote_subdir: str, curl_bin: str, auth_config: Path) -> None: current = base_url.rstrip("/") + "/" pieces = [piece for piece in remote_subdir.strip("/").split("/") if piece] for piece in pieces: current = current + quote(piece) + "/" result = run_cmd([ curl_bin, "--config", str(auth_config), "-sS", "-o", "/dev/null", "-w", "%{http_code}", "-X", "MKCOL", current, "--connect-timeout", "20", "--max-time", "60", ], check=False) try: status = int((result.stdout or "").strip() or "0") except ValueError: status = 0 if status not in SUCCESS_MKCOL: raise RuntimeError("MKCOL failed for {} with HTTP {}".format(current, status)) def upload_file(base_url: str, remote_subdir: str, archive_name: str, archive_path: Path, curl_bin: str, auth_config: Path) -> int: remote_url = "{}/{}/{}".format( base_url.rstrip("/"), "/".join(quote(part) for part in remote_subdir.strip("/").split("/") if part), quote(archive_name), ) result = run_cmd([ curl_bin, "--config", str(auth_config), "-sS", "-o", "/dev/null", "-w", "%{http_code}", "-T", str(archive_path), remote_url, "--connect-timeout", "30", "--max-time", "1800", ], check=False) try: return int((result.stdout or "").strip() or "0") except ValueError: return 0The endpoint is obtained without validatin ...[truncated 2310 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse
WEBDAV_SITEwithurllib.parse.urlparsebefore creating the archive or credential file. - Require the scheme to be exactly
httpsand reject URLs with missing or unsupported schemes. - Reject URLs containing embedded user information to avoid ambiguous credential handling.
- Keep TLS certificate verification enabled. Do not introduce curl options such as
--insecure. - Consider adding curl's
--proto =httpsand--proto-redir =httpscontrols to prevent protocol downgrade through redirects. - Consider using
--location-trustedonly if strictly necessary; otherwise avoid forwarding credentials across redirects. - If cleartext HTTP is indispensable for a tightly controlled local environment, place it behind an explicit opt-in flag, emit a prominent warning, and document that it must be protected by a trusted encrypted tunnel.
Example validation:
python from urllib.parse import urlparse parsed_url = urlparse(base_url) if parsed_url.scheme.lower() != "https" or not parsed_url.netloc: raise ValueError("WEBDAV_SITE must be a valid HTTPS URL") if parsed_url.username is not None or parsed_url.password is not None: raise ValueError("WEBDAV_SITE must not contain embedded credentials")Curl should additionally be constrained to HTTPS:
python [ curl_bin, "--proto", "=https", "--proto-redir", "=https", "--config", str(auth_config), # remaining arguments ]- Parse
