Validation Bypass and Denial of Service via Fail-Open Document Validation
Description
Hot Chocolate 16 document validation fails open in some cases: parts of an operation could be executed without being checked by every validation rule. This can terminate the server process with a stack overflow, and it lets operations past validation rules that the application relies on:
- The field cycle depth rule (
AddMaxAllowedFieldCycleDepthRule), which is part of the default security policy, and the execution depth rule (AddMaxExecutionDepthRule). - The introspection depth limits.
- The directive rules, so for example
@defercan be executed on a server that does not enable it. - The check for undeclared variables.
- Custom validation rules built on
DocumentValidatorVisitororTypeDocumentValidatorVisitor.
An application is affected when both of the following hold:
- It runs a Hot Chocolate 16 server (
AddGraphQLServer(),AddGraphQL(), orAddGraphQLFunction()with Azure Functions) or a Fusion gateway (AddGraphQLGatewayServer()orAddGraphQLGateway()). - It accepts operation documents from clients. This is the default. Applications that only execute persisted operations are not affected.
The process crash applies in the following cases:
- Fusion gateways, in the default configuration.
- Hot Chocolate servers from 16.7.0, in the default configuration.
- Hot Chocolate servers from 16.0.0 to 16.6.x, only when the cost analyzer is not registered, for example with
AddGraphQLServer(disableDefaultSecurity: true)or withAddGraphQL()on anIServiceCollection. With the cost analyzer, the request is answered with an error.
The validation rule bypasses apply to all affected versions.
Fixed Versions
- 16.7.3
Impact
An unauthenticated client can end the server or gateway process with a single request. A stack overflow cannot be caught in .NET, so every in-flight request and subscription is lost with the process, and the request can be repeated after each restart. The attacker needs almost no knowledge of the schema, and the request stays within the default request limits.
Independently of the crash, a client can run operations that the application's validation rules would reject, such as operations nested deeper than the field cycle depth or execution depth rules allow, or operations using directives the schema does not enable. Cost limits still apply, and authorization of fields is not bypassed.
This issue is classified as CWE-636: Not Failing Securely ('Failing Open').
Recommendation
Upgrade to 16.7.3 or later. An operation for which a validation rule exceeds MaxAllowedFragmentVisits is then rejected with a validation error. If legitimate operations exceed the limit, raise it on the validation options:
builder
.AddGraphQLServer()
.ConfigureValidation((_, b) => b.ModifyOptions(o => o.MaxAllowedFragmentVisits = 5_000));There is no workaround.