Repository navigation
fix: redact credentials from the command attached to errors - #2231
PavelPashov merged 4 commits into
Conversation
Reply errors and AbortErrors carry the failed command as
`err.command = { name, args }`. For AUTH that includes the username and
password in plain text, and they end up in application logs (redis#1713).
Add SENSITIVE_ARGS_COMMANDS to the command flags and a
Command.redactSensitiveArgs() helper that replaces only the credentials:
all AUTH arguments, the AUTH/AUTH2 credentials of HELLO and MIGRATE, the
password rules of ACL SETUSER and the values of CONFIG SET. Other
commands, and the other subcommands of ACL and CONFIG, keep their
arguments as they are.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2897217f49
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ], | ||
| FIRST_ARG_TIMEOUT_COMMANDS: ["bzmpop", "blmpop"], | ||
| BLOCK_OPTION_COMMANDS: ["xread", "xreadgroup"], | ||
| SENSITIVE_ARGS_COMMANDS: ["auth", "hello", "migrate", "acl", "config"], |
There was a problem hiding this comment.
Redact Sentinel authentication settings
When a client sends the supported SENTINEL SET <master> auth-pass <password> form through the sentinel method registered by Commander, a server error still takes the non-sensitive path because sentinel is absent from this set, so DataHandler places the plaintext password in err.command.args. Add Sentinel-aware handling (including the global sentinel-pass configuration form) so supported Sentinel deployments do not retain the credential leak.
AGENTS.md reference: AGENTS.md:L7-L7
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@mrityunjay-pandey could you also redact SENTINEL SET ... auth-pass/auth-user and SENTINEL CONFIG SET values? Not a blocker; we can merge without it.
There was a problem hiding this comment.
Thanks for the review! Done in the latest commit:
SENTINEL SET <master> ...: the values ofauth-passandauth-userare redacted, other options keep their values.SENTINEL CONFIG SET ...: the values are redacted and the parameter names kept, same asCONFIG SET.- Other
SENTINELsubcommands are unchanged.
I added unit tests for both, and for an auth-pass master name not being mistaken for the option. Lint, prettier and test:tsd pass, and so does test:js.
There was a problem hiding this comment.
Follow-up after your approval, since it changed more than the Sentinel lines: while fixing the rename-command case the bot found, I saw that malformed commands (which are exactly the ones Redis rejects) could shift a password out of the redacted positions in the other parsers too. bbd047a makes the parsing position-independent (details in the description) and adds tests for each malformed case. No change for well-formed commands. Lint, prettier, test:tsd and test:js pass.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Also redact the auth-pass and auth-user values of SENTINEL SET and the values of SENTINEL CONFIG SET.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6060e5b2a2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| case "sentinel": | ||
| // SENTINEL SET master option value [option value ...] | ||
| if (token(0) === "set") { | ||
| for (let i = 2; i < args.length; i += 2) { |
There was a problem hiding this comment.
Parse variable-arity Sentinel options before redacting
Fresh evidence in the updated Sentinel branch is the fixed two-token stride: in valid SENTINEL SET mymaster rename-command CONFIG HIDDEN auth-pass secret, rename-command consumes two values, so auth-pass is at index 5 and is never inspected by this loop. If the connection closes while this command is pending (or a later option makes Redis return an error), abortError/DataHandler still place secret in err.command.args; advance according to rename-command's variable arity before redacting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch: rename-command takes two values, so the loop now skips both before looking for auth-pass/auth-user. Fixed in ada14fe with a test for SET mymaster rename-command CONFIG HIDDEN auth-pass secret.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ada14fe3fd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return redacted; | ||
| case "acl": | ||
| // ACL SETUSER username [rule ...] | ||
| if (token(0) === "setuser") { |
There was a problem hiding this comment.
Redact credentials nested in ACL DRYRUN
When an administrator uses the supported Redis 7 form ACL DRYRUN restricted CONFIG SET requirepass secret and the simulated user lacks CONFIG SET, Redis returns an error for the outer acl command. RedisCommander.acl accepts the trailing command arguments, but this branch only handles SETUSER, so secret remains in err.command.args and can still be logged; apply the sensitive-argument redaction to the embedded command for DRYRUN too.
AGENTS.md reference: AGENTS.md:L55-L55
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit ada14fe. Configure here.
The redaction relied on argument positions, so a malformed command, which is exactly what makes Redis return an error, could shift a password out of the redacted slots. Scan HELLO from its first argument and MIGRATE right after the key, look at every token of SENTINEL SET instead of stepping through pairs, and redact every argument of a CONFIG SET or SENTINEL CONFIG SET whose parameters and values are not in pairs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbd047a441
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (token(i) === "auth-pass" || token(i) === "auth-user") { | ||
| redact(i + 1); | ||
| i += 1; |
There was a problem hiding this comment.
Honor rename-command arity during Sentinel redaction
With autoResendUnfulfilledCommands: false, a close while SENTINEL SET mymaster rename-command CONFIG auth-user auth-pass secret is pending makes this loop treat the rename target auth-user as an option, redact and skip the real auth-pass token, and leave secret in err.command.args. Fresh evidence beyond the earlier variable-arity report is the final every-token revision that reintroduces the leak for this valid option sequence; parse rename-command's two operands before resuming the option scan.
AGENTS.md reference: AGENTS.md:L7-L7
Useful? React with 👍 / 👎.
| if (!Command.checkFlag("SENSITIVE_ARGS_COMMANDS", commandName)) { | ||
| return args; |
There was a problem hiding this comment.
Redact credentials inside COMMAND key inspection
With autoResendUnfulfilledCommands: false, a close while redis.command("GETKEYS", "MIGRATE", ..., "AUTH", "secret") (or GETKEYSANDFLAGS) is pending sends the outer name command through this early return, so abortError retains the password in err.command.args. lib/utils/RedisCommander.ts:1296-1308 explicitly exposes both wrappers with arbitrary trailing command arguments; recognize them and recursively sanitize the embedded command name and arguments.
AGENTS.md reference: AGENTS.md:L55-L55
Useful? React with 👍 / 👎.
# [6.1.0](v6.0.0...v6.1.0) (2026-11-23) ### Bug Fixes * accept field arrays in hmget/hmgetBuffer types ([#2167](#2167)) ([c0cd66c](c0cd66c)) * align auto-pipeline callbacks for dynamic commands ([#2180](#2180)) ([7479cab](7479cab)) * apply the legacy reply shape to uppercase command names ([#2252](#2252)) ([8ecb423](8ecb423)) * clean up Sentinel failover subscriptions after quit ([#2198](#2198)) ([727edfa](727edfa)) * close the monitor connection when monitor() rejects ([#2247](#2247)) ([3cfe93f](3cfe93f)) * cluster stuck in close ([#2217](#2217)) ([a5fad1d](a5fad1d)) * **cluster:** bucket autopipelined MSET objects by their first key ([#2207](#2207)) ([b4e3237](b4e3237)) * **cluster:** do not reject pipeline commands for connecting nodes when offline queue is disabled ([#2277](#2277)) ([71516ca](71516ca)), closes [#2096](#2096) [Cluster#sendCommand](https://github.com/Cluster/issues/sendCommand) [#2276](#2276) * **cluster:** do not throw when auto-pipelining meets an uncached slot ([#2233](#2233)) ([e04bb49](e04bb49)) * **cluster:** don't fall back to a replica when no primary is left ([#2275](#2275)) ([c353e34](c353e34)) * **cluster:** emit sharded subscriber connect errors silently ([#2241](#2241)) ([00c9a22](00c9a22)) * **cluster:** end when quit() or disconnect() is called while reconnecting ([#2240](#2240)) ([8526785](8526785)) * **cluster:** hash autopipelined Buffer keys by their bytes ([#2208](#2208)) ([a8378bd](a8378bd)), closes [Command#getSlot](https://github.com/Command/issues/getSlot) * **cluster:** hash lone surrogates as the UTF-8 Node sends ([#2242](#2242)) ([cfa464d](cfa464d)) * **cluster:** keep forwarding sharded messages after reconnecting from end ([#2251](#2251)) ([326e987](326e987)) * **cluster:** map every slot when stringNumbers is enabled ([#2255](#2255)) ([8ce4115](8ce4115)) * **cluster:** match Buffer shard channels when unsubscribing ([#2203](#2203)) ([d997d01](d997d01)) * **cluster:** pass the retry delay to the reconnecting event ([#2291](#2291)) ([ed50383](ed50383)) * **cluster:** resend only the redirected command in a pipeline ([#2214](#2214)) ([46b3191](46b3191)), closes [#2075](#2075) [Pipeline#exec](https://github.com/Pipeline/issues/exec) [Cluster#sendCommand](https://github.com/Cluster/issues/sendCommand) [Pipeline#exec](https://github.com/Pipeline/issues/exec) [Cluster#sendCommand](https://github.com/Cluster/issues/sendCommand) [Pipeline#exec](https://github.com/Pipeline/issues/exec) * **cluster:** stay ended when nodes removed by disconnect() end late ([#2237](#2237)) ([61896e5](61896e5)), closes [#2217](#2217) * **cluster:** stop refreshing slots when disconnect() is called during a refresh ([#2249](#2249)) ([80501ed](80501ed)) * **cluster:** support zero-argument sunsubscribe with sharded subscribers ([#2137](#2137)) ([13ff050](13ff050)), closes [#2133](#2133) * **cluster:** vendor cluster-key-slot to fix empty hash tag slot bug ([#2172](#2172)) ([b479b76](b479b76)) * correct Sentinel retry ordering after node connection failures ([#2246](#2246)) ([a10e0fa](a10e0fa)) * decode integer replies up to MAX_SAFE_INTEGER exactly ([#2164](#2164)) ([28940b5](28940b5)) * decode RESP3 attribute replies instead of failing the connection ([#2213](#2213)) ([6a8cb3e](6a8cb3e)), closes [#decodeNestedType](https://github.com/redis/ioredis/issues/decodeNestedType) [#decodeMapAsObject](https://github.com/redis/ioredis/issues/decodeMapAsObject) [#decodeMapKey](https://github.com/redis/ioredis/issues/decodeMapKey) * decode RESP3 doubles with Number ([#2150](#2150)) ([6fb5a10](6fb5a10)) * end when quit() or disconnect() is called while reconnecting ([#2245](#2245)) ([81bc16a](81bc16a)) * handle rejection from the db-restoring select on reconnectOnError ([#2229](#2229)) ([1b744ca](1b744ca)) * handle rejections from auto-resubscribe and select on reconnect ([#2187](#2187)) ([de2fbdf](de2fbdf)) * inherit connectTimeout for cluster subscribers ([#2220](#2220)) ([db57c2d](db57c2d)) * keep String.prototype in fast mode after defining VerbatimString ([#2206](#2206)) ([90e1261](90e1261)) * keep subscriber mode while other channel kinds remain subscribed ([#2196](#2196)) ([eb97beb](eb97beb)) * keep the exec error out of its own previousErrors ([#2218](#2218)) ([2c602cf](2c602cf)) * keep the selected db for commands queued while reconnecting ([#2235](#2235)) ([9f90154](9f90154)) * preserve empty keys and match patterns in scan streams ([#2199](#2199)) ([b169c3a](b169c3a)) * redact credentials from the command attached to errors ([#2231](#2231)) ([a26f8de](a26f8de)), closes [#1713](#1713) * reject unfulfilled commands dropped on reconnect ([#2194](#2194)) ([d95d05a](d95d05a)), closes [#2193](#2193) * reset retry attempts when connect() is called after giving up ([#2204](#2204)) ([b597303](b597303)), closes [#1463](#1463) * reset the manual close state when connect() is called after end ([#2250](#2250)) ([7713c4b](7713c4b)) * resolve argument-less (p)unsubscribe once its own kind is empty ([#2238](#2238)) ([280812b](280812b)) * restore the db selected by a non-lowercase SELECT after reconnecting ([#2248](#2248)) ([400b774](400b774)) * **sentinel:** handle errors on failover detector connections ([#2257](#2257)) ([09bcda5](09bcda5)) * **sentinel:** retry unreachable sentinels in a loop instead of recursing ([#2270](#2270)) ([6bee8d2](6bee8d2)) * **types:** accept documented TLS profile options ([#2195](#2195)) ([56a7fb8](56a7fb8)), closes [#1626](#1626) * **types:** add event overloads to Cluster interface ([#2201](#2201)) ([3996eaf](3996eaf)), closes [#2191](#2191) * **types:** add smessage and smessageBuffer event overloads ([#2191](#2191)) ([ee48f4c](ee48f4c)), closes [#2190](#2190) * **types:** allow number for zrange stop argument ([#2163](#2163)) ([932f4c2](932f4c2)) ### Features * add BITRANGEINTARRAY command ([#2279](#2279)) ([b141399](b141399)) * add set member expiration commands ([#2261](#2261)) ([5efba6b](5efba6b)), closes [redis/redis#15938](redis/redis#15938) * bless commands ([#2209](#2209)) ([9181ee0](9181ee0)) * **cluster:** allow configuring node role for Pub/Sub subscriber ([#2176](#2176)) ([6b9130c](6b9130c)) * sharded subscriber health check ([#2268](#2268)) ([1b25ffb](1b25ffb)) * smart client handoffs ([#2165](#2165)) ([d8ae3cb](d8ae3cb)) * sorted set move commands ([#2288](#2288)) ([2f4f09d](2f4f09d))
|
🎉 This PR is included in version 6.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |

Fixes #1713. This picks up #2076, which has been idle since the review in March, and follows that review.
Problem
Reply errors and
AbortErrors carry the failed command aserr.command = { name, args }. ForAUTHthis includes the username and password in plain text, so a wrong password (orERR max number of clients reachedduring the handshake) writes the credentials into application logs.Change
SENSITIVE_ARGS_COMMANDSentry inCommandNameFlags:auth,hello,migrate,acl,config.Command.redactSensitiveArgs(name, args), used whereDataHandlerandabortError()attach the command to the error. It replaces only the credentials with"[REDACTED]":AUTH: all argumentsHELLO 3 AUTH user pass: the username and the passwordMIGRATE ... AUTH pass/AUTH2 user pass: the credentials. Options are only matched after the 5 positional arguments, so a key namedauthis kept.ACL SETUSER user ...rules: only the password rules (>,<,#,!). The username and the other rules are kept, and otherACLsubcommands are untouched.CONFIG SET param value ...: the values. Parameter names are kept, andCONFIG GETetc. are untouched.SENTINEL SET <master> ...: the values ofauth-passandauth-user.SENTINEL CONFIG SET param value ...: the values, likeCONFIG SET.HELLOis scanned from its first argument,MIGRATEright after the key, every token ofSENTINEL SETis checked, and aCONFIG SET/SENTINEL CONFIG SETwhose parameters and values are not in pairs has all its arguments redacted.argsarray back, with no copy.On
CONFIG SETI redact every value rather than a list of sensitive parameters (requirepass,masterauth,tls-key-file-pass, ...). Module or future parameters can hold secrets too, and the value is rarely what you need when debugging. Happy to narrow it to a list if you prefer.Not in this PR: the
debugoutput when queueing or writing a command (DEBUG=ioredis:*) and the tracingsanitizeArgs, which letsACLandCONFIGarguments through. Both could reuse the helper in a follow-up.Tests
test/unit/command.ts: every rule above, including keywords that appear as values (a client name or key namedauth),Bufferarguments, and that the input array is not mutated.test/functional/sensitive_args.ts: against a real server, failedAUTH,HELLO,ACL SETUSERandCONFIG SETreplies, and anAUTHaborted by a connection close (mock server). All 13 new tests fail onmain, e.g.args: ["no-such-user", "secret"].npm run test:jsagainst Redis 7.0.15: 2286 passing. 8 tests fail, and the same 8 fail onmainbecause they need Redis 8 commands (WITHSCORE,NOVALUES).npm run lint(no new warnings),prettier --check, andnpm run test:tsd.Note
Low Risk
Security-hardening change on error metadata only; command wire format and successful paths are unchanged, with broad test coverage for redaction rules.
Overview
Fixes credential leakage when Redis reply errors and connection-close
AbortErrors exposeerr.command.argsin logs.Adds
Command.redactSensitiveArgs, keyed off a newSENSITIVE_ARGS_COMMANDSflag (auth,hello,migrate,acl,config,sentinel). Sensitive tokens are replaced with"[REDACTED]"while non-secret parts of the command stay visible; non-sensitive commands return the original args array unchanged.DataHandler.returnErrorandabortErrorinevent_handler.tsnow attach redacted args to errors.Unit tests cover each redaction rule (including malformed commands and
Bufferargs); functional tests assert redaction on real failed commands and on AUTH aborted by disconnect.Reviewed by Cursor Bugbot for commit bbd047a. Bugbot is set up for automated code reviews on this repo. Configure here.