# Off-by-slash vulnerability in nodejs.org and iojs.org

Nginx off-by-slash in nodejs.org/iojs.org configs let `/metrics../` traverse out of the alias dir to read files like `/home/dist/.bashrc`.

- Payout: $1,200
- Severity: medium
- Program: Internet Bug Bounty
- Found by: nagaro
- Disclosed: 2022-07-28
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1650273
- Library page: https://bugbountylibrary.com/r/h1%3A1650273
- Tags: area:web domain:web impact:data-leak kind:bounty platform:hackerone sev:medium tech:nginx technique:recon technique:source-review vuln:misconfiguration vuln:path-traversal

**Target:** Nginx config for nodejs.org and iojs.org (location /metrics alias)
**Root cause:** `location /metrics` (no trailing slash) paired with `alias /home/dist/metrics/` (trailing slash) causes Nginx to strip the prefix and append the remainder, so `/metrics../` resolves to `/home/dist/../` and escapes the intended directory.
**Steps:**
1. Read nodejs/build nginx configs for nodejs.org and iojs.org
2. Spot `location /metrics { alias /home/dist/metrics/; autoindex on; }` — prefix lacks trailing slash, alias has one
3. Request `https://nodejs.org/metrics../.bashrc`
4. Observe contents of `/home/dist/.bashrc` returned, confirming traversal out of the alias dir
**How found:** Code-reading of public nginx configs in nodejs/build repo; recognized the classic off-by-slash alias pattern (Orange Tsai path-normalization research) and tested the `../` traversal against the live host.
**Exploitation:** Unauthenticated GET to `/metrics../<file>` on nodejs.org/iojs.org reads arbitrary files under `/home/dist` (e.g. `.bashrc`); autoindex on `/metrics` also lists the metrics dir.
**Insight:** When auditing nginx configs, grep for `location` blocks whose prefix lacks a trailing slash but whose `alias` has one — the mismatch lets `..` escape the alias root; test live hosts with `<prefix>../<file>` even when the path looks like a static endpoint.

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

**Request reading /home/dist/.bashrc via off-by-slash**

```
For example, you can browse the contents of `/home/dist/.bashrc` by accessing `https://nodejs.org/metrics../.bashrc`.
```

