Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gteissier
GitHub Repository: gteissier/erl-matter
Path: blob/master/Internet-scan.md
271 views

Erlang processes exposed on the Internet

The main goal of erl-matter is to identify and weaponize Erlang distribution weaknesses. Automatically generated cookies are weak, and while bruteforce works, it also requires significant time for the attack to succeed.

This time we have opted to take a broader view of the Internet.

Erlang cookies may be automatically generated once, but they may also be directly setup using startup parameters: -setcookie allows for this.

Are weak cookies only the tip of the iceberg ?

Step 1: scan the Internet

To answer this question, Shodan is the first idea that comes to mind.

But Erlang distribution can be enabled in a lot of different projects, some of them probably unknown, with source code not published to the Internet. We cannot simply search for name like rabbitmq or ejabberd. We have opted to search for tcp/4369, which relates to the Erlang Port Mapper Daemon.

Its presence indicates that an Erlang process supporting distribution was once started on this machine. Several processes may be running, in which case, a list of processes - their name and on which port to contact them - will be returned by the EPMD scanner shodan uses.

The initial result for EPMD - early 2019 - has yielded 151407 entries. As explained above, each entry is an EPMD listing, hence, each entry itself may yield to multiple Erlang processes. Counting up, 170438 Erlang processes were listed on the Internet.

We have grouped by Erlang process name:

  • 55% of the exposed Erlang processes are rabbitmq and ejabberd:

Erlang process nameProduct, link to descriptionCount
rabbitrabbitmq, AMQP broker56903
ejabberdejabberd, XMPP broker37908
  • followed by a long tail of Erlang processes, some of them rather interesting such as chef, erlac or mongooseIM:

Erlang process nameProduct, link to descriptionCount
riaksearchriak_search3146
flussonicflussonic3061
ns_1couchbase2580
babysitter_of_ns_1couchbase2539
flussonic-thumbnailerflussonic2254
couchdb_ns_1couchbase2102
couchdbcouchdb1995
vpnu-radius1911
emqemq, MQTT broker977
vpn_assemble667
riakriak645
rabbitmqrabbitmq, process name of ancient versions487
emqttdemq425
cm410
emqxemq359
terminal357
freeswitchmod_erlang_event, IPBX271
relay255
ejabberd-srvejabberd243
janus238
bosstdsbosstds, Web load balancer200
zulipzulip198
erlacIntel Active System Console, Intel BMC179
ercheferchef, continuous automation platform175
bouncer172
bookshelfpart of chef169
VerneMQvernemq, MQTT broker155
mongooseimmongooseIM, XMPP broker, may also be embedded in other products such Wazo IPBX148
splynxsplynx billing systems ISP/WISP147
kolab_guamGuam, reverse IMAP proxy, part of a groupware solution. Future features include Data-Loss Prevention (DLP) capabilities and Audit Trail integration.142
bigcouchbigcouch, also embedded in 2600Hz, clustering of couchdb140
slot127
mulog_agent_1113
ecallmgrkazoo 2600Hz112
vpnrouter_game_p1_s1108
  • the list is still long, with a lot of Erlang processes named via a pattern like the last one above, but we have added two more points of interest:

Erlang process nameProduct, link to descriptionCount
nms_starterAlcatel-Lucent OmniVista 2500 Network Management System63
sip_ss7_intercom1

Step 2: harvest cookies

Now that we have a list of Internet exposed Erlang distribution ports, we have tried to find the cookie associated, to open the door to remote code execution.

A common way to start an Erlang based component is to wrap Erlang VM options in a specific file called vm.args. And the cookie may be hardwired using -setcookie option. A github search for Erlang projects and -setcookie reveals more than 100 pages of results. We have put most of the leaked cookie in a dictionary.

Not all the processes listed above had their cookie revealed via code source examination. Some of Erlang processes did not had their sources published on the Internet.

Step 3: do not forget the obvious answer

One more twist: guess what is the cookie if everything else fails ? Random and hard to guess, without a link with the process name ?

Keep it simple: use the process name itself !

It happens the cookie value is just the Erlang process name itself. It is often left to the careful and wise system admin to modify the tiny yet powerful secret.

So we have added it to the dictionary-erldp logic, which bruteforces the cookie from a given list of leaked cookies, and the substrings of the process name itself.

In a sandbox, this gives:

asciicast

Secure your assets

Only good sense here, but having more than 100k machines exposed, it is worth repeating it again !

  • minimize network exposition: Erlang distribution has virtually no reason to be exposed on the Internet. The use for remote control and clustering shall be controlled, not opened to the Internet

  • change default Erlang cookies: we have seen many default cookies accessible at github and google. And the combination of an open port and a known cookie gives remote code execution to attackers.

Many many thanks to Cyril for giving shodan download credits !