Fix GitHub App authentication on runners with minor clock drift#2289
Open
aholstrup1 wants to merge 3 commits into
Open
Fix GitHub App authentication on runners with minor clock drift#2289aholstrup1 wants to merge 3 commits into
aholstrup1 wants to merge 3 commits into
Conversation
Backdate the JWT 'iat' claim by 60 seconds instead of 10, as recommended by GitHub, so GitHub App authentication tolerates up to ~60s of clock drift instead of ~10s. Fixes 401 errors on self-hosted runners whose clock runs ahead of GitHub's. Fixes #2284
…-app-jwt-clock-drift
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make GitHub App authentication more tolerant of minor clock drift on self-hosted runners by adjusting the JWT iat backdating and documenting the change in release notes.
Changes:
- Backdate the GitHub App JWT
iatclaim by 60 seconds (previously 10) inGenerateJwtForTokenRequest. - Add a release note entry for Issue #2284 describing the JWT clock-drift tolerance change.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
Actions/Github-Helper.psm1 |
Adjusts JWT iat backdating intended to reduce 401s caused by runner clock drift. |
RELEASENOTES.md |
Documents the Issue #2284 fix and its intended behavior. |
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.
Why
GitHub App authentication intermittently failed with
401 (Unauthorized)during steps like "Download Project Dependencies", but only on self-hosted runners. The same repo, project, App, and dependency worked fine on GitHub-hosted runners. The differentiator was the runner's clock.Root cause
GenerateJwtForTokenRequestbackdated the JWTiat("issued at") claim by only 10 seconds. GitHub rejects a JWT whoseiatis in its future. A self-hosted runner whose clock runs more than ~10 seconds ahead of GitHub therefore produces a future-datediat, and the JWT-only call (GET /repos/.../installation, made before any installation token exists) gets a 401. GitHub-hosted runners are tightly time-synced, so they never hit this.Fix
Backdate
iatby 60 seconds instead of 10, as recommended by GitHub, to tolerate runners whose clock runs slightly ahead. Theexpclaim is left at 10 minutes (already within GitHub's "no more than 10 minutes into the future" limit).This is intentionally minimal: a one-line change to the backdate plus a release note. Keeping the runner clock synchronized (e.g. via NTP) is still recommended, but AL-Go now tolerates the small drift commonly seen on self-hosted runners.
Fixes: #2284