Skip to content

security: fix SSRF, cleartext fetch, error disclosure, and tainted URL flow in handlers#23

Draft
al1dazzi with Copilot wants to merge 3 commits into
mainfrom
copilot/rch-task-ca50612072ea2ec9-remediate-selected-batch
Draft

security: fix SSRF, cleartext fetch, error disclosure, and tainted URL flow in handlers#23
al1dazzi with Copilot wants to merge 3 commits into
mainfrom
copilot/rch-task-ca50612072ea2ec9-remediate-selected-batch

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown

Four reachable security findings in FetchTool, SafeAIAnswer, and ParseLanguage: unvalidated user-controlled URLs reaching http.Get (CWE-319 / CWE-918), and raw err.Error() strings written directly to HTTP responses.

URL validation (internal/safety/guards.go)

  • New SafeFetchURL(rawURL) — rejects non-https schemes, resolves the hostname via DNS, and checks every returned address against a comprehensive private/reserved CIDR blocklist (RFC 1918, loopback, CGNAT, link-local, multicast, documentation ranges, IPv6 equivalents)
  • init() panics on any malformed built-in CIDR to surface programming errors at startup

SSRF + cleartext fix (internal/handlers/suspicious.go)

  • FetchTool now calls SafeFetchURL before http.Get; invalid/private URLs are rejected with a generic 400 before any network I/O
  • All http.Error(w, err.Error(), …) replaced with generic messages; originals logged server-side
fetchURL, err := safety.SafeFetchURL(source)
if err != nil {
    http.Error(w, "invalid request URL", http.StatusBadRequest)
    return
}
resp, err := http.Get(fetchURL.String())

Error disclosure (internal/handlers/ai.go, internal/handlers/cve.go)

  • SafeAIAnswer: JSON decode error no longer echoed to client ("invalid request body")
  • ParseLanguage: language parse error no longer echoed to client ("invalid language tag")

Copilot AI changed the title [WIP] Remediate selected batch of 4 units security: fix SSRF, cleartext fetch, error disclosure, and tainted URL flow in handlers Jun 22, 2026
Copilot AI requested a review from al1dazzi June 22, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants