GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(google-auth-oauthlib): prevent ipv6 address reuse by daniel-sanche · Pull Request #18463 · googleapis/google-cloud-python

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Extending the solution in #18166

We previously added a guard to prevent external processes sitting on the same port, and hijacking oauth calls. This PR extends that logic to also prevent processes using the ipv6 address

Fixes: #18296

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction
daniel-sanche added 5 commits September 18, 2026 22:45
@daniel-sanche
prevent ipv6 squatting
fbeb5cc
@daniel-sanche
fixed review feedback
f87a915
@daniel-sanche
improved comments, prevent close
5ed3951
@daniel-sanche
improve comments
4b19e26
@daniel-sanche
added context
09f2b2f
@daniel-sanche
daniel-sanche requested a review from a team as a code owner September 24, 2026 22:33
gemini-code-assist[bot]
gemini-code-assist Bot reviewed Sep 24, 2026
View reviewed changes

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances security by reserving the IPv6 loopback address (::1) when binding to localhost during the OAuth flow, preventing other processes from intercepting the callback. It also updates port availability checks and adds corresponding unit tests. The feedback suggests refactoring a complex lambda expression in the unit tests that uses a generator to raise an exception, replacing it with a cleaner and more idiomatic local helper function.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-auth-oauthlib/tests/unit/test_interactive.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

daniel-sanche and others added 5 commits September 24, 2026 16:02
@daniel-sanche
addressed PR feedback
0f706f0
@daniel-sanche
Merge branch 'main' into fix_auth_windows_approach_G
ba772a2
@daniel-sanche
fix lint
91975d5
@daniel-sanche
moved attribute to init
d3ea5f7
@daniel-sanche
removed duplicate code
227a8f6
ohmayr
ohmayr reviewed Sep 25, 2026
View reviewed changes
Comment thread packages/google-auth-oauthlib/google_auth_oauthlib/interactive.py Outdated
# Also verify that no process is already listening on IPv6 loopback (::1).
if is_open and hasattr(socket, "AF_INET6"):
is_open = (
not google_auth_oauthlib.flow._ExclusiveWSGIServer._is_listener_present(

@ohmayr ohmayr Sep 25, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to use _is_listener_present outside of the class scope like this, then we should consider promoting it to is_listener_present.

Alternatively, I noticed that it's a static method, so you can keep it as _is_listener_present but move it out of the class.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I renamed the function

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-auth-oauthlib/google_auth_oauthlib/flow.py Outdated
# the port while the browser falls back from `::1` to `127.0.0.1`.
try:
self._ipv6_socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
if sys.platform == "win32" and hasattr(socket, "SO_EXCLUSIVEADDRUSE"):

@ohmayr ohmayr Sep 25, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I see a couple of instances of this check and the follow up call. Maybe, we can extract this logic into its own function.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@daniel-sanche daniel-sanche Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-auth-oauthlib/google_auth_oauthlib/flow.py Outdated
"""
try:
with socket.socket(family, socket.SOCK_STREAM) as probe:
probe.settimeout(0.1)

@ohmayr ohmayr Sep 25, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we define a class level variable for this hardcoded timeout? Something like:

_PROBE_TIMEOUT_SECONDS = 0.1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daniel-sanche reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@daniel-sanche daniel-sanche Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/google-auth-oauthlib/google_auth_oauthlib/flow.py Outdated
super().__init__(*args, **kwargs)

@staticmethod
def _is_listener_present(family, addr, port):

@ohmayr ohmayr Sep 25, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding type hints.

Suggested change
def _is_listener_present(family, addr, port):
def _is_listener_present(family: int, addr: str, port: int) -> bool:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daniel-sanche reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@daniel-sanche daniel-sanche Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daniel-sanche
addressed PR comments
a816a7c
ohmayr
ohmayr approved these changes Sep 28, 2026
View reviewed changes
@ohmayr
ohmayr merged commit 30b4f44 into main Sep 28, 2026
112 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ohmayr
ohmayr deleted the fix_auth_windows_approach_G branch September 28, 2026 21:49
@release-please release-please Bot mentioned this pull request Sep 28, 2026
chore: release main #18464
Merged
JoeWang1127 pushed a commit that referenced this pull request Sep 29, 2026
@release-please
chore: release main (#18464)
d6bed5a
🤖 I have created a release *beep* *boop*
---


<details><summary>django-google-spanner: 5.2.0</summary>

##
[5.2.0](django-google-spanner-v5.1.0...django-google-spanner-v5.2.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>gapic-generator: 1.41.0</summary>

##
[1.41.0](gapic-generator-v1.40.0...gapic-generator-v1.41.0)
(2026-09-29)


### Features

* **gapic-generator:** add schema support for resumable uploads
([#18480](#18480))
([78ff458](78ff458))


### Bug Fixes

* **gapic-generator:** init mock response in version header test
([#18488](#18488))
([7871fa9](7871fa9))
</details>

<details><summary>google-api-core: 2.40.0</summary>

##
[2.40.0](google-api-core-v2.39.0...google-api-core-v2.40.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-auth-httplib2: 0.4.3</summary>

##
[0.4.3](google-auth-httplib2-v0.4.2...google-auth-httplib2-v0.4.3)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-auth-oauthlib: 1.5.0</summary>

##
[1.5.0](google-auth-oauthlib-v1.4.1...google-auth-oauthlib-v1.5.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))


### Bug Fixes

* **google-auth-oauthlib:** prevent ipv6 address reuse
([#18463](#18463))
([30b4f44](30b4f44))
</details>

<details><summary>google-cloud-bigtable: 2.48.0</summary>

##
[2.48.0](google-cloud-bigtable-v2.47.0...google-cloud-bigtable-v2.48.0)
(2026-09-29)


### Features

* **bigtable:** Reroute Mutations Batcher to use data client
([#18200](#18200))
([0b488a3](0b488a3))
* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-core: 2.8.0</summary>

##
[2.8.0](google-cloud-core-v2.7.0...google-cloud-core-v2.8.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-dns: 0.37.2</summary>

##
[0.37.2](google-cloud-dns-v0.37.1...google-cloud-dns-v0.37.2)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-documentai-toolbox: 0.17.4</summary>

##
[0.17.4](google-cloud-documentai-toolbox-v0.17.3...google-cloud-documentai-toolbox-v0.17.4)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-firestore: 2.33.0</summary>

##
[2.33.0](google-cloud-firestore-v2.32.0...google-cloud-firestore-v2.33.0)
(2026-09-29)


### Features

* **firestore:** add BSON cross-type query ordering support
([#18405](#18405))
([13be295](13be295))
* **firestore:** add BSON read deserialization support
([#18402](#18402))
([ce2544f](ce2544f))
* **firestore:** add PyMongo duck-typing serialization support
([#18406](#18406))
([a1e0e00](a1e0e00))
</details>

<details><summary>google-cloud-ndb: 2.7.0</summary>

##
[2.7.0](google-cloud-ndb-v2.6.1...google-cloud-ndb-v2.7.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-runtimeconfig: 0.37.2</summary>

##
[0.37.2](google-cloud-runtimeconfig-v0.37.1...google-cloud-runtimeconfig-v0.37.2)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-cloud-storage: 3.15.1</summary>

##
[3.15.1](google-cloud-storage-v3.15.0...google-cloud-storage-v3.15.1)
(2026-09-29)


### Bug Fixes

* **storage:** add correct app hub uri prefix to aco traces
([#18483](#18483))
([7cead02](7cead02))
</details>

<details><summary>google-cloud-testutils: 1.10.0</summary>

##
[1.10.0](google-cloud-testutils-v1.9.3...google-cloud-testutils-v1.10.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>google-resumable-media: 2.11.0</summary>

##
[2.11.0](google-resumable-media-v2.10.2...google-resumable-media-v2.11.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

<details><summary>googleapis-common-protos: 1.75.5</summary>

##
[1.75.5](googleapis-common-protos-v1.75.4...googleapis-common-protos-v1.75.5)
(2026-09-29)


### Bug Fixes

* resolve error where google/longrunning/operations.proto is missing
([#18477](#18477))
([e1d306a](e1d306a)),
refs
[#18478](#18478)
</details>

<details><summary>proto-plus: 1.29.0</summary>

##
[1.29.0](proto-plus-v1.28.4...proto-plus-v1.29.0)
(2026-09-29)


### Features

* declare Python3.15 support
([05b0c34](05b0c34))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ohmayr ohmayr ohmayr approved these changes
+1 more reviewer
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

google-auth-oauthlib: run_local_server advertises http://localhost:PORT but binds IPv4 only, so on Windows the OAuth callback can be silently delivered to another process

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@daniel-sanche @ohmayr
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.