Skip to content

Validate CLIENT SETINFO attribute values - #2124

Merged
Vasileios Zois (vazois) merged 2 commits into
microsoft:mainfrom
foobar:fix/client-setinfo-validation
Sep 14, 2026
Merged

Vasileios Zois (vazois) merged 2 commits into
microsoft:mainfrom
foobar:fix/client-setinfo-validation

Conversation

@foobar

@foobar Tristan Su (foobar) commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

CLIENT SETINFO stored LIB-NAME/LIB-VER values without validation and echoed them verbatim into CLIENT LIST/CLIENT INFO, so a client could inject arbitrary reply lines into administrative output.

  • Values are validated as printable ASCII (33-126) on the raw bytes, matching Redis validateClientAttr, and rejected with ERR <attr> cannot contain spaces, newlines or special characters. mirroring Redis's wording.
  • Attribute dispatch precedes value validation, so the echoed attribute in errors is always a case-variant of a matched constant; unknown attributes keep the syntax-error path.
  • Attribute matching is case-insensitive (lib-name accepted), matching Redis subcommand lookup.
  • Note: high-byte (128-255) values were previously accepted and ASCII-mangled in CLIENT LIST; they are now rejected, matching Redis.

Regression tests cover CRLF injection, control/high bytes, boundary bytes 33/126, failed-SETINFO preservation, empty-value clearing, case-insensitive matching, and CLIENT LIST line-cleanliness. Command docs updated accordingly.

Signed-off-by: Tristan Su [email protected]

Copilot AI balanced review requested due to automatic review settings September 10, 2026 06:33

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.

🟡 Changes recommended

The invalid-value error path currently echoes the client-provided attribute casing (contradicting the PR’s stated “matched constant” behavior) and one new assertion is brittle to formatting/order changes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR hardens CLIENT SETINFO by validating LIB-NAME / LIB-VER values before storing and echoing them via CLIENT LIST / CLIENT INFO, preventing CRLF/control-byte injection into administrative output.

Changes:

  • Added byte-level validation for CLIENT SETINFO values (printable ASCII range 33–126) and a Redis-matching error message on rejection.
  • Updated attribute matching to be case-insensitive (e.g., lib-ver accepted) while keeping unknown attributes on the existing syntax-error path.
  • Documented the new error behavior and added regression tests covering invalid bytes/injection attempts and value-preservation semantics.
File summaries
File Description
website/docs/commands/client.md Documents the new CLIENT SETINFO error reply behavior for invalid attribute values.
test/standalone/Garnet.test.acl/Resp/ACL/BasicTests.cs Adds regression tests for invalid CLIENT SETINFO values and output cleanliness in CLIENT INFO/CLIENT LIST.
libs/server/Resp/CmdStrings.cs Introduces a reusable formatted error string for invalid client attribute values.
libs/server/Resp/ClientCommands.cs Implements case-insensitive attribute dispatch and raw-byte validation of attribute values before storing.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment thread libs/server/Resp/ClientCommands.cs
Comment thread test/standalone/Garnet.test.acl/Resp/ACL/BasicTests.cs
@vazois

Copy link
Copy Markdown
Contributor

Tristan Su (@foobar), please address the copilot comments.

CLIENT SETINFO stored LIB-NAME/LIB-VER values without validation and
echoed them verbatim into CLIENT LIST, so a client could inject
arbitrary reply lines into the administrative output. Values are now
validated as printable ASCII (33-126) on the raw bytes, matching Redis
validateClientAttr, and rejected with 'ERR <attr> cannot contain
spaces, newlines or special characters.' mirroring Redis's
addReplyErrorFormat wording. Attribute dispatch precedes value
validation, so unknown attributes keep the syntax error path and the
echoed attribute is always a matched constant.

Signed-off-by: Tristan Su <[email protected]>
@foobar
Tristan Su (foobar) force-pushed the fix/client-setinfo-validation branch from e007e1a to 4997f4f Compare September 11, 2026 23:43
@vazois
Vasileios Zois (vazois) merged commit cd35bf4 into microsoft:main Sep 14, 2026
166 of 169 checks passed
@foobar
Tristan Su (foobar) deleted the fix/client-setinfo-validation branch September 15, 2026 00:25
x@01 (x-at-01) added a commit to webc-fork/garnet that referenced this pull request Sep 20, 2026
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.

3 participants