-
Notifications
You must be signed in to change notification settings - Fork 453
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
Meta protocol flush_all method is vulnerable to code injection (Lack of input type check) #932
Comments
Thanks @xhzeem - very helpful. While I'm not sure that the threat surface here is that large (if you have control over the flush_all argument you probably have control over the Dalli client), but I agree that this should be sanitized. I'll get a fix in shortly. |
Thanks for your fast response... Anyway, the point here is not about being able to write ruby code, but instead passing unsafe user-controlled data to that method which can be used in some cases by malicious actors to inject more commands into the Memcached server. |
I see the fix is sufficient. |
I’ll do some final checks today and confirm I cannot find any other similar issues |
I'm unable to get some tests done right so if you can help to confirm dalli/lib/dalli/protocol/meta.rb Line 111 in 5588d98
How should I call this method and pass the cas ?
dalli/lib/dalli/protocol/meta.rb Line 46 in 5588d98
The touch function is lacking the ttl = TtlSanitizer.sanitize(ttl) if ttl part, but as far as my tests it is still only accepting numbers in the TTL, I cannot get the flow exactly.
If you can confirm those two methods are safe I think everything else is good so far as of my checks. |
@xhzeem I'll take a look. I don't think Dalli does any material checking on the format of the CAS, but memcached does require the CAS to be a 64-bit value. So that's an easy sanitize. I'll add that and a corresponding test. Regarding touch, the ttl is sanitized at the |
Good job I've checked the lastest version and to me, everything looks great. |
Security fix for petergoldstein/dalli#932
Security fix for petergoldstein/dalli#932
Hi there,
I'm a security researcher currently doing research on Memcached wrappers vulnerabilities. I was doing some source code reviewing on your wrapper and noticed that the
flush_all
method on the meta protocol takes a delay value and passes it to the server without any checks, which can be used to smuggle commands to the Memcached server if an attacker has control over the value passed to the flush_all method.dalli/lib/dalli/protocol/meta.rb
Lines 137 to 140 in 5588d98
dalli/lib/dalli/protocol/meta/request_formatter.rb
Lines 76 to 81 in 5588d98
Proof of Concept
Suggested Fix:
You should just add a simple check for the
delay
type and confirm it's a number or keep the 0 value.The text was updated successfully, but these errors were encountered: