← Back to Pull requests

fix: prevent credential-bearing HTTP downgrades #2704

Closed
unknown closed this pull request without merging on Oct 14, 2026 15:36 UTC
View on GitHub
unknown unknown commented on Oct 08, 2026 13:45 UTC
Author

<!-- entire-trail-link-start -->
https://entire.io/gh/entireio/cli/trails/1522
<!-- entire-trail-link-end -->

Summary

Close credential-bearing HTTPS-to-HTTP downgrade paths in the remote-helper proxy, API client, control-plane client, cloud dispatch client, and cell catalog resolver.

  • Add a shared redirect floor: once a chain reaches HTTPS, no later hop may leave it, including HTTP → HTTPS → HTTP and redirects to loopback. Preserve each client's existing host policy, hop cap, and stricter injected callbacks without mutating supplied clients.

  • Validate remote-helper replica schemes at cache/header/Location ingress and before requests. Permit HTTP only for loopback replicas of an explicitly HTTP loopback entry; never resume HTTP after reaching HTTPS, including manual failover. SkipTLS does not authorize plaintext.

  • Reject absolute HTTP API endpoints against an HTTPS base URL.

  • Guard ordinary control-plane HTTP redirects independently of auth-go's 421 routing and OAuth exchange protections.

  • Revalidate destinations after caller-supplied redirect callbacks return nil; preserve callback errors and http.ErrUseLastResponse unchanged.

  • Document the transport policy and add wiring-level regression coverage for all five flows, all five redirect statuses, callback URL rewrites, HTTP replica ingress, and development compatibility.
  • Thanks to @wernerkasselman-au for responsibly reporting these HTTPS-to-HTTP downgrade paths and providing detailed follow-up findings that helped strengthen the fix.

    Context

    Follow-up to the class addressed in #2224 and #2261 / entireio/auth-go#25. Those fixes protect OAuth clients; these CLI-owned bearer-header clients need their own redirect policy. The API client's existing cross-host guard remains essential because its transport reapplies Authorization.

    The reported redirect scenarios require a server-issued downgrade. This change does not establish that an untrusted repository alone can trigger credential theft, or that production servers issue such redirects.

    Verification

  • Confirmed regression tests fail before their fixes: plaintext destinations receive requests in all five flows, HTTP replicas pass validation, and a callback URL rewrite bypasses the pre-callback check.

  • Recording transports keep hostname and port identical so a cross-host guard cannot conceal the scheme bug; tests assert rejected destinations receive no request.

  • Affected packages pass under go test -race.

  • mise run fmt and mise run lint pass; lint rerun on the final tree before push.

  • mise run test:e2e:canary passes: 56 Vogon scenarios and 4 Roger Roger scenarios.

  • Latest required pre-commit mise run check passes in full, including lint, unit/integration tests with race detection, and deterministic canaries. The earlier local OpenCode seed-cache failure did not recur on this run.
  • <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    High Risk

    Changes authentication and git transport security boundaries (redirect handling, replica URL validation, and bearer attachment); regressions could break local dev loopback or block legitimate redirects.

    > Overview

    Closes paths where bearer tokens could be sent over plaintext after an HTTPS hop or via poisoned replica URLs. A shared CheckSecureRedirect / WithSecureRedirects floor is wired into the API client, cloud dispatch client, cell catalog resolver, and git remote-helper proxy.

    > Shared redirect policy: Once a redirect chain reaches HTTPS, later hops cannot leave it (including loopback HTTP). Existing per-client host rules and injected CheckRedirect callbacks are preserved via WithSecureRedirects.

    > API client: Redirect handling delegates to the shared guard; requireSameHost also rejects absolute http:// endpoints when the base URL is HTTPS.

    > Remote-helper proxy: Replica URLs are scheme-checked at cache/header/Location ingress and before auth stamping. HTTPS is required except HTTP loopback replicas of an explicit HTTP loopback entry; requireHTTPS sticks after any HTTPS contact so manual failover cannot downgrade. SkipTLS does not allow plaintext.

    > Tests & docs: httpclienttest.CheckRejectsDowngrade exercises all four flows across redirect status codes; proxy ingress/downgrade cases are covered. docs/development/api-routing.md documents the transport policy.

    > <sup>Reviewed by Cursor Bugbot for commit 31f67c4a9afd17a27b4097d08176f05a07669deb. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 581 lines (+435 / -146) across 7 files Reviewer: hiddeco Review duration: 8750m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 581 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.381
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2704"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%
    Repository