Skip to main content
Menu
Advisories

Cross-Site Request Forgery in the Azure Functions Isolated Worker via Missing Content-Type

GHSA-466M-6VPQ-3FMPPublished Updated GitHub

Description

In Azure Functions apps that use the isolated worker model (HotChocolate.AzureFunctions.IsolatedProcess), Hot Chocolate treats a request without a Content-Type header as application/json. A web page on another origin can send a POST without a Content-Type. That is a CORS simple request, which a browser sends without a preflight and with the user's cookies, and Hot Chocolate executes it as a GraphQL request, including mutations. The ASP.NET Core endpoint mapped by MapGraphQL() and the in-process Azure Functions model refuse the same request.

The same default lets a GET request without the GraphQL-Preflight header through when EnforceGetRequestsPreflightHeader is enabled.

An application is affected when both of the following hold:

  • It hosts Hot Chocolate in the Azure Functions isolated worker model.
  • It authenticates requests with credentials that the browser attaches automatically, such as cookies. That includes cookies with any SameSite value when the attacking page is on the same site, for example on another subdomain.

Fixed Versions

The vulnerability is fixed in the following releases:

  • 16.6.9
  • 15.1.19
  • 14.3.3
  • 13.9.18

Impact

A page that a signed-in user visits can execute GraphQL operations, including mutations, with that user's identity. It cannot read the responses, so the impact is the effect of the operations it runs. With EnforceGetRequestsPreflightHeader enabled, the GET case runs queries only, so it matters only for queries with side effects.

This issue is classified as CWE-352: Cross-Site Request Forgery (CSRF).

Recommendation

Upgrade to one of the fixed releases. A request without a Content-Type header is then answered as it is on MapGraphQL(), so a client that sends a JSON body must send Content-Type: application/json.

If an immediate upgrade is not possible, refuse a POST without a Content-Type header in the function, before it reaches Hot Chocolate:

[Function("GraphQLHttpFunction")]
public Task<HttpResponseData> Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, Route = "graphql/{**slug}")]
    HttpRequestData request)
{
    if (string.Equals(request.Method, "POST", StringComparison.OrdinalIgnoreCase)
        && !request.Headers.Contains("Content-Type"))
    {
        return Task.FromResult(request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
    }

    return _executor.ExecuteAsync(request);
}

If EnforceGetRequestsPreflightHeader is enabled, also refuse a GET that carries neither a GraphQL-Preflight header nor a Content-Type header.

Affected versions

References

GitHub · ChilliCream/graphql-platform