Erlang Port Mapper Daemon - PORT 4369
Become VeryLazyTech member! π
Follow us on:
β Twitter @VeryLazyTech.
πΎ Github @VeryLazyTech.
π Medium @VeryLazyTech.
πΊ YouTube @VeryLazyTech.
π© Telegram @VeryLazyTech.
π΅οΈββοΈ My Site @VeryLazyTech.
Visit our shop for e-books and courses. π
Basic info
epmd is a service used by Erlang nodes to find each other in a cluster.
It listens by default on TCP/4369 and keeps track of running nodes + their associated ports.
When an Erlang node starts, it registers with epmd. Other nodes can then query epmd to discover connection details.
The issue? If epmd is exposed to the internet without access controls, an attacker can enumerate running nodes and sometimes connect directly to the Erlang shell, leading to RCE.
Enumeration
When you see port 4369 open, the first step is enumeration.
Nmap Service Detection
Output:
Connect to epmd
You can query epmd directly using ncat or Erlang tools.
If you send:
(epmd n command), it responds with a list of nodes.
Output:
Or use built-in tools:
output:
Here, rabbit is a registered Erlang node (often RabbitMQ or CouchDB).
Exploitation Scenarios
Once we know thereβs an Erlang node, exploitation depends on the application running and security settings.
Scenario A β Connecting to Erlang Shell
If the Erlang node is configured with no cookie authentication or uses a default cookie, you can connect directly:
Then connect to target node:
If successful:
You now have a shell inside the Erlang node, where you can execute code.
Scenario B β Exploiting RabbitMQ / CouchDB
Applications like RabbitMQ (default uses rabbit node) rely on epmd. If the cookie is compromised, you can fully control the broker.
PoC to execute OS commands:
If successful, you get:
Erlang Cookie RCE
Remote Connection
If you can leak the Authentication cookie you will be able to execute code on the host. Usually, this cookie is located in ~/.erlang.cookie and is generated by erlang at the first start. If not modified or set manually it is a random string [A:Z] with a length of 20 characters.
More information in https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/ The author also share a program to brutforce the cookie:
Local Connection
In this case we are going to abuse CouchDB to escalate privileges locally:
Example taken from https://0xdf.gitlab.io/2018/09/15/htb-canape.html#couchdb-execution You can use Canape HTB machine to practice how to exploit this vuln.
Exploitation Workflow
Hereβs a step-by-step attack chain:
Scan target
Enumerate nodes
Extract Erlang cookie
Sometimes itβs in config files (
/var/lib/rabbitmq/.erlang.cookie)Weak/default cookie values (
cookie,rabbit) are common in old setups.
Connect using erl
Ping the node
Execute OS commands
Result:
Tools for Exploiting epmd
Metasploit Module:
auxiliary/scanner/erlang/epmd_enumNmap enumeration
Learn & practice For the Bug Bounty
Support VeryLazyTech π
Become VeryLazyTech member! π
Follow us on:
β Twitter @VeryLazyTech.
πΎ Github @VeryLazyTech.
π Medium @VeryLazyTech.
πΊ YouTube @VeryLazyTech.
π© Telegram @VeryLazyTech.
π΅οΈββοΈ My Site @VeryLazyTech.
Visit our shop for e-books and courses. π
Last updated