[Bug] ASGI cookie conversion serializes an absent Domain attribute and breaks __Host- cookies
Maintainer antworten meist innerhalb von 4 Tagen
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Beginne in workers/azure_functions_worker/bindings/datumdef.py ungefähr bei den Zeilen 232–245 und führe anschließend die zugehörigen Tests in workers/tests/unittests/test_http_functions.py ungefähr bei den Zeilen 374–379 aus. Füge einen Regressionstestfall für die bereitgestellte __Host-test-Antwort hinzu und überprüfe, dass fehlende Domain-Attribute weggelassen werden, während explizite Domains weiterhin serialisiert werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Expected Behavior
This surfaced in FastMCP issue #4748. FastMCP's OAuth consent flow emits a valid __Host- cookie, but when the application runs on Azure Functions, the browser receives a Domain attribute and rejects it.
Azure Functions should preserve the absence of Domain in this ASGI response:
Set-Cookie: __Host-test=value; Path=/; Secure; HttpOnly; SameSite=Lax
__Host- cookies require Secure, Path=/, and no Domain attribute.
Actual Behavior
The Python ASGI response path parses Set-Cookie into a structured cookie and serializes the missing domain as a present, empty domain. The final response contains domain= or surfaces the Function App hostname as its effective domain. Browsers therefore reject the __Host- cookie; in FastMCP this causes the consent POST's CSRF check to fail.
Steps to Reproduce
- Deploy the ASGI application below to Azure Functions.
- Request its HTTP endpoint over HTTPS.
- Inspect the final
Set-Cookieheader and the browser cookie warnings. - Observe that the response includes a Domain attribute and the browser rejects
__Host-test.
Relevant code being tried
import azure.functions as func
async def asgi_app(scope, receive, send):
assert scope["type"] == "http"
await send(
{
"type": "http.response.start",
"status": 200,
"headers": [
(b"content-type", b"text/plain"),
(
b"set-cookie",
b"__Host-test=value; Path=/; Secure; HttpOnly; SameSite=Lax",
),
],
}
)
await send(
{
"type": "http.response.body",
"body": b"ok",
"more_body": False,
}
)
app = func.AsgiFunctionApp(
app=asgi_app,
http_auth_level=func.AuthLevel.ANONYMOUS,
)
Relevant log output
No application error is logged. The failure appears in the response header and browser cookie warning.
requirements.txt file
azure-functions==1.24.0
Where are you facing this problem?
Production Environment
Function app name
Not publicly shareable
Additional Information
azure-functions-python-library removes the raw header and parses it with SimpleCookie:
https://github.com/Azure/azure-functions-python-library/blob/dev/azure/functions/http.py#L113-L116
The worker then passes the empty cookie_entity['domain'] value to to_nullable_string, creating a present RPC domain:
https://github.com/Azure/azure-functions-python-worker/blob/dev/workers/azure_functions_worker/bindings/datumdef.py#L232-L245
The existing end-to-end test expects an attribute-free cookie to become foo=bar; domain=; path=:
https://github.com/Azure/azure-functions-python-worker/blob/dev/workers/tests/unittests/test_http_functions.py#L374-L379
A targeted fix would omit the RPC domain when cookie_entity['domain'] is empty while preserving explicit domains. A __Host- regression test can verify that the final response contains Path=/; Secure and no Domain.
- Vorherrschende Sprache
- Python
- Sterne
- 357
- Forks
- 119
- Ø Merge
- 4 T. 8 Std.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Azure/azure-functions-python-worker
-
Linux ARM64 packaging omits worker modules and generates protos incompatible with bundled runtimesEvtl. vergeben @hallvictoria hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Azure/azure-functions-python-worker#1924 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 28/100
Azure/azure-functions-python-worker#1908 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
Azure/azure-functions-python-worker#1906 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Azure/azure-functions-python-worker#1904 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
[Python 3.14 proxy worker] Missing sys.modules["__main__"] breaks multiprocessing spawnEvtl. vergeben @Fire162 hat das vor 16 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
Azure/azure-functions-python-worker#1903 ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in Azure/azure-functions-python-worker
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
pytest-dev/pytest-html#1085 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
pollen-robotics/reachy_mini#1527 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
A seed and its negative give the same run, so realizations of a negative seed repeat each otherOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag