Repository navigation
Stop leaking an OIDC session on every client-credentials token refresh - #2257
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the OAuth2 session-reuse changes.
No open issues 🎉
What changed in this PR
Fixes OIDC session leaks during client-credentials token refresh by reusing the connection’s existing OAuth2 session instead of creating a new one each time.
Changes:
- Uses the existing session for both sync and async refreshes, reducing each refresh to one token request.
- Suppresses refresh-failure warnings when synchronous shutdown is already underway.
- Adds regression coverage for credential-based refreshes, session leaks, and bearer tokens without refresh tokens.
| File | Description |
|---|---|
weaviate/connect/v4.py |
Reuses OAuth2 sessions for token renewal and suppresses shutdown-related warnings. |
mock_tests/test_auth.py |
Extends sync and async refresh tests and checks that nonrenewable bearer tokens start no refresher. |
Review effort: Balanced
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2257 +/- ##
==========================================
+ Coverage 89.41% 89.43% +0.02%
==========================================
Files 314 314
Lines 24861 24886 +25
==========================================
+ Hits 22229 22257 +28
+ Misses 2632 2629 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Proov triage
Advisory, generated by Proov (deepseek-v4.1-flash) at 8c61af5. The review follows. |
|
Proov review: approve-with-comments The fix itself looks right — the refresher now renews on the session it owns, and the security pass confirms the grant is unchanged. What's missing is proof: the new
Nits: CI is green (129 success, 1 skipped). review-branch@c31ceb2 · deepseek-v4.1-flash · tests not run · advisory |
Each refresh of a client-credentials token built a new OAuth2Client, requested two tokens on it and never closed it. Every round left behind a connection pool and its SSL context, plus one transport per configured proxy now that the session follows the connection's proxies.
The refresher now calls fetch_token() on the client's own session, which already holds the client id, secret, scope and token endpoint. A round sends one token request and builds nothing.
A sync close() that lands while a refresh is in flight no longer warns that the token issuer could not be reached.