On this page
Browser numeric IP address URL parsing can make two differently written URLs appear to name the same host. Before launch, compare what the browser constructs, what your reverse proxy receives, and what the application sees—especially if any layer makes decisions based on the host.
This guide provides a local comparison workflow. It does not treat a normalized URL or a successful request as proof that a system is secure.
Key Takeaways
- Compare ordinary dotted IPv4 notation with alternative numeric forms, but measure each browser rather than assuming it accepts or normalizes them identically.
- Capture the browser’s parsed URL, the proxy’s incoming request and
Hostheader, and the application’s view separately. - A browser may change a URL before sending it, so the server might never see the spelling the tester entered.
- Parser differences are diagnostic findings, not security assessments. Check the actual trust boundary and controls separately.
Choose a controlled set of URLs
Use a browser and a Python installation on an isolated test machine. The example server below listens only on 127.0.0.1; it uses port 18080 for a small diagnostic reverse proxy and 18081 for its backend application. Stop other services using those ports first.
The candidate URLs below are intended to explore different ways a numeric host might be interpreted. Acceptance and normalization are observations to record, not assumptions:
| Case | Candidate URL |
|---|---|
| Dotted IPv4 | http://127.0.0.1:18080/probe?case=dotted |
| Short dotted form | http://127.1:18080/probe?case=short |
| Single decimal number | http://2130706433:18080/probe?case=decimal |
| Hexadecimal-looking number | http://0x7f000001:18080/probe?case=hex |
| Leading-zero component | http://0177.0.0.1:18080/probe?case=leading-zero |
The nonstandard-looking forms are test inputs, not recommended public URLs. Browser, operating-system, proxy, and library behavior can differ. Test the actual versions used in your deployment.
Research and execution limits: The WHATWG URL Standard and Python’s server and URL-parsing documentation were not available to consult for this article. The example was not executed here, and no browser or server behavior below is presented as an observed result. Consult those sources and run the checks in your target environments before drawing compatibility conclusions.
Advertisement
Inspect the browser’s parsed URL first
Open the browser’s developer console and run this snippet. Constructing these URL objects is a parsing check; it does not itself send requests.
const candidates = [
['dotted', 'http://127.0.0.1:18080/probe?case=dotted'],
['short', 'http://127.1:18080/probe?case=short'],
['decimal', 'http://2130706433:18080/probe?case=decimal'],
['hex', 'http://0x7f000001:18080/probe?case=hex'],
['leading-zero', 'http://0177.0.0.1:18080/probe?case=leading-zero'],
];
console.table(candidates.map(([name, input]) => {
try {
const url = new URL(input);
return {
name,
input,
href: url.href,
host: url.host,
hostname: url.hostname,
port: url.port,
};
} catch (error) {
return { name, input, error: String(error) };
}
}));
Record the browser name and version, the original input, and every displayed field or error. host includes the port when one is present; hostname is the host without the port. Also record the address bar after navigation: it may not preserve the original spelling.
For the request stage, use an isolated environment with network egress restricted to the intended loopback endpoints. Use a direct browser connection rather than an external proxy, and disable extensions that could rewrite requests. Only navigate a candidate if the browser’s parsing result shows hostname as 127.0.0.1 and the port as 18080. Skip rejected or differently parsed inputs. This precheck helps avoid unintended destinations; the network restriction is still important.
Run a local diagnostic proxy and application
Save the following as numeric_ip_lab.py and run python3 numeric_ip_lab.py. It uses Python’s standard library and requires a Python installation with http.server, http.client, and urllib.parse. The proxy forwards only to the fixed local backend; it is a diagnostic example, not a production proxy.
import http.client
import json
import threading
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import urlsplit
PROXY_PORT = 18080
APP_PORT = 18081
def describe_request(handler, layer):
hosts = handler.headers.get_all("Host", [])
record = {
"layer": layer,
"request_line": handler.requestline,
"path": handler.path,
"host_headers": hosts,
}
if len(hosts) == 1:
try:
parsed = urlsplit("http://" + hosts[0] + "/")
record["parsed_hostname"] = parsed.hostname
record["parsed_port"] = parsed.port
except ValueError as exc:
record["parse_error"] = str(exc)
return record
def log_record(record):
print(json.dumps(record), flush=True)
class QuietHandler(BaseHTTPRequestHandler):
def log_message(self, format, *args):
pass
class AppHandler(QuietHandler):
def do_GET(self):
record = describe_request(self, "application")
log_record(record)
body = json.dumps(record, indent=2).encode("utf-8")
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
class ProxyHandler(QuietHandler):
def do_GET(self):
record = describe_request(self, "proxy")
log_record(record)
hosts = record["host_headers"]
if len(hosts) != 1:
self.send_error(400, "Expected exactly one Host header")
return
connection = http.client.HTTPConnection(
"127.0.0.1", APP_PORT, timeout=5
)
try:
connection.putrequest("GET", self.path, skip_host=True)
connection.putheader("Host", hosts[0])
connection.putheader("Connection", "close")
connection.endheaders()
response = connection.getresponse()
body = response.read()
status = response.status
except (OSError, http.client.HTTPException, ValueError):
self.send_error(502, "Local backend request failed")
return
finally:
connection.close()
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
if __name__ == "__main__":
app = ThreadingHTTPServer(("127.0.0.1", APP_PORT), AppHandler)
try:
proxy = ThreadingHTTPServer(("127.0.0.1", PROXY_PORT), ProxyHandler)
except OSError:
app.server_close()
raise
app_thread = threading.Thread(target=app.serve_forever, daemon=True)
app_thread.start()
try:
print("Local lab running; press Ctrl+C to stop.", flush=True)
proxy.serve_forever()
except KeyboardInterrupt:
pass
finally:
proxy.server_close()
app.shutdown()
app.server_close()
app_thread.join()
For each candidate that passes the browser precheck, enter the original candidate URL in the address bar. Capture the browser’s parsed fields and address bar, then capture the proxy and application records printed in the terminal. The case query parameter helps correlate the records. The application record is also returned in the response body. Ignore unrelated requests such as a browser’s favicon request.
The proxy logs the request it receives, then deliberately passes the received Host header to the fixed backend. Each layer also applies Python’s urlsplit to that header for a separate parser observation. That operation is not validation, and this particular proxy does not attempt to reproduce the host rewriting, virtual-host routing, or forwarded-header configuration of your production proxy.
Stop the lab with Ctrl+C. If a port cannot be bound, choose unused local ports and update both the script and every candidate URL consistently.
Advertisement
Compare with the deployed stack
Repeat the experiment in an authorized, isolated environment using the actual browser versions, reverse proxy configuration, and application runtime you intend to ship. Consult the WHATWG URL Standard for browser URL behavior and the documentation for your specific proxy and application server; the local Python proxy is only a way to expose the observation points.
For each case, record:
- The original input and whether browser URL construction succeeded.
- The browser’s
href,host,hostname, port, and address bar after navigation. - The proxy’s incoming request target and
Hostheader, plus any host value it uses for routing or forwards upstream. - The application’s received host-related headers and framework-parsed host, including any forwarded-host processing.
- Rejections, errors, redirects, and any transformations, with component versions and relevant configuration.
A useful finding describes the boundary precisely: for example, whether a difference arose before the request reached the proxy or while the proxy prepared the upstream request. Do not infer an application’s behavior from the proxy log alone. If a layer rejects a candidate, record the rejection rather than forcing it through another component and calling the result equivalent.
When sharing logs, remove cookies, authorization headers, tokens, and other sensitive data. The lab intentionally records only a small subset of request data.
Common Mistakes
- Assuming the server received the original URL text. The browser can parse or serialize it before making the request; compare the input with the actual request at each boundary.
- Treating one parser as authoritative for every layer. A browser’s URL object, a proxy’s routing logic, and an application framework may use different rules.
- Testing against a public or production destination. Use an isolated environment and explicit authorization; never rely solely on a numeric spelling to keep traffic local.
- Calling normalization a vulnerability—or a successful response a pass. Neither establishes whether an attacker can cross a security boundary.
- Assuming this Python proxy matches production. Real proxies may rewrite
Host, add forwarding headers, reject requests, or route differently.
Best Practices
Define which component is trusted to interpret the host and how that value is passed downstream. Review proxy and application configuration together, including which clients may supply forwarded headers. Test both accepted and rejected inputs after configuration or version changes.
If the application fetches user-supplied URLs, investigate that feature separately: URL parsing or a hostname check alone is not an SSRF defense. Controls may need scheme and destination restrictions, DNS and connection-time checks, redirect revalidation, network egress restrictions, timeouts, and response-size limits.
Conclusion
Numeric host tests are most useful when they show where interpretation changes. Capture the browser, proxy, and application views independently, then assess any difference against the actual deployment’s routing and security controls.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.