The pqc-probe CLI runs on your own machine, against servers you chose. The web service turns that around. A stranger types a hostname into a form, and the operator's server opens TLS and SSH connections to it, parses whatever comes back, and shows the result in the stranger's browser.
That is a request-forgery machine unless it is designed not to be one. The form must not reach the operator's internal network, must not turn into a free port scanner or a way to hammer someone else's server, must not fall over under load, and must not let a hostile server put script into a visitor's page. This post covers how pqc-probe-web handles each, what the tests pin down, and what is still open.
Part 6 of a series on building pqc-probe. Earlier: part 1, part 2, part 3, part 4, part 5.
What can go wrong
The service has a written threat model. It names five things worth protecting:
- The operator's internal network, including the cloud metadata service at 169.254.169.254. The probe makes outbound connections; it must not become a way in.
- Third-party servers. They must not be port-scanned or hammered through the service.
- The operator's IP reputation. Every target sees probes coming from that address.
- The service's own capacity: CPU, processes, memory, connections.
- Visitors. Report pages show text chosen by a server that may be hostile.
And four kinds of attacker: a visitor sending crafted targets or floods, a scanned server sending hostile data, the DNS authority for a submitted name, and anyone on the network who can reach the service without going through its reverse proxy.
Each row in that document names the test that pins its mitigation, or says plainly that it follows from the design or must come from the operator. Most of what follows comes down to the order of checks a request passes before any socket is opened:
The order matters. A repeat request is answered before it costs the client anything. The client's budget is charged before DNS, because DNS is the first step that costs real work. And the per-address budget comes after resolution, because only then is the real server known.
Where the probe may connect
Server-side request forgery is the first thing to rule out. If a visitor can submit 10.0.0.5, or a name that resolves to it, the service becomes their window into the operator's network.
The host string is strict. Only ASCII letters, digits, dots and hyphens, and no label may start or end with a hyphen. That refuses URLs, user@host, IPv6 literals and anything that looks like a command-line option, such as -oProxyCommand=.... The host is later passed to openssl and ssh as exactly one argument, with no shell.
Every address is checked, after resolution. The name is resolved once, and every IPv4 address in the answer is checked against a blocklist: 0/8, 10/8, 100.64/10, 127/8, 169.254/16 (the metadata services), 172.16/12, 192.168/16, the documentation and benchmarking ranges, multicast, 240/4 and a few more. If any one record is private, the whole target is refused:
for &ip in addrs {
if let Some(reason) = blocked_reason(ip) {
return Err(PolicyError::BlockedAddress {
host: host.to_string(),
ip,
reason,
});
}
}
Ok(Target::new(host, port).with_resolved(first))
Checking after resolution also handles the numeric tricks. 127.1, 0x7f.1 and 2130706433 all pass the syntax check, but the resolver turns each into 127.0.0.1, and the address check refuses it. There is a test for each.
The probe connects to the address that was checked. That last line returns a Target pinned to the resolved address. openssl and ssh are given the IP; the name is used only for SNI. That closes DNS rebinding, where a name answers with a public address for the check and a private one a moment later for the connection: there is no second lookup to poison. The same answer is reused for SSH, so a request for both protocols costs one lookup, and both probes go to the same checked address.
IPv4 only. Only A records are used and both tools are forced to -4. That keeps IPv6 and v4-mapped addresses out of the picture entirely. It also fixed a real problem: Tokio's resolver asks for every address family, and on a network with broken IPv6 DNS it sat waiting for the AAAA answer for more than five seconds. The lookup now asks getaddrinfo for AF_INET only, on a blocking thread, with a 5-second limit and one retry.
None of this replaces a network-level egress filter. The threat model lists that as the operator's job: the application check is the first line of defence, not the only one.
Rate limits in three layers
A scanner anyone can use needs limits on who is asking, on who is being asked, and on asking the same thing twice.
Per client. Each client gets a token bucket for submissions (burst 5, refilling at 6 a minute), at most 2 probes in flight and 60 a day. Polling for status has its own, looser bucket (burst 60, 120 a minute), so a browser refreshing a report page doesn't eat the submission budget.
Who "the client" is takes some care. Behind a reverse proxy, every request arrives from the proxy's address, so the real client is in X-Forwarded-For. But anyone can send that header. The service believes it only when the direct peer is a configured proxy, and reads it from the right, skipping trusted proxies, because the left-hand entries are whatever the client chose to write:
if !trusted.contains(&peer) {
return peer;
}
let Some(header) = forwarded_for else {
return peer;
};
for part in header.rsplit(',') {
let Ok(ip) = part.trim().parse::<IpAddr>() else {
return peer;
};
let ip = ip.to_canonical();
if !trusted.contains(&ip) {
return ip;
}
}
peer
IPv6 clients are bucketed by their /64, not their full address. A single host usually controls a whole /64, so counting each address separately would hand it 2^64 budgets.
Per target address. A per-client limit doesn't stop twenty clients pointing at one small server, or one client cycling through twenty aliases for it. So there is a second limit per resolved server address, shared by everyone: burst 6, 12 a minute. Past that, the answer is 429 target_busy. This is the reason the check sits after DNS.
Per request. A repeat of the same request within 60 seconds gets the earlier job back, with reused: true. It costs no DNS lookup, no connection and nothing from the client's budget. The key is the target name lower-cased with one trailing dot removed, plus the protocol, mode and ports.
My first design keyed this cooldown on the resolved address instead, which looked stricter. It would have been wrong: many unrelated sites share one CDN address, and keying on the address would hand one site's report to a visitor who asked about another. The name is what the visitor asked about, so the name is the key, and the per-address limit takes care of politeness to the shared server.
What goes back to the visitor
The response is an attack surface too, in two directions: what it reveals about the operator, and what a hostile server can smuggle into it.
Errors say what happened, not where. A refused target is reported by the range it fell in ("private network", "benchmarking range"), never by the address it resolved to, so a visitor can't map the operator's internal DNS by submitting names. Resolver error text goes to the log, not the page. And a probe tool that fails to start gives a fixed sentence, while the path and OS error go to the log:
ProbeError::SpawnFailed(io) => {
tracing::error!(error = %io, "could not start a probe tool");
"a probe tool could not be started on the server".to_string()
}
The matching test feeds it an error mentioning /secret/path/openssl and checks the word secret never comes out.
A failure in one protocol doesn't hide the other. If TLS succeeds and SSH times out, the report keeps the TLS result and lists the SSH error beside it. The job fails only when no protocol produced anything.
Job ids can't be guessed. They are UUID v4, 122 random bits, written as 32 hex characters. Anything else is rejected before lookup and never echoed back.
Hostile text stays text. Certificate fields, SSH banners and algorithm names all come from the scanned server. Every one goes through one escaping function before it reaches HTML, and control characters are replaced too:
pub fn esc(s: &str) -> String {
let mut out = String::with_capacity(s.len());
for c in s.chars() {
match c {
'&' => out.push_str("&"),
'<' => out.push_str("<"),
'>' => out.push_str(">"),
'"' => out.push_str("""),
'\'' => out.push_str("'"),
c if c.is_control() && c != '\n' => out.push('\u{fffd}'),
c => out.push(c),
}
}
out
}
Escaping is the first line. The second is that the pages need no JavaScript at all. The form is a plain POST that redirects to the job page, and the job page polls with a meta refresh until the report is ready. With nothing to allow, the Content-Security-Policy can forbid everything:
default-src 'none'; style-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'
Even if a value slipped past esc(), the browser would refuse to run it. The pages also send X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer and X-Frame-Options: DENY. JSON is built with serde, never by string formatting, and server-controlled strings are not written to the log.
Testing it, and what is still open
Every mitigation in the threat model points at a test or says why it can't have one. The web crate has 83 tests and the core library 91. A few that carry the most weight:
-
blocked_ranges_are_blocked_including_boundariesandpublic_addresses_and_range_neighbours_are_allowed: the first and last address of each blocked range, and the addresses just outside it. -
connect_host_prefers_resolved_address: the tools are given the checked IP, not the name. -
one_server_address_is_not_probed_more_than_its_budget_whatever_the_name: aliases share one budget. -
x_forwarded_for_counts_only_from_a_trusted_proxy: a spoofed header from a direct client is ignored. -
nothing_a_scanned_server_controls_reaches_the_page_unescaped: a hostile report, with markup in every field a server controls, rendered through every page.
Unit tests can't show that the limits hold under concurrency, so there is also a load test, scripts/loadtest.py, using only Python's standard library. It is deliberately polite to the outside world and starts at most one real probe. It floods the health and metadata endpoints and fails on any 5xx. It fires many identical submissions at the same moment, and every accepted one must carry the same job id; that proves the cooldown reuse is atomic and not a race. Then it floods the status endpoint, expecting 200s and then 429s with Retry-After, and still no 5xx. Every check passed before the release.
Some gaps are known and written down rather than hidden:
- State is in memory. A restart forgets jobs, limits and cooldowns, which hands every client a fresh budget.
- A stalled DNS lookup keeps its thread until the system resolver gives up, even after the 5-second limit. The per-client limits bound it, but it isn't capped on its own.
- People behind one NAT, or one IPv6 /64, share a budget.
- A busy shared address can be refused to everyone for a moment. The per-address limit applies to CDN addresses too.
- There is no authentication and no abuse reporting. A target owner who wants to be left alone needs the operator to change the policy or the proxy.
- The report is only as honest as the handshake. A server can lie about what it supports. The report says what a handshake showed, not what the server's configuration is.
The service also doesn't sandbox itself. For a public deployment, the operator still has to run it as a non-root user with resource limits, filter egress at the network layer, put it behind a TLS-terminating proxy, and log requests there.
Takeaways
- Check the address, then connect to that address. Validating a name and connecting to the name later leaves room for DNS rebinding. Pin the resolved IP.
- One private record refuses the whole target. A name with a public and a private address is a probe for your network, not a mistake.
- Put each limit where its key is known. Client limits before DNS, because DNS costs work. Server limits after DNS, because only then do you know the server.
- Key a cache on what the user asked about. An address is shared by many sites; the name is not.
- Don't need JavaScript, then forbid it. A page with no script can carry a CSP that blocks all of it, which backs up escaping instead of relying on it.
- Write the threat model down, with evidence. A mitigation that points at a test can be trusted after the next refactor; one that points at nothing can't.
The web service is in the repo as pqc-probe-web, and in the Docker image from part 5. If you run it publicly, read the operator section of the threat model first.

Top comments (0)