Skip to content

Redact protocol error log when hide-user-data-from-log enabled #1889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025

Conversation

YueTang-Vanessa
Copy link
Contributor

In this code logic: https://github.com/valkey-io/valkey/blob/unstable/src/networking.c#L2767-L2773, c->querybuf + c->qb_pos may also include user data.
Update the log message when config hide-user-data-from-log is enabled.

@zuiderkwast
Copy link
Contributor

When exactly is this triggered? Only when the client sends some incorrectly encoded RESP?

Copy link

codecov bot commented Mar 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.00%. Comparing base (06990c2) to head (1b77cf5).
Report is 5 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1889      +/-   ##
============================================
- Coverage     71.00%   71.00%   -0.01%     
============================================
  Files           123      123              
  Lines         65671    65675       +4     
============================================
+ Hits          46631    46632       +1     
- Misses        19040    19043       +3     
Files with missing lines Coverage Δ
src/networking.c 88.78% <100.00%> (+0.12%) ⬆️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@hpatro hpatro left a comment

Choose a reason for hiding this comment

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

Could you add a test case and assert *redacted* on it ?.

@YueTang-Vanessa YueTang-Vanessa force-pushed the unstable branch 2 times, most recently from 74ff2b0 to addd428 Compare March 28, 2025 00:36
@QuChen88
Copy link
Contributor

Looks good to me

@QuChen88
Copy link
Contributor

QuChen88 commented Mar 28, 2025

@zuiderkwast Basically any sort of protocol parsing error from the primary to the replica can lead to this condition to get triggered and the query buffer containing potential user data/commands would get logged. This can happen for various reasons including data corruption over the wire etc. i.e. we saw this in a couple of our redis clusters in the past.

3524:S 26 Mar 2025 17:49:50.755 # WARNING: Receiving inline protocol from master, master stream corruption? Closing the master connection and discarding the cached master.
3524:S 26 Mar 2025 17:49:50.755 # Protocol error (Master using the inline protocol. Desync?) from client: ... Query buffer during protocol error: '293..$4..hdel..$31.. <key-name>...

The chances of this happening is pretty low, but still non zero.

@YueTang-Vanessa YueTang-Vanessa force-pushed the unstable branch 3 times, most recently from ffde5c4 to 6d8099b Compare March 29, 2025 03:41
Signed-off-by: VanessaTang <yuetan@amazon.com>
1. print the query buffer info in case hide-user-data-from-log is disabled
2. fix tests to wait for the information in the log

Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

LGTM

@ranshid ranshid merged commit 09f9630 into valkey-io:unstable Mar 31, 2025
51 checks passed
ranshid added a commit to ranshid/valkey that referenced this pull request Mar 31, 2025
…y-io#1889)

In this code logic:
https://github.com/valkey-io/valkey/blob/unstable/src/networking.c#L2767-L2773,
`c->querybuf + c->qb_pos` may also include user data.
Update the log message when config `hide-user-data-from-log` is enabled.

---------

Signed-off-by: VanessaTang <yuetan@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
ranshid added a commit that referenced this pull request Mar 31, 2025
In this code logic:
https://github.com/valkey-io/valkey/blob/unstable/src/networking.c#L2767-L2773,
`c->querybuf + c->qb_pos` may also include user data.
Update the log message when config `hide-user-data-from-log` is enabled.

---------

Signed-off-by: VanessaTang <yuetan@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
@hwware hwware added this to Valkey 8.1 Apr 2, 2025
@hwware hwware moved this to To be backported in Valkey 8.1 Apr 2, 2025
RayaCoo pushed a commit to RayaCoo/valkey that referenced this pull request Apr 3, 2025
…y-io#1889)

In this code logic:
https://github.com/valkey-io/valkey/blob/unstable/src/networking.c#L2767-L2773,
`c->querybuf + c->qb_pos` may also include user data.
Update the log message when config `hide-user-data-from-log` is enabled.

---------

Signed-off-by: VanessaTang <yuetan@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
zarkash-aws pushed a commit to zarkash-aws/valkey that referenced this pull request Apr 6, 2025
…y-io#1889)

In this code logic:
https://github.com/valkey-io/valkey/blob/unstable/src/networking.c#L2767-L2773,
`c->querybuf + c->qb_pos` may also include user data.
Update the log message when config `hide-user-data-from-log` is enabled.

---------

Signed-off-by: VanessaTang <yuetan@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
Signed-off-by: Shai Zarka <zarkash@amazon.com>
@zuiderkwast zuiderkwast moved this from To be backported to Unknown if backported in Valkey 8.1 Apr 7, 2025
murphyjacob4 pushed a commit to enjoy-binbin/valkey that referenced this pull request Apr 13, 2025
…y-io#1889)

In this code logic:
https://github.com/valkey-io/valkey/blob/unstable/src/networking.c#L2767-L2773,
`c->querybuf + c->qb_pos` may also include user data.
Update the log message when config `hide-user-data-from-log` is enabled.

---------

Signed-off-by: VanessaTang <yuetan@amazon.com>
Signed-off-by: Ran Shidlansik <ranshid@amazon.com>
Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
@zuiderkwast zuiderkwast moved this from Unknown if backported to Done in Valkey 8.1 Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants