Qingjun Wu created KAFKA-21686:
----------------------------------

             Summary: SASL expiring-credential re-login can fire long after the 
credential expires when the host is suspended
                 Key: KAFKA-21686
                 URL: https://issues.apache.org/jira/browse/KAFKA-21686
             Project: Kafka
          Issue Type: Bug
          Components: security
            Reporter: Qingjun Wu


ExpiringCredentialRefreshingLogin's refresher thread waits for the whole 
interval until
the next re-login with a single time.sleep(nextRefreshMs - nowMs). Time.sleep 
is backed
by Thread.sleep, whose timeout is relative and measured against a monotonic 
clock that
does NOT advance while the host is suspended (laptop OS sleep, or a paused / 
live-migrated
VM). If the host is suspended while the thread is in that sleep, on resume the 
sleep keeps
counting its original relative duration, so the OAUTHBEARER/SASL token can 
expire
(wall-clock) well before the re-login runs. The client then keeps presenting an 
expired
token and authentication fails until the sleep finally elapses.

Observed in a multi-day soak test: after a ~4-hour laptop suspend, 
SASL/OAUTHBEARER
workloads kept failing with invalid_token even though fresh tokens were 
available, and did
not recover until the thread's sleep elapsed (or the client was restarted).

Proposed fix: wait in bounded chunks and re-read the wall clock after each 
chunk, so after
a resume the thread notices the deadline has passed and re-logins within one 
chunk instead
of up to the full interval. No public interface change.

(Related but out of scope: a failed re-authentication does not itself trigger 
an early
refresh — a larger change.)



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to