fix(cli): reject NUL bytes in message content with byte offset - #6452
Open
santhiprakash wants to merge 1 commit into
Open
fix(cli): reject NUL bytes in message content with byte offset#6452santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
buzz messages send and buzz messages edit previously accepted content containing an embedded NUL byte (0x00) and passed it through to the relay. On Windows, PowerShell expandable here-strings (where `0 expands to NUL) are a common source: the argument is truncated at the C-string boundary before buzz.exe starts, but the same shape can also arrive via stdin, file, paste, or non-Windows transports where the byte survives into the process. After validate_content_size, the CLI now rejects any 0x00 byte in the resolved content with a hard CliError::Usage that names the byte offset of the NUL and points operators at the PowerShell literal here-string workaround. The validator cannot detect the Windows --content argv class of truncation (the OS command line is cut before buzz.exe starts), so the error is documented as a defense for NULs that reach the process, not a fix for the argv boundary itself. The check is applied in both cmd_send_message and cmd_edit_message so existing messages cannot be edited into the same silent-truncation shape either. Closes block#5916 Signed-off-by: Santhi Prakash <b.santhiprakash@gmail.com>
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.
Summary
buzz messages sendandbuzz messages editpreviously accepted content containing an embedded NUL byte (0x00) and forwarded it through to the relay. The CLI returnedaccepted:truewith whatever the transport preserved, so an agent could believe a complete message was delivered while the relay stored only a truncated prefix.After
validate_content_size, the CLI now rejects any0x00byte in the resolved content with a hardCliError::Usagethat names the byte offset of the NUL and points operators at the PowerShell literal here-string workaround. The same check runs on bothsendandeditso a message that was previously published with a NUL-bearing suffix cannot be silently edited into the same shape.The validator cannot detect the Windows
--content $msgclass of truncation: the NUL terminates the native command line beforebuzz.exestarts, so Clap receives only the prefix and the validator never sees the NUL. The error is therefore documented (in code and in the CLI README) as a defense for NULs that reach the process — stdin, file, paste, or non-Windows transports — not a fix for the OS argv boundary itself. The actionable workaround for the Windows case is to pipe the body through stdin using a PowerShell literal here-string (@'...'@) so backtick escapes do not expand to NUL.Closes #5916
Related issue
Testing
Six new unit tests in
crates/buzz-cli/src/validate.rscover:byte offset 2No existing tests were modified.