Websocket proxy auth truncates passwords that contain a colon
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Start in kubernetes/stream/ws_client.py at the credential split around line 602, then inspect nearby tests for websocket_proxycare. Reproduce with the provided snippet, including a password containing colons and malformed credentials. Done when the full password is preserved and malformed headers no longer raise an uncaught IndexError, with tests covering both cases.
Written by the indexing model from the issue text.
Description
What happened (please include outputs or screenshots):
While testing an experimental version of Perch, we found the following and figured it was worth a report.
websocket_proxycare splits the decoded proxy-authorization credentials on every : and keeps only the first two parts. A proxy password that contains a colon is cut off, so websocket calls (stream for exec, attach and port-forward) through an authenticated proxy send the wrong password.
import base64
from types import SimpleNamespace
from kubernetes.stream.ws_client import websocket_proxycare
cred = base64.b64encode(b"alice:pa:ss:word").decode()
cfg = SimpleNamespace(no_proxy=None, proxy="http://proxy:3128",
proxy_headers={"proxy-authorization": "Basic " + cred})
print(websocket_proxycare({}, cfg, "wss://h", {})["http_proxy_auth"])
# ('alice', 'pa')
The same code raises IndexError: list index out of range when the header is just Basic, or when the decoded value has no colon.
What you expected to happen:
('alice', 'pa:ss:word'). RFC 7617 allows colons in the password; only the user-id can't contain one.
How to reproduce it (as minimally and precisely as possible):
Run the snippet above against master. No cluster is needed.
Anything else we need to know?:
The split is at kubernetes/stream/ws_client.py:602:
auth = urlsafe_b64decode(b64value).decode().split(':')
connect_opt.update({'http_proxy_auth': (auth[0], auth[1]) })
split(':', 1) would keep the full password.
Environment:
- Kubernetes version (
kubectl version): not needed, no cluster involved - OS (e.g., MacOS 10.13.6): macOS 26.2 (arm64)
- Python version (
python --version): 3.14.2 - Python client version (
pip list | grep kubernetes): 37.0.0+snapshot (master, bb9199f7)
- Dominant language
- Python
- Stars
- 7.7k
- Forks
- 3.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kubernetes-client/python
-
getheaders is deprecated in urllib3 >= 2.0.0May be free again A pull request for this issue was closed without being merged. Openkind/bug
Difficulty 1/5 Under an hour Newbie friendliness 68/100
kubernetes-client/python#2280 · 16 comments · 9 reactions ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
kubernetes-client/python#2733 · 2 comments ·
Maintainers usually reply within 1 day
-
Growing library sizeOpenhelp wanted
Difficulty 5/5 Over a week Newbie friendliness 35/100
kubernetes-client/python#2677 · 15 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Add option to disable strict x509 verifcation in sync clientPossibly taken @Vishwa0223 claimed this 49 days ago. Openhelp wanted kind/feature
kubernetes-client/python#2602 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
v36.0.0 regression fetching container logsMay be free again @yliaog claimed this 88 days ago, and no pull request is open. Openkind/bug
kubernetes-client/python#2596 · 16 comments · 2 reactions · 1 assignee ·
Maintainers usually reply within 1 day
All issues in kubernetes-client/python
Similar issues
-
area: agents area: docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openapi/gknowledge#23 ·
-
get() for StrEnumPossibly taken @FeJo5952 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
collective/icalendar#1921 · 1 comment ·
Maintainers usually reply within 1 day
-
Improvement Python Spans
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getsentry/sentry-python#7994 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
alphagov/notifications-api#5004 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
equinor/radix-flux#3922 ·
Maintainers usually reply within 1 day