CVE-2021-32626 is patched for Redis 5 and 6 and in unstable:

$ git log --all --oneline --grep="CVE-2021-32626" | cat
0f8b634cd Fix invalid memory write on lua stack overflow (CVE-2021-32626) (#9591)
8f241ab3b Fix invalid memory write on lua stack overflow {CVE-2021-32626}
666ed7fac Fix invalid memory write on lua stack overflow {CVE-2021-32626}
a4b813d8b Fix invalid memory write on lua stack overflow {CVE-2021-32626}

If I want to patch Redis 4 for myself, what do I need to take care of? I see that lua_checkstack is used, but I can't determine what value should be used for the second argument and how the body of the conditional should look like. Do you have any guidance on how to fix the CVE in Redis 4?

Comment From: oranagra

just cherry pick the commit (a4b813d8b) from the 4.0 branch, i've just tested and it works nicely (clean cherry pick with no conflicts). unlike redis 6.0 (due to RESP3), not much changed in that area between redis 5.0 and 4.0.