Issue #3978 - HTTP/2 vulnerabilities.
Small fixed after review. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
5fc83c3d0c
commit
5184c4ec3d
|
@ -45,7 +45,7 @@ public class ContinuationBodyParser extends BodyParser
|
||||||
{
|
{
|
||||||
if (hasFlag(Flags.END_HEADERS))
|
if (hasFlag(Flags.END_HEADERS))
|
||||||
{
|
{
|
||||||
onHeaders();
|
onHeaders(buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ public class ContinuationBodyParser extends BodyParser
|
||||||
headerBlockFragments.storeFragment(buffer, length, last);
|
headerBlockFragments.storeFragment(buffer, length, last);
|
||||||
reset();
|
reset();
|
||||||
if (last)
|
if (last)
|
||||||
return onHeaders();
|
return onHeaders(buffer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,15 +103,20 @@ public class ContinuationBodyParser extends BodyParser
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onHeaders()
|
private boolean onHeaders(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
ByteBuffer headerBlock = headerBlockFragments.complete();
|
ByteBuffer headerBlock = headerBlockFragments.complete();
|
||||||
MetaData metaData = headerBlockParser.parse(headerBlock, headerBlock.remaining());
|
MetaData metaData = headerBlockParser.parse(headerBlock, headerBlock.remaining());
|
||||||
|
if (metaData == null)
|
||||||
|
return true;
|
||||||
if (metaData == HeaderBlockParser.SESSION_FAILURE)
|
if (metaData == HeaderBlockParser.SESSION_FAILURE)
|
||||||
return false;
|
return false;
|
||||||
if (metaData == null || metaData == HeaderBlockParser.STREAM_FAILURE)
|
|
||||||
return true;
|
|
||||||
HeadersFrame frame = new HeadersFrame(getStreamId(), metaData, headerBlockFragments.getPriorityFrame(), headerBlockFragments.isEndStream());
|
HeadersFrame frame = new HeadersFrame(getStreamId(), metaData, headerBlockFragments.getPriorityFrame(), headerBlockFragments.isEndStream());
|
||||||
|
if (metaData == HeaderBlockParser.STREAM_FAILURE)
|
||||||
|
{
|
||||||
|
if (!rateControlOnEvent(frame))
|
||||||
|
return connectionFailure(buffer, ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, "invalid_continuation_frame_rate");
|
||||||
|
}
|
||||||
notifyHeaders(frame);
|
notifyHeaders(frame);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,11 +103,6 @@ public class HeaderBlockParser
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug(x);
|
LOG.debug(x);
|
||||||
if (!headerParser.getRateControl().onEvent(x))
|
|
||||||
{
|
|
||||||
notifier.connectionFailure(buffer, ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, "invalid_header_frame_rate");
|
|
||||||
return SESSION_FAILURE;
|
|
||||||
}
|
|
||||||
notifier.streamFailure(headerParser.getStreamId(), ErrorCode.PROTOCOL_ERROR.code, "invalid_hpack_block");
|
notifier.streamFailure(headerParser.getStreamId(), ErrorCode.PROTOCOL_ERROR.code, "invalid_hpack_block");
|
||||||
return STREAM_FAILURE;
|
return STREAM_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class SettingsBodyParser extends BodyParser
|
||||||
{
|
{
|
||||||
SettingsFrame frame = new SettingsFrame(Collections.emptyMap(), hasFlag(Flags.ACK));
|
SettingsFrame frame = new SettingsFrame(Collections.emptyMap(), hasFlag(Flags.ACK));
|
||||||
if (!rateControlOnEvent(frame))
|
if (!rateControlOnEvent(frame))
|
||||||
connectionFailure(buffer, ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, "invalid_settings_frame");
|
connectionFailure(buffer, ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, "invalid_settings_frame_rate");
|
||||||
else
|
else
|
||||||
onSettings(frame);
|
onSettings(frame);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class UnknownBodyParser extends BodyParser
|
||||||
cursor = consume(buffer, length);
|
cursor = consume(buffer, length);
|
||||||
boolean parsed = cursor == 0;
|
boolean parsed = cursor == 0;
|
||||||
if (parsed && !rateControlOnEvent(new UnknownFrame(getFrameType())))
|
if (parsed && !rateControlOnEvent(new UnknownFrame(getFrameType())))
|
||||||
return connectionFailure(buffer, ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, "invalid_unknown_frame");
|
return connectionFailure(buffer, ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, "invalid_unknown_frame_rate");
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue