Skip to content

Harden handler URL fetching and error responses for Reachable shard 4 (CWE-319/918 + error disclosure)#35

Draft
al1dazzi with Copilot wants to merge 8 commits into
mainfrom
copilot/rch-task-8eb6746d52ccfef5-remediate-batch
Draft

Harden handler URL fetching and error responses for Reachable shard 4 (CWE-319/918 + error disclosure)#35
al1dazzi with Copilot wants to merge 8 commits into
mainfrom
copilot/rch-task-8eb6746d52ccfef5-remediate-batch

Conversation

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown

This PR addresses the selected Reachable critical shard (4 units) in internal/handlers/ai.go, internal/handlers/cve.go, and internal/handlers/suspicious.go. It removes reachable SSRF/plaintext URL paths in FetchTool and eliminates internal error detail leakage in the scoped handlers.

  • FetchTool SSRF/TLS controls (internal/handlers/suspicious.go)

    • Added validatedToolURL gate before outbound requests.
    • Enforced absolute https URLs only.
    • Enforced exact URL allowlisting via REACH_FETCH_TOOL_ALLOWED_URLS (comma-separated HTTPS URLs).
    • Normalized URLs for deterministic matching and cached parsed allowlist state.
    • Kept behavior intact for allowed URLs while failing closed when allowlist is unset.
  • Error disclosure remediation (internal/handlers/ai.go, internal/handlers/cve.go, internal/handlers/suspicious.go)

    • Replaced http.Error(..., err.Error(), ...) responses in scoped sinks with generic client-safe messages.
    • Preserved diagnostics through server-side logging (log.Printf(...)) instead of returning internals to clients.
  • Focused regression coverage (internal/handlers/remediation_test.go)

    • Added targeted tests for:
      • non-HTTPS rejection
      • disallowed URL/path rejection
      • generic fetch failure response (no low-level network details)
      • allowlisted HTTPS success path
      • generic invalid-body handling in SafeAIAnswer
      • safe unsupported-tag response in ParseLanguage
safeURL, err := validatedToolURL(r.URL.Query().Get("url"))
if err != nil {
    http.Error(w, "invalid source url", http.StatusBadRequest)
    return
}
resp, err := http.Get(safeURL)

Copilot AI changed the title [WIP] Remediate selected batch of 4 units Harden handler URL fetching and error responses for Reachable shard 4 (CWE-319/918 + error disclosure) Jul 9, 2026
Copilot AI requested a review from al1dazzi July 9, 2026 15:16
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