[Bug] Interactive auth callback hangs forever when an idle connection reaches AuthCodeReceiver first
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- python
- Domaine
- authentication, backend
Piste de recherche
Start by reading AuthCodeReceiver and its use of HttpServer; the issue identifies synchronous request handling and a connection accepted before the OAuth POST as the suspected path. Reproduce the flow with an idle connection reaching the listener first, then check that the real OAuth POST is processed and az login completes. The issue does not name a test file.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
When I run az login in my VS code terminal (using the VS Code SSH extension to connect to my Linux VM), it either succeeds, or it hangs forever after I log in via the browser until I close the browser and cancel the command. If I retry a couple of times, sometimes 1 succeeds. (Sometimes I spam 10x and it'll work once - fairly annoying).
To Reproduce
Steps to reproduce the behavior:
- Use the VS Code SSH extension to connect to a Linux VM
- az login on the VM (not with device code, this is using interactive auth via the browser)
- Login using the browser
- Login either works fine, or hangs forever
Expected behavior
The normal flow, looking at the code-
- az cli asks MSAL to perform interactive auth
- MSAL creates a temp HTTP server on a port and registers a redirect URI
- az cli opens the entra login auth page in the browser
- after auth, entra should be returning an HTML form that the browser POSTs to the redirect URI
- VS Code remote SSH forwards the local connection to that port on the Linux machine
- MSAL reads the auth code from the POST and does the token exchange
TLDR: the local browser should POST to the localhost port on the VS code tunnel, then to the MSAL HTTP server, before returning the auth code to az cli.
What you see instead
- MSAL was listening on the redirect port, ex. 39397
- An idle TCP connection arrives from a different ephemeral source port (this could really be from anything, but I'm guessing it has to do with the VS code remote SSH behavior - I think it shouldn't matter, though).
- MSAL accepted that connection
- It was an empty connection - no requests arrive
- The real OAuth POST arrives from a different port
- The real OAuth POST sits in the server's request queue forever
Accepted idle connection:
127.0.0.1:39397 <-> 127.0.0.1:40890
Recv-Q: 0
Queued real callback:
127.0.0.1:39397 <-> 127.0.0.1:40902
Recv-Q: 3026
The MSAL Python version you are using
- Azure CLI: 2.89.0
- MSAL Python: 1.36.0
- Also present in MSAL Python 1.37.0 source
- Python: Azure CLI bundled Python 3.14
- OS: Ubuntu 22.04
- Client: VS Code Remote SSH with a Windows browser
Additional context
I think this is a race condition and if the OAuth connection reaches the listening port first, everything works fine.
A few things I noticed:
- AuthCodeReceiver is using HttpServer, which I think is singled threaded. I can't find the GitHub link, but looking at the handler in Python source it looks like we process the request synchronously and don't accept another connection until the handler is done
self._server.timeout = timeoutin AuthCodeReceiver is for accepting new requests, but this hang should be happening after the initial accept - we're just waiting for the request bytes
- Langage dominant
- Python
- Étoiles
- 971
- Forks
- 223
- Merge moyen
- 13 h 48 min
- PR mergées (30 j)
- 2
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de AzureAD/microsoft-authentication-library-for-python
-
needs attention untriaged
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
AzureSDK bug P1
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
http_client docstring does not say that timeout, verify and proxies only configure the default sessionPeut-être pris @HardMax71 l’a pris il y a 38 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 25/100
-
[Bug] The built-in retry never retries the token POST: HTTPAdapter(max_retries=1) keeps urllib3's default allowed_methodsPeut-être pris @HardMax71 l’a pris il y a 44 jours. Ouvertebug untriaged
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
AzureAD/microsoft-authentication-library-for-python#957 · 3 commentaires ·
-
public-client untriaged
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
Toutes les issues de AzureAD/microsoft-authentication-library-for-python
Issues similaires
-
comp/cli P3 type/security
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
NousResearch/hermes-agent#141420 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
vendor-pitch
Difficulté 2/5 1-3 heures Accessibilité débutants 87/100
Les mainteneurs répondent en général sous 1 jour
-
bug llm p2
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
amd/gaia#5379 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
New tool: ZIPZAX Python Notebook StudioPeut-être pris @github-actions l’a pris aujourd’hui. Ouvertesubmission triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
kausalflow/tools#226 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100