TL;DR
- An admin page can be blocked outside a VPN while its login API still accepts public requests.
- A raw-path firewall rule can miss encoded requests when downstream components decode them before routing.
- Protect every entry to the capability, and make access checks agree with routing about which capability is being called.
You open the admin page from outside the VPN. Access denied. You reconnect through the VPN. The login form appears.
Both checks pass. Neither tells you whether someone can send a login request without opening that page.
This is a composite scenario explaining a general failure pattern. Routes, code and request outcomes below are illustrative; they are not a production incident transcript or a tested configuration for a particular framework.
The page and the API have separate entrances
![]()
Figure 1. The VPN gate covers one request path. A script can use the other without loading the page.
A login form is a client of an API. The browser might fetch GET /admin, then submit credentials to POST /api/login. Those requests can pass through different access rules.
Suppose the restriction covers only /admin. A script can send the POST directly. It needs the endpoint and the request format; it does not need the HTML form.
The API can still reject incorrect passwords. The failure is that an interface intended for private use has become a public place to try them.
Account lockout helps, but its counting scope matters. Trying a common password across many accounts is password spraying. Each account may remain below its lockout threshold even while the endpoint receives substantial aggregate traffic. An exposed endpoint does not guarantee a successful compromise; password strength, MFA and throttling still affect the outcome.
Keep account-based controls and complement them with source and broader abuse signals. Source-only limits also have gaps: attackers can change IPs, and legitimate users can share one. OWASP's credential attack guidance discusses these trade-offs.
The first question to test is simple: from outside the VPN, does the login request reach credential processing at all?
Why a spelling change can reopen the route
Adding a firewall rule for the API seems like the next obvious fix.
A web application firewall, or WAF, inspects HTTP requests before they reach the application. It can block suspicious requests, but its view of a path depends on its configuration and transformations.
Consider this deliberately incomplete rule:
# Illustrative vulnerable rule: path is the raw request path.
if path.startswith("/api/login"):
block()
The letter l can be represented as %6c. If the WAF checks raw text and the backend decodes before routing, the two components make different decisions:
Figure 2. One request has two representations. The rule checks one; the router uses another.
Double encoding adds another possible disagreement. Encoding the percent sign produces %256c. It becomes %6c after one decode and l after another:
| Request spelling | After one decode | After two decodes |
|---|---|---|
/api/login | /api/login | /api/login |
/api/%6cogin | /api/login | /api/login |
/api/%256cogin | /api/%6cogin | /api/login |
The last row reaches the same route only if the actual request chain performs those two decoding steps. A stack that rejects the request or leaves the remaining escape untouched behaves differently. OWASP's double-encoding explanation describes the general mechanism.
That condition is the point of the example. Encoding creates a bypass when the enforcement layer and the eventual consumer disagree. The string alone does not establish a vulnerability.
Adding %6c to the blocked list patches one representation. It leaves the larger question unanswered: which representation does each component use?
The fix: enforce the boundary where the route is known
For an admin-only interface, begin with an inventory: the page, login, recovery, session refresh and administrative APIs. Decide which must be private. A shared customer login cannot simply be restricted because the admin page also uses it.
Where practical, place private administration behind a dedicated ingress or host with a default-deny network policy. Cover its APIs as well as its pages, and prevent direct access to the origin from bypassing that ingress.
Inside the application, attach policy to the selected route. The check must run before its handler and before any protected side effect. This is conceptual middleware, not drop-in framework code:
route = router.resolve(request) # Resolve only; do not run the handler.
if route is None:
return not_found()
# Policies are explicit and default-deny, not inferred from a raw prefix.
policy = policies.for_route(route.id)
client = trusted_ingress.client_context(request)
if not policy.allows_network(client):
return forbidden()
if not policy.allows_identity(request.session):
return unauthorized_or_forbidden()
return route.handle(request)
The login route permits an unauthenticated identity so credentials can be checked, while still requiring the approved network. Administrative data routes require both the approved network and an authorized identity.
Figure 3. Equivalent spellings must receive the same access decision, or be rejected before dispatch.
An IP allowlist still depends on trustworthy client-address extraction. Accept forwarded address information only from configured trusted proxies; an arbitrary X-Forwarded-For header is not evidence of VPN membership. NGINX's real-IP documentation makes that trust configuration explicit.
Avoid introducing a separate “decode until unchanged” loop as a generic repair. Follow the router's supported normalization rules, reject unsupported ambiguity and prevent later components from reinterpreting an already-checked request. The security decision and dispatch must share the same meaning.
The counter-argument I take seriously
A correctly configured WAF can normalize paths and block these examples. Some frameworks reject them before routing. In either case, the illustrative bypass above fails.
Keep that protection. The reason to enforce route policy in the application is that private access should remain an explicit property of the operation. A WAF exception or alternate ingress should not silently turn it public. OWASP recommends checking authorization on every request and denying by default.
A VPN source also does not prove an individual user's identity. A compromised device or untrusted user on that network may pass the network check. Authentication, authorization and abuse controls remain necessary.
The transferable part
- Test the request behind the page. In an authorized test environment, call each private endpoint from outside the approved network. Verify that rejection happens before credential processing or protected work. A status code alone cannot prove where enforcement occurred.
- Test representations against the whole request chain. Send ordinary, encoded and double-encoded variants. Inspect the selected route and enforcement result. Every variant that reaches a private handler must receive its policy; unsupported variants should be rejected.
- Make private access explicit. Check route registration, ingress coverage and origin reachability together. Include an approved-network success case so a blanket outage cannot pass as a security fix.
These diagrams explain a failure mechanism, not a measured reduction in attacks. I have not benchmarked the controls or reproduced this exact stack. The useful change in the review question is concrete: after checking that the page is blocked, check whether every request behind it meets the same boundary.
