Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Bug] Interactive auth callback hangs forever when an idle connection reaches AuthCodeReceiver first

Đang mở
#950 2 bình luận 3 reaction 0 người được giao Xem trên GitHub

@Thanatos9404 đang làm issue này rồi.

Từ ngày 15/10/2026.

  • #971 của @Thanatos9404 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
authentication, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug public-client

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:

  1. Use the VS Code SSH extension to connect to a Linux VM
  2. az login on the VM (not with device code, this is using interactive auth via the browser)
  3. Login using the browser
  4. Login either works fine, or hangs forever

Expected behavior
The normal flow, looking at the code-

  1. az cli asks MSAL to perform interactive auth
  2. MSAL creates a temp HTTP server on a port and registers a redirect URI
  3. az cli opens the entra login auth page in the browser
  4. after auth, entra should be returning an HTML form that the browser POSTs to the redirect URI
  5. VS Code remote SSH forwards the local connection to that port on the Linux machine
  6. 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

  1. MSAL was listening on the redirect port, ex. 39397
  2. 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).
  3. MSAL accepted that connection
  4. It was an empty connection - no requests arrive
  5. The real OAuth POST arrives from a different port
  6. 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:

  1. 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
  2. self._server.timeout = timeout in AuthCodeReceiver is for accepting new requests, but this hang should be happening after the initial accept - we're just waiting for the request bytes
Ngôn ngữ chính
Python
Star
971
Fork
223
Merge trung bình
13 giờ 48 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AzureAD/microsoft-authentication-library-for-python

Tất cả issue của AzureAD/microsoft-authentication-library-for-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.