Repository navigation
Description
Test environment: Local Kali Linux x86_64, Python 3.14.8, connector checkout declaring version 2.2.0 at commit 248ffd5896c7a46bba115452dc10b8389d3ede54. The driver source was unchanged.
Affected code: run_server() in:
redshift_connector/plugin/browser_azure_credentials_provider.pyredshift_connector/plugin/browser_azure_oauth2_credentials_provider.py
Bug: When the callback peer disconnects, recv() returns b''. Neither helper checks for this condition, so it keeps reading the ended connection. Each read finishes immediately; the socket-operation timeout therefore does not stop the loop.
Debugging tools used on Kali Linux: I used socat, pidstat, and GNU timeout to debug and reproduce the disconnect-handling issue, together with Python's cProfile and pytest for profiling and follow-up checks. The reproduction executed the actual extracted methods using local Unix socket pairs and an accept() shim.
Tools and roles:
socatclosed the peer endpoint without sending an authentication payload.pidstatindependently sampled the worker's CPU consumption.- Python's
cProfilerecorded the repeated native socketrecv()calls. - GNU
timeoutimposed backup limits on worker/client process lifetimes. pytestchecked scripted callback behavior and the evidence parsers. These were not complete browser sign-in tests.
Python signal watchdogs interrupted the measured loops at the test budget.
Reproduction: With driver/ and reports/ beside each other, run from their parent directory:
timeout -k 2s 45s python3 reports/collect_callback_evidence.pyObserved: In approximately 2.3 seconds, Azure made 1,195,639 recv() calls and Azure OAuth2 made 785,928. Both used roughly one CPU core and required watchdog interruption. As a control, open, idle connections correctly timed out with negligible CPU use in both the original methods and the copies with the proposed fix applied in memory.
Impact if unfixed: The authentication helper can remain busy without returning a result or connection error. Applications waiting for it could have stalled sign-in attempts and sustained client CPU consumption.
Proposed fix: Check for EOF immediately after receiving data, inside the existing with conn: block, before decoding or parsing:
part = conn.recv(size)
if not part:
raise InterfaceError("Connection closed before authentication completed")In-memory testing of this change made both disconnected cases exit after one read in approximately 2 milliseconds, while idle timeouts still worked. The patch has not been applied to the driver checkout, and complete authentication regression testing remains necessary.
Evidence attachment: redshift-auth-evidence-minimal.zip contains nine files: the reproduction script, combined results, two CPU logs, two readable profiles, environment metadata, the proposed patch, and a README. The local username and machine-specific paths have been redacted; recorded measurements are preserved. Upload the ZIP with the report and use the attachment link generated by the reporting form.
How to review the files: Extract the ZIP and open the redshift-auth-evidence-minimal/ folder. Start with README.md for the setup and testing limits, then follow this structure:
redshift-auth-evidence-minimal.zip
redshift-auth-evidence-minimal/
├── README.md Reproduction instructions and testing limits
└── reports/
├── collect_callback_evidence.py Script that reproduces the EOF/idle cases
└── evidence/
└── callback-eof-20261112T075315353916Z/
├── results.json Outcomes and measurements for all 12 cases
├── environment.json Python, platform, tools, and reviewed commit
├── azure-original-socat_eof.pidstat.txt Azure CPU measurements
├── oauth2-original-socat_eof.pidstat.txt OAuth2 CPU measurements
├── azure-original-socat_eof.profile.txt Azure recv() call counts
├── oauth2-original-socat_eof.profile.txt OAuth2 recv() call counts
└── proposed-eof.patch Suggested EOF check for both providers
Read results.json for the comparison, use the CPU logs and profiles to check the measured behavior, and review proposed-eof.patch for the suggested correction. The connector source is obtained separately at the reviewed commit and placed in driver/ beside reports/ before running the collector.
Activity