[Bug] ASGI cookie conversion serializes an absent Domain attribute and breaks __Host- cookies
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 68/100
Línea de trabajo
Comienza en workers/azure_functions_worker/bindings/datumdef.py alrededor de las líneas 232-245 y, después, ejecuta las pruebas relacionadas en workers/tests/unittests/test_http_functions.py alrededor de las líneas 374-379. Añade un caso de regresión para la respuesta __Host-test proporcionada y verifica que los atributos Domain ausentes se omitan, mientras que los dominios explícitos se siguen serializando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 357
- Forks
- 117
- Merge medio
- 9 d 27 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Azure/azure-functions-python-worker
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
Azure/azure-functions-python-worker#1908 · 2 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Azure/azure-functions-python-worker#1906 · 1 comentario ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
-
bug python
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Azure/azure-functions-python-worker#1887 · 1 reacción ·
Todos los issues de Azure/azure-functions-python-worker
Issues similares
-
pydanty:is-working
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pydantic/pydantic-ai#8843 ·
Los mantenedores suelen responder en 1 día
-
breaking change enhancement server
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
sktime/sktime#11310 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día