Repository navigation
Conversation
PluggableAuthCredentials passed the configured timeout_millis value straight to Timeout.timeout, which takes seconds. The default 30000 ms timeout therefore allowed the helper executable to run for over eight hours before being interrupted, and the documented 5-120 second bounds were never enforced at run time. Correcting the units alone was not enough. Open3.capture3 joins the child in an ensure block, so Timeout::Error only surfaced once the helper exited on its own, and each expiry printed reader-thread backtraces to stderr. Run the helper with Open3.popen3 in its own process group and apply a single deadline to the process wait and to reading stdout and stderr, so a background child that inherits the pipes cannot extend the wait. Raise CredentialsError when the deadline passes, matching the documented contract of retrieve_subject_token!, and send SIGKILL to the group from an ensure whenever the block exits before the helper has been reaped. That covers the deadline and also an interrupted caller, which would otherwise wait on a helper that no longer shares its terminal's process group. On Windows only the direct process is killed. Specs cover the millisecond-to-second conversion, a real process that outlives a sub-second deadline, a background child holding stdout open after the executable exits, and an Interrupt raised in the caller before the deadline. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
@googlebot I signed it! |
wtn
marked this pull request as ready for review
October 27, 2026 19:36
Member
|
@wtn The CLA check is failing for It's in your commit message: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PluggableAuthCredentials#retrieve_subject_token!readstimeout_millisfrom the executable credential source, defaults it to 30000, checks it against the documented 5000 to 120000 bounds, and then passes it unchanged tosubprocess_with_timeout, which hands it toTimeout.timeout.Timeout.timeouttakes seconds, so the default allows the helper to run for 30000 seconds, over eight hours, and the bounds check never constrains anything at run time.Converting the units is not enough on its own.
subprocess_with_timeoutwrapsOpen3.capture3, which runs insideOpen3.popen_run, whoseensurecloses the pipes and joins the child. WhenTimeoutraises inside the block, thatensurewaits for the helper to exit, so the error surfaces only after the helper finishes by itself, and each expiry prints twoIOError: stream closed in another threadbacktraces from the reader threads:subprocess_with_timeoutnow usesOpen3.popen3withpgroup: trueon POSIX, reads stdout and stderr on threads withreport_on_exceptionoff, and computes one monotonic deadline fromtimeout_millis / 1000.0. The process wait and both reader joins are bounded by the time remaining on that deadline, so a background child that inherits stdout cannot extend the wait past it. If any of them runs out, aGoogle::Auth::CredentialsErroris raised, as the method's@raisealready promised. Anensureon thepopen3block sendsSIGKILLto the process group whenever the block leaves before the helper has been reaped. That covers the deadline, and it also covers anInterruptin the caller, which the helper would otherwise outlive because its own process group no longer receives the terminal's Ctrl-C. On WindowsProcess.killreaches only the direct process, so no process group is requested there.The new specs fail on
mainand pass with this change.