Repository navigation
Fix SET mutually exclusive NX/XX and IF* options - #15291
Conversation
|
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. |
|
This change touches performance-sensitive code paths. Adding the |
|
My concern is that this might be a breaking change. |
Do note that after the parsing stage in
Here is output of redis-cli: Can you clarify WDYM by silently accepted ? EDIT: my bad. I see the other way around is indeed syntax error.
|
|
I'd suggest accepting this change. |
CE Performance Automation : step 1 of 2 (build) STARTING...This comment was automatically generated given a benchmark was triggered.
|
CE Performance Automation : step 2 of 2 (benchmark) RUNNING...This comment was automatically generated given a benchmark was triggered. Started benchmark suite at 2026-06-17 15:01:52.272529 and took 158.071071 seconds up until now. In total will run 140 benchmarks. |
This reverts commit 914eac4.
|
Just realize that 914eac4 is wrong. If we want to cover this bug, we need to put the |
Follow #14435
The conditions
NX,XX,IFEQ,IFNE,IFDEQandIFDNEbelong to a single mutually-exclusive group. TheIF*parse branches enforced this against the whole group (cond_mut_excl), but theNX/XXbranches only checked each other.This made rejection depend on argument order.
SET k v NX IFEQ xwas rejected (theIFEQbranch sawNXalready set), butSET k v IFEQ x NXwas accepted (the NX branch ignored theIFEQflag).Affected command examples (all silently accepted before the fix):
Note
Low Risk
Small change to SET argument parsing only; it rejects previously accepted invalid syntax and does not alter successful SET semantics.
Overview
SET extended-option parsing now treats NX, XX, and the IFEQ / IFNE / IFDEQ / IFDNE conditions as one mutually exclusive group during argument parsing.
Previously, the IF* branches used the full
cond_mut_exclmask, but NX and XX only blocked each other. That made validation depend on token order—for exampleSET k v NX IFEQ xfailed whileSET k v IFEQ x NXwas accepted. The NX and XX branches inparseExtendedStringArgumentsOrReplynow use the same(cond_mut_excl & ~OBJ_SET_NX)/(cond_mut_excl & ~OBJ_SET_XX)checks as the IF* options, so invalid combinations always return a syntax error regardless of order.Unit tests were added for NX/XX paired with each IF* flag (both orderings) and for IF* flags combined with each other, asserting the key is unchanged on error.
Reviewed by Cursor Bugbot for commit 833bc97. Bugbot is set up for automated code reviews on this repo. Configure here.