-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential RCE via :erlang.binary_to_term #59
Comments
Hi @vovayartsev !! First of all, thanks for bringing this up. I'm glad to discuss it. Let me share my thoughts. I agree with what you outlined above. However, I don't think this is an issue that should be addressed by Nebulex, IMO, it is more on the Nebulex client/user side. Nebulex is just the Cache wrapper, that can be seen as the cache itself in this scenario. This means what is stored in the cache is the user's responsibility. Like you said, what if a user wants to store an anonymous function? From the Nebulex standpoint, we shouldn't prevent that. The validation of the data to be stored (if you want any) should come from the client/user logic. Besides, the iex> f = fn _, _ -> IO.puts "I was executed!!!"; {:halt, []} end
iex> MyApp.Cache.put("fun", f)
:ok
iex> value = MyApp.Cache.get("fun") # Nebulex just returns what it was stored
iex> is_function(value)
true So, Nebulex is not evaluating the fetched values or iterating over them, it just returns the stored data. Therefore, the issue itself is on the business logic using the adapter (on the user side), since it is where the value may be potentially evaluated. Does it make sense? Now, let's say you want to add extra security validating the values to be stored in the cache. You can do that by providing your own serializer via the Anyway, I just wanted to share my thoughts about this, but let me know what you think. |
Thank for the very detailed reply @cabol ! Providing an own serializer via the As for community (vs just me) - what do you think is the best way to raise awareness? |
Thank would be great. I can think of a couple of options:
|
Challenge accepted 😎 |
This is explained well in https://paraxial.io/blog/elixir-rce
Basically, the code below will print
I was executed!!!
In Nebulex context this means that any iteration over structures fetched from Nebulex creates an RCE vulnerability through Redis.
Yes, normally Redis is not writable from the outside.... But still it's a "security weakness".
One potential fix would be using https://hexdocs.pm/plug_crypto/Plug.Crypto.html#non_executable_binary_to_term/2
The downsides are:
plug_crypto
(a small one and with no other runtime deps)non_executable_binary_to_term
would iterate over each result fetched from the cache)@cabol I'm happy to make a PR if you suggest a resolution for the above concerns 🙏
The text was updated successfully, but these errors were encountered: