reject overlong grpc-timeout in ConvertGrpcTimeoutToUS by ubeddulla · Pull Request #3577 · apache/brpc · GitHub
Skip to content

reject overlong grpc-timeout in ConvertGrpcTimeoutToUS - #3577

Open
ubeddulla wants to merge 1 commit into
apache:masterfrom
ubeddulla:grpc-timeout-overflow
Open

ubeddulla wants to merge 1 commit into
apache:masterfrom
ubeddulla:grpc-timeout-overflow

Conversation

@ubeddulla

Copy link
Copy Markdown
Contributor

ConvertGrpcTimeoutToUS parses the grpc-timeout header from any gRPC client but only checks that a single unit char trails the digits, so a value with many digits (or a negative one) flows into timeout_value * and overflows int64, which is undefined and then lands a bogus deadline in gettimeofday_us() on the request path. The gRPC-over-HTTP2 spec caps TimeoutValue at an 8-digit positive integer, so reject anything outside 0..99999999 before the multiply. The added regression test decodes a 999999999999999999H timeout, which returns a wrapped value today and -1 after the change.

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The numeric check still accepts overlong values containing leading zeros, contrary to the stated eight-digit limit.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Prevents overflow when parsing oversized gRPC timeout headers.

Changes:

  • Bounds parsed timeout values before unit conversion.
  • Adds regression and boundary tests.
File Description
src/​brpc/​grpc.cpp Rejects timeout values outside the safe numeric range.
test/​brpc_grpc_protocol_unittest.cpp Tests valid, negative, and oversized timeouts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/brpc/grpc.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants