HTTP/2: close connection with PROTOCOL_ERROR when receiving GOAWAY frame with non-zero stream ID.
This commit is contained in:
parent
fc56552b2a
commit
a4887f4caf
|
|
@ -406,6 +406,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
|
|||
throw new Http2ConnectionErrorException(Http2ErrorCode.PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
if (_incomingFrame.StreamId != 0)
|
||||
{
|
||||
throw new Http2ConnectionErrorException(Http2ErrorCode.PROTOCOL_ERROR);
|
||||
}
|
||||
|
||||
Stop();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -941,6 +941,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.Contains(5, _abortedStreamIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GOAWAY_Received_StreamIdNonZero_ConnectionError()
|
||||
{
|
||||
await InitializeConnectionAsync(_noopApplication);
|
||||
|
||||
await SendInvalidGoAwayFrameAsync();
|
||||
|
||||
await WaitForConnectionErrorAsync(expectedLastStreamId: 0, expectedErrorCode: Http2ErrorCode.PROTOCOL_ERROR, ignoreNonGoAwayFrames: false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GOAWAY_Received_InterleavedWithHeaders_ConnectionError()
|
||||
{
|
||||
|
|
@ -1484,6 +1494,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
return SendAsync(frame.Raw);
|
||||
}
|
||||
|
||||
private Task SendInvalidGoAwayFrameAsync()
|
||||
{
|
||||
var frame = new Http2Frame();
|
||||
frame.PrepareGoAway(0, Http2ErrorCode.NO_ERROR);
|
||||
frame.StreamId = 1;
|
||||
return SendAsync(frame.Raw);
|
||||
}
|
||||
|
||||
private Task SendWindowUpdateAsync(int streamId, int sizeIncrement)
|
||||
{
|
||||
var frame = new Http2Frame();
|
||||
|
|
|
|||
Loading…
Reference in New Issue