Repository navigation
Accept padded base64 in binary request headers - #3155
Open
rajputdivyanshu81 wants to merge 2 commits into
Open
rajputdivyanshu81 wants to merge 2 commits into
rajputdivyanshu81 wants to merge 2 commits into
Conversation
The gRPC wire format says implementations "MUST accept padded and un-padded values" for -bin headers. The inbound decoder for build.bazel.remote.execution.v2.requestmetadata-bin used BASE64_STANDARD_NO_PAD, so a padded value failed to decode and the request metadata was silently dropped. decode_binary_header() strips trailing '=' and is used both inbound and in the outbound forwarding path, which already did the same inline. Refs TraceMachina#3117 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
palfrey
requested changes
Nov 10, 2026
|
|
||
| if let Some(bazel_header) = req.headers().get(BAZEL_REQUESTMETADATA_HEADER) | ||
| && let Ok(decoded) = BASE64_STANDARD_NO_PAD.decode(bazel_header.as_bytes()) | ||
| && let Ok(decoded) = decode_binary_header(bazel_header.as_bytes()) |
Member
There was a problem hiding this comment.
Why not just use BASE64_STANDARD?
Contributor
Author
There was a problem hiding this comment.
BASE64_STANDARD on its own requires padding in base64 0.22, so it would reject the unpadded values gRPC clients are told to send. The spec says implementations "MUST accept padded and un-padded values" and should send unpadded. Your comment did point at a cleaner fix, though: I've replaced the manual = stripping with a standard-alphabet engine using DecodePaddingMode::Indifferent, so one decoder accepts both forms. Pushed in 43de32c.
Review feedback: rather than stripping trailing `=` by hand, decode with a standard-alphabet engine whose padding mode is Indifferent. BASE64_STANDARD alone would reject the unpadded values gRPC clients are told to send. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 11, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The gRPC wire format says implementations "MUST accept padded and un-padded values" for
-binheaders. The inbound decoder forbuild.bazel.remote.execution.v2.requestmetadata-binusedBASE64_STANDARD_NO_PAD, so a padded value failed to decode and the request metadata (tool name, invocation and correlation ids) was silently dropped. A newdecode_binary_header()strips trailing=and is used both inbound and in the outbound forwarding path, which already did the same thing inline.Refs #3117
How was this verified?
New tests decode the same
RequestMetadatafrom a padded and an unpadded header and check both give the same result. The padded case fails without the change. Thenativelink-utiltests that cover telemetry pass locally (Windows, cargo, 18 tests). I haven't run the Bazel targets locally; CI covers them.reference/protocol-api.mdxgets one sentence on the behavior.Risk
Low. Values that decoded before decode the same way; only padded values, which were dropped, now decode. The outbound path's behavior is unchanged, it just shares the helper now.
AI assistance
Claude Code found this during a REAPI conformance audit, made the change, wrote the tests and ran them. I reviewed every line.