← Back to Pull requests

Fix websocket proxy auth truncating passwords that contain a colon #2738

Closed
unknown closed this pull request without merging on Oct 14, 2026 17:07 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 07:11 UTC
Author

Problem

websocket_proxycare() decodes the proxy-authorization header for websocket calls (exec/attach/port-forward through an authenticated HTTP proxy) and splits the decoded user:pass string on every ::

auth = urlsafe_b64decode(b64value).decode().split(':')
connect_opt.update({'http_proxy_auth': (auth[0], auth[1]) })

Per RFC 7617, the password half of Basic auth credentials may contain : — only the user-id may not. A proxy password containing a colon (e.g. pa:ss:word) is silently truncated to the text before the first colon, so the websocket client authenticates to the proxy with the wrong password. A header with no colon at all (or just Basic with no credentials) raises an unhandled IndexError.

Root Cause

str.split(':') with no limit splits on every colon, and the code unconditionally indexes auth[0]/auth[1] assuming exactly two parts.

Solution

  • Split on the first colon only (split(':', 1)), so the rest of the password is preserved.

  • Only set http_proxy_auth when the split actually produced both halves, instead of indexing unconditionally — this turns the previous IndexError on a colon-less/malformed header into a no-op (same as if no proxy-authorization header were present).
  • Testing

  • Test added: extended the existing table-driven test_websocket_proxycare in kubernetes/stream/ws_client_test.py with two cases: a password containing colons (user:pa:ss:word), and a header with no colon at all (useronly).

  • Tests run: pytest kubernetes/stream/ws_client_test.py (24 passed) and pytest kubernetes/stream/ (full module, all passing).

  • Result: the new cases fail on master (AssertionError: ('user', 'pa') == ('user', 'pa:ss:word') for the colon case, IndexError: list index out of range for the no-colon case) and pass with this fix.
  • Related Issue

    Closes #2734

    Diff: 233 lines (+174 / -59) across 2 files Reviewer: roycaihw Review duration: 2036m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.60) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 233 lines diff across 2 files
    0.60
    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.326
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.060
    Real PR Conversation Timeline
    1 comments
    "Review active on #2738"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    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: 60.3% (MEDIUM) · Higher = larger blast radius
    60.3%
    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: 23.8% · Safe to merge
    23.8%