Skip to content

fix(tracing): redact values for GETSET and PSETEX - #2134

Merged
PavelPashov merged 1 commit into
redis:mainfrom
spokodev:fix/tracing-redact-getset-psetex
Jul 2, 2026
Merged

PavelPashov merged 1 commit into
redis:mainfrom
spokodev:fix/tracing-redact-getset-psetex

Conversation

@spokodev

@spokodev spokodev commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

The command tracing added in #2089 sanitizes argument values before emitting them on the ioredis:command diagnostics channel, so secrets are not leaked to APM/observability subscribers. The README states values in commands like SET are replaced with ?. Two write commands slip through and emit their value in plaintext:

GETSET mykey <SECRET>          -> traced as ["mykey", "<SECRET>"]      (expected ["mykey", "?"])
PSETEX mykey 300000 <SECRET>   -> traced as ["mykey", "300000", "<SECRET>"] (expected ["mykey", "?", "?"])

GETSET and PSETEX are just SET-with-return and SET-with-expiry, so their value is as sensitive as SET's.

Cause

In lib/tracing.ts, SERIALIZATION_SUBSETS is matched first-hit-wins. GETSET and PSETEX are absent from the args: 1 (redact values, keep key) group, so they fall through to the broad args: -1 (retain all) rule via its GET and P[EFISTU] prefixes. This also diverges from the upstream @opentelemetry/redis-common serialization subsets the file states it adapts, which place both GETSET and PSETEX in the redact-values group.

Fix

Add GETSET and PSETEX to the args: 1 regex, matching upstream. SET/SETEX/SETNX were already covered; this only closes the two-command gap.

Testing

Added cases to the existing sanitizeArgs describe block in test/functional/tracing.ts asserting the key is kept and the value is redacted for GETSET and PSETEX. They fail on the current code (value emitted verbatim) and pass with the fix; the full sanitizeArgs block stays green, and GETDEL/GETRANGE/PTTL/PERSIST still return all args (no shadowing).


Note

Low Risk
Narrow observability sanitization fix with tests; no runtime command behavior or auth/data-path changes.

Overview
GETSET and PSETEX were leaking value arguments on the ioredis:command tracing channel because they were not in the args: 1 sanitization group and instead matched the broad read-only rule (GET / P* prefixes), which keeps all arguments visible.

This PR adds both commands to the same args: 1 regex as SET and related write commands in lib/tracing.ts, so only the key is emitted and TTL/value args become ?. Functional tests in test/functional/tracing.ts lock in the expected sanitizeArgs output for lowercase and uppercase command names.

Reviewed by Cursor Bugbot for commit f439182. Bugbot is set up for automated code reviews on this repo. Configure here.

sanitizeArgs left the value argument of GETSET and PSETEX in plaintext
in the command tracing payload, because both fell through to the
retain-all rule. They are write commands whose value is as sensitive as
SET's. Add them to the redact-values group, matching the upstream
@opentelemetry/redis-common serialization subsets the file adapts.
@jit-ci

jit-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@PavelPashov

Copy link
Copy Markdown
Contributor

@spokodev Thanks for the PR. I’ll take a look and review it.

@PavelPashov PavelPashov 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.

Thank you for the contribution, this looks good to me. Approved.

@PavelPashov
PavelPashov merged commit 832765d into redis:main Jul 2, 2026
19 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 29, 2026
# [6.0.0-beta.1](v5.11.1...v6.0.0-beta.1) (2026-07-29)

* Add RESP3 ([#2127](#2127)) ([5d0862e](5d0862e))

### Bug Fixes

* clear stale socket timeout on reconnect ([#2148](#2148)) ([6455dbe](6455dbe))
* **cluster:** recreate stale connection on circular MOVED ([#2135](#2135)) ([08c8967](08c8967))
* **cluster:** validate MOVED slot to prevent Array.prototype pollution ([#2151](#2151)) ([9618206](9618206)), closes [#1267](#1267)
* **command:** serialize large integer arguments in decimal notation ([#2136](#2136)) ([09b8d04](09b8d04))
* **redis:** keep reconnecting when connection closes during client setup ([#2099](#2099)) ([#2123](#2123)) ([f9a66bc](f9a66bc))
* **sentinel:** preserve zero preferred slave priority ([#2129](#2129)) ([a3f9f2d](a3f9f2d))
* **tracing:** redact values for GETSET and PSETEX ([#2134](#2134)) ([832765d](832765d))

### Features

* add LMOVEM and BLMOVEM command support ([#2144](#2144)) ([c26af46](c26af46))
* add Redis 8.10 set cardinality commands ([#2143](#2143)) ([301099b](301099b))
* support MAXCOUNT and MAXSIZE for stream reads ([#2142](#2142)) ([ae5e41b](ae5e41b))

### BREAKING CHANGES

* ioredis now requires Node.js 20 or newer and uses RESP3 by default. Set `protocol: 2` to retain the v5 wire protocol.
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 6.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions Bot pushed a commit that referenced this pull request Jul 31, 2026
# [6.0.0](v5.11.1...v6.0.0) (2026-07-31)

* Add RESP3 ([#2127](#2127)) ([5d0862e](5d0862e))

### Bug Fixes

* clear stale socket timeout on reconnect ([#2148](#2148)) ([6455dbe](6455dbe))
* **cluster:** recreate stale connection on circular MOVED ([#2135](#2135)) ([08c8967](08c8967))
* **cluster:** validate MOVED slot to prevent Array.prototype pollution ([#2151](#2151)) ([9618206](9618206)), closes [#1267](#1267)
* **command:** serialize large integer arguments in decimal notation ([#2136](#2136)) ([09b8d04](09b8d04))
* **redis:** keep reconnecting when connection closes during client setup ([#2099](#2099)) ([#2123](#2123)) ([f9a66bc](f9a66bc))
* **sentinel:** preserve zero preferred slave priority ([#2129](#2129)) ([a3f9f2d](a3f9f2d))
* **tracing:** redact values for GETSET and PSETEX ([#2134](#2134)) ([832765d](832765d))
* **types:** export ScanStreamOptions, RedisStatus and ClusterStatus ([#2158](#2158)) ([cf3bf71](cf3bf71))

### Features

* add LMOVEM and BLMOVEM command support ([#2144](#2144)) ([c26af46](c26af46))
* add Redis 8.10 set cardinality commands ([#2143](#2143)) ([301099b](301099b))
* himport managed fieldsets ([#2159](#2159)) ([729f174](729f174))
* improve default connection resilience ([#2160](#2160)) ([6d0716e](6d0716e))
* support MAXCOUNT and MAXSIZE for stream reads ([#2142](#2142)) ([ae5e41b](ae5e41b))

### BREAKING CHANGES

* ioredis now requires Node.js 20 or newer and uses RESP3 by default. Set `protocol: 2` to retain the v5 wire protocol.
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants