Basically, Redis is not immune to escaping issues when the input line is used verbatim. For example:
SET mykey <some-attacker-chosen-data>
However, Redis is not immune to problems arising from the use of invalid input in the context of string interpolation, as Sven Herzberg has shown. To make Sven's example safe, you can simply use the hash and avoid a return to interpolation. Otherwise, use either non-common prefixes to use in combination with key interpolation, or use some basic form of health check on an input that filters out the separator used or better, confirm that the input is actually a number (in a specific example).
So, while Redis does not suffer from typical SQL attack attacks, when you use untrusted input in the context of string interpolation, used to create key names or, even worse, Lua scripts, some caution should be exercised.
antirez
source share