Skip to content

quiche: enforce content-length header consistency#18459

Merged
alyssawilk merged 7 commits intoenvoyproxy:mainfrom
danzh2010:contentlength
Oct 11, 2021
Merged

quiche: enforce content-length header consistency#18459
alyssawilk merged 7 commits intoenvoyproxy:mainfrom
danzh2010:contentlength

Conversation

@danzh2010
Copy link
Copy Markdown
Contributor

Signed-off-by: Dan Zhang danzh@google.com

Commit Message: If request/response has content-length header, its value must be the equal to the actually body length. Otherise reset the stream as nghttp2 does.

Risk Level: low
Testing: added integration tests

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

/assign @alyssawilk

Signed-off-by: Dan Zhang <danzh@google.com>
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this one up! just 2 nits and you're good to go

if (received_content_bytes_ > content_length_.value() ||
(end_stream && received_content_bytes_ != content_length_.value())) {
// Reset instead of closing the connection to align with nghttp2.
onStreamError(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make sure the stream would have informative error details here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added inconsistent_content_length response code detail

}
}

TEST_P(DownstreamProtocolIntegrationTest, ContentLengthLargerThanPayload) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of one additional test in multiplexed integration test where we have an incorrect body length and trailers, just to test the accounting you added there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@alyssawilk
Copy link
Copy Markdown
Contributor

one more thing sorry, can you add the TODO to clean up once we enforce upstream?

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #18459 was synchronize by danzh2010.

see: more, trace.

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Oct 6, 2021
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Copy Markdown
Contributor Author

one more thing sorry, can you add the TODO to clean up once we enforce upstream?

done

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @wrowe could you do a quick pass and let me know if there's anything other than 304/HEAD that content length validation doesn't apply to?

@danzh2010
Copy link
Copy Markdown
Contributor Author

/assign @wrowe

@alyssawilk
Copy link
Copy Markdown
Contributor

Guess not :-/
Well it's runtime guarded so worst case we flip back.

@alyssawilk alyssawilk merged commit 0101fef into envoyproxy:main Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants