Repository navigation
Refuse a cross-origin redirect of the OAuth2 user info request - #350
Merged
Merged
Conversation
The oauth2 transport adds the access token to every redirect hop, so a user info URL answering with a redirect to another host sent the token there. The info request now uses a copy of the client whose redirect policy runs any existing CheckRedirect first, keeps the default 10-hop cap when there is none, and stops at a hop off the scheme, host and port of InfoURL. The login then fails with 503 and logs only the redirect status, so a signed Location stays out of the log. The avatar client keeps its own redirect policy. Also drops the unreachable Transport nil check in avatarClient and the comments in the avatar tests.
With no client redirect policy, the 10-hop cap returned a plain error before the origin check. Go's HTTP client wraps that error with the raw Location of the refused hop, and the login handler logs it, so a signed URL on the hop past the cap reached the log. The cap now stops with the last redirect response, like the origin refusal, and the login answers 503 with only the status in the log. The README note on the refused redirects becomes a versioned behaviour change block, with the HTTP-to-HTTPS case and the xn-- form for redirect targets.
Coverage Report for CI Build 46100781025Coverage decreased (-0.2%) to 88.598%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
umputun
added a commit
that referenced
this pull request
Nov 28, 2026
…Telegram GetUpdates error path (#351) * Report coverage to Coveralls from the v2 workflow only When both workflows ran, they uploaded separate v1 and v2 profiles to the same Coveralls repo. A PR could then be compared with a master build for the other module: #350 showed -0.2% while its v1 coverage went up. The v1 workflow now keeps its coverage profile but no longer uploads it, and drops the statuses permission only goveralls used. * Test that Telegram keeps polling after a GetUpdates error Coverage of the GetUpdates error path depended on poll timing in the confirmed-request test, so the same commit reported different coverage from run to run. A test with a GetUpdates that always fails now takes the log-and-continue branch of the Run poll loop on every run and checks that polling goes on after the error. * Add backlog items for two Telegram Run defects Run keeps its running mark after a BotInfo error, which blocks a later ProcessUpdate, and an init timeout in setupHandler skips cancel and join, which can leave Run running. Both surfaced in the review of this branch and predate it.
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.
follow-up to #349. The oauth2 transport adds the user's access token to every redirect hop, so a user info URL that answered with a redirect could send the token across origins. That path predates #349, which only covered the avatar fetch.
CheckRedirectfirst and keeps its errors. With that passed, it stops at a hop off the scheme, host and port ofInfoURL, and, when the client has no policy, before the eleventh request. A refusal by this guard answers the login with 503 and logs only the redirect status, so a signedLocationstays out of the loghttp://tohttps://on the same host included, now fails the login. To follow a same-origin redirect on an internationalized host, write the host in itsxn--form inInfoURLand in any absolute redirect targetTransportnil check inavatarClientand the comments in the avatar testsv1 and v2 carry the same change.