Commit df0faf93 authored by Fan Yang's avatar Fan Yang Committed by Commit Bot

In QUIC, when processing timestamps in ACK frame, close connection if...

In QUIC, when processing timestamps in ACK frame, close connection if delta_from_largest_observed is too high.

Merge internal change: 232664362

R=rch@chromium.org

Bug: 928821
Change-Id: Ie3efa2514b40aa20797717cb23deeaef8d238670
Reviewed-on: https://chromium-review.googlesource.com/c/1459064Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Fan Yang <fayang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630091}
parent bb4a3767
...@@ -3072,6 +3072,14 @@ bool QuicFramer::ProcessTimestampsInAckFrame(uint8_t num_received_packets, ...@@ -3072,6 +3072,14 @@ bool QuicFramer::ProcessTimestampsInAckFrame(uint8_t num_received_packets,
return false; return false;
} }
if (largest_acked.ToUint64() <= delta_from_largest_observed) {
set_detailed_error(QuicStrCat("delta_from_largest_observed too high: ",
delta_from_largest_observed,
", largest_acked: ", largest_acked.ToUint64())
.c_str());
return false;
}
// Time delta from the framer creation. // Time delta from the framer creation.
uint32_t time_delta_us; uint32_t time_delta_us;
if (!reader->ReadUInt32(&time_delta_us)) { if (!reader->ReadUInt32(&time_delta_us)) {
...@@ -3091,6 +3099,14 @@ bool QuicFramer::ProcessTimestampsInAckFrame(uint8_t num_received_packets, ...@@ -3091,6 +3099,14 @@ bool QuicFramer::ProcessTimestampsInAckFrame(uint8_t num_received_packets,
set_detailed_error("Unable to read sequence delta in received packets."); set_detailed_error("Unable to read sequence delta in received packets.");
return false; return false;
} }
if (largest_acked.ToUint64() <= delta_from_largest_observed) {
set_detailed_error(
QuicStrCat("delta_from_largest_observed too high: ",
delta_from_largest_observed,
", largest_acked: ", largest_acked.ToUint64())
.c_str());
return false;
}
seq_num = largest_acked - delta_from_largest_observed; seq_num = largest_acked - delta_from_largest_observed;
// Time delta from the previous timestamp. // Time delta from the previous timestamp.
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "net/third_party/quic/platform/api/quic_ptr_util.h" #include "net/third_party/quic/platform/api/quic_ptr_util.h"
#include "net/third_party/quic/platform/api/quic_string.h" #include "net/third_party/quic/platform/api/quic_string.h"
#include "net/third_party/quic/platform/api/quic_test.h" #include "net/third_party/quic/platform/api/quic_test.h"
#include "net/third_party/quic/platform/api/quic_text_utils.h"
#include "net/third_party/quic/test_tools/quic_framer_peer.h" #include "net/third_party/quic/test_tools/quic_framer_peer.h"
#include "net/third_party/quic/test_tools/quic_test_utils.h" #include "net/third_party/quic/test_tools/quic_test_utils.h"
#include "net/third_party/quic/test_tools/simple_data_producer.h" #include "net/third_party/quic/test_tools/simple_data_producer.h"
...@@ -4281,6 +4282,260 @@ TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) { ...@@ -4281,6 +4282,260 @@ TEST_P(QuicFramerTest, AckFrameTwoTimeStampsMultipleAckBlocks) {
CheckFramingBoundaries(fragments, QUIC_INVALID_ACK_DATA); CheckFramingBoundaries(fragments, QUIC_INVALID_ACK_DATA);
} }
TEST_P(QuicFramerTest, AckFrameTimeStampDeltaTooHigh) {
// clang-format off
unsigned char packet[] = {
// public flags (8 byte connection_id)
0x28,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x78, 0x56, 0x34, 0x12,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x01,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x01,
// num timestamps.
0x01,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
};
unsigned char packet39[] = {
// public flags (8 byte connection_id)
0x28,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x12, 0x34, 0x56, 0x78,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x01,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x01,
// num timestamps.
0x01,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
};
unsigned char packet44[] = {
// type (short header, 4 byte packet number)
0x32,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x12, 0x34, 0x56, 0x78,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x01,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x01,
// num timestamps.
0x01,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
};
unsigned char packet46[] = {
// type (short header, 4 byte packet number)
0x43,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x12, 0x34, 0x56, 0x78,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x01,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x01,
// num timestamps.
0x01,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
};
// clang-format on
if (framer_.transport_version() == QUIC_VERSION_99) {
return;
}
QuicEncryptedPacket encrypted(
AsChars(framer_.transport_version() > QUIC_VERSION_45
? packet46
: (framer_.transport_version() > QUIC_VERSION_43
? packet44
: (framer_.transport_version() == QUIC_VERSION_35
? packet
: packet39))),
QUIC_ARRAYSIZE(packet), false);
EXPECT_FALSE(framer_.ProcessPacket(encrypted));
EXPECT_TRUE(QuicTextUtils::StartsWith(
framer_.detailed_error(), "delta_from_largest_observed too high"));
}
TEST_P(QuicFramerTest, AckFrameTimeStampSecondDeltaTooHigh) {
// clang-format off
unsigned char packet[] = {
// public flags (8 byte connection_id)
0x28,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x78, 0x56, 0x34, 0x12,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x03,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x03,
// num timestamps.
0x02,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
// Delta from largest observed.
0x03,
// Delta time.
0x10, 0x32,
};
unsigned char packet39[] = {
// public flags (8 byte connection_id)
0x28,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x12, 0x34, 0x56, 0x78,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x03,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x03,
// num timestamps.
0x02,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
// Delta from largest observed.
0x03,
// Delta time.
0x10, 0x32,
};
unsigned char packet44[] = {
// type (short header, 4 byte packet number)
0x32,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x12, 0x34, 0x56, 0x78,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x03,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x03,
// num timestamps.
0x02,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
// Delta from largest observed.
0x03,
// Delta time.
0x10, 0x32,
};
unsigned char packet46[] = {
// type (short header, 4 byte packet number)
0x43,
// connection_id
0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
// packet number
0x12, 0x34, 0x56, 0x78,
// frame type (ack frame)
// (no ack blocks, 1 byte largest observed, 1 byte block length)
0x40,
// largest acked
0x03,
// Zero delta time.
0x00, 0x00,
// first ack block length.
0x03,
// num timestamps.
0x02,
// Delta from largest observed.
0x01,
// Delta time.
0x10, 0x32, 0x54, 0x76,
// Delta from largest observed.
0x03,
// Delta time.
0x10, 0x32,
};
// clang-format on
if (framer_.transport_version() == QUIC_VERSION_99) {
return;
}
QuicEncryptedPacket encrypted(
AsChars(framer_.transport_version() > QUIC_VERSION_45
? packet46
: (framer_.transport_version() > QUIC_VERSION_43
? packet44
: (framer_.transport_version() == QUIC_VERSION_35
? packet
: packet39))),
QUIC_ARRAYSIZE(packet), false);
EXPECT_FALSE(framer_.ProcessPacket(encrypted));
EXPECT_TRUE(QuicTextUtils::StartsWith(
framer_.detailed_error(), "delta_from_largest_observed too high"));
}
TEST_P(QuicFramerTest, NewStopWaitingFrame) { TEST_P(QuicFramerTest, NewStopWaitingFrame) {
if (version_.transport_version == QUIC_VERSION_99) { if (version_.transport_version == QUIC_VERSION_99) {
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment