Vulnerability research · Deep dive

Beyond the Perimeter: two filters, two detours

During a security assessment, Uzair Kaaf came across a JSP application behind a cloud WAF that blocked every classic XSS attempt. The origin server, however, was directly reachable from the internet, and all that waited there was a keyword filter. A payload that assembles its code only in the browser got past both layers.

Class
CWE-79 · CWE-184
Severity
CVSS 3.1: 8.0 (High)
Precondition
Reachable origin, victim opens a link
Impact
JavaScript in the origin's context
At a glance

A WAF is a seatbelt, not armor

The application relied on two filters: a cloud WAF at the edge and a blocklist in the code. Both could be bypassed, one via the network path, the other via the expressiveness of JavaScript. What was missing was output encoding.

  • 01

    What happens

    A legacy JSP endpoint reflects the course parameter into the page without HTML encoding. The cloud WAF blocks this on the main domain. But the origin server also accepts direct connections, and there only a blocklist checks for known keywords.

  • 02

    What the attacker needs

    No account and no credentials, but reconnaissance: finding the directly reachable origin server, building a payload without blocked words, and a victim who opens a crafted link.

  • 03

    What the attacker achieves

    Arbitrary JavaScript in the victim's browser, in the context of the origin server. A session takeover follows only under conditions: the origin must be reachable under a hostname of the domain that the session cookies apply to, and the cookies must not carry HttpOnly. In the report, HttpOnly was missing.

  • 04

    How to classify it

    As cross-site scripting (CWE-79), enabled by an incomplete list of disallowed inputs (CWE-184). The directly reachable origin is an unprotected alternate channel (CWE-420): the main path is protected, the second one is not. On top of that, a session cookie without HttpOnly (CWE-1004).

Severity according to CVSS 3.1

8.0High

VectorCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:N (opens external website)

The author's assessment: the attack works over the network and without an account, but requires finding the origin server first (high complexity), and a victim has to open a crafted link. Because the script runs in the victim's browser, the scope is changed. The high confidentiality and integrity ratings assume that the script reaches the session, meaning it runs under a hostname of the domain and the cookie lacks HttpOnly. Without that access, the rating would be considerably lower.

CWE-79 (opens external website)CWE-184 (opens external website)

Rank 5

is held by Injection, which includes cross-site scripting, in the OWASP Top 10:2025, with 1,404,249 recorded occurrences and 62,445 mapped CVEs. According to OWASP, XSS alone accounts for more than 30,000 CVEs.

A05:2025 Injection (December 2025) (opens external website)

The target and its domain are not named. Domain, path and IP addresses on this page are anonymized; we deliberately show requests and payload only in abridged form.

The layers

Each layer relied on the next one

A cloud WAF filters what passes through its proxy. It does not replace secure code, and it only protects as long as there is no second path to the server.

Observed pattern

  1. OperatorPuts a cloud WAF in front of a legacy JSP application and considers XSS handled.
  2. OriginAccepts connections on ports 80 and 443 from any address, not just from the WAF.0.0.0.0/0 → :443
  3. ApplicationFilters known keywords instead of encoding the output.alert( · prompt( · confirm(
  4. BrowserExecutes the code assembled at runtime; without HttpOnly, the session cookie is readable by script.document.cookie

Four layers, and none of them closed the gap.

Secure pattern

  1. OperatorTreats the WAF as an additional layer, not as a replacement for safe output.
  2. OriginOnly accepts connections from the WAF, which authenticates with a client certificate.mTLS · WAF ranges only
  3. ApplicationEncodes every output for its context; markup turns into harmless text.<img src=x …>
  4. BrowserA CSP without 'unsafe-inline' and 'unsafe-eval' blocks inline handlers and code from strings; HttpOnly protects the cookie.script-src 'self'

If one layer fails, the next one holds.

Blocklists and WAF rules look for known patterns. But JavaScript offers countless ways to write the same code differently. The only reliable defenses work regardless of content: context-aware output encoding in the application, and an origin that can only be reached through the WAF.

Proof of concept

The attack path in four acts

Domain, path and addresses are anonymized, requests and payload abridged. The sequence matches the report.

The cloud WAF holds

The course parameter of a legacy JSP endpoint was reflected into the page without HTML encoding, a classic candidate for reflected XSS. On the main domain, however, the cloud WAF in front blocked every attempt to inject even basic HTML tags or event handlers and returned 403.

Request
GET /…?course=<script>alert(1)</script>Host: www.example.com
Response
HTTP/1.1 403 Forbidden<h1>403 Forbidden - Request Blocked by Web Application Firewall</h1>

Abridged; domain and path anonymized.

Only reproduce on your own systems or with the operator's written permission.

Filter lab

Which layer actually holds?

Choose path, payload and protection and see where the request is stopped. The lab only models the logic of the finding; it sends no requests and executes no code.

Request path
Payload
Protection in the application

Path through the layers

  1. 1Cloud WAFbypassed
  2. 2Applicationpassed
  3. 3Output in the HTMLinserted raw
  4. 4Victim's browserexecuted

Executed: the finding

The WAF is bypassed, the blocklist finds no known word, the output is raw, and no CSP intervenes. The browser assembles the code and executes it in the context of the origin server.

Simplified model of the finding. Real WAFs and filters differ in their rules; the principle stays the same.

Root cause

Three assumptions that did not hold

None of the three gaps alone would have been enough. Only together did a filtered input bug turn into an exploitable attack path.

1

The origin was directly reachable

The server accepted connections from the entire internet. That made the WAF a recommendation rather than a requirement: anyone who knew the address could skip it.

2

Filtering instead of encoding

The application tried to recognize dangerous input by known words instead of encoding every output. A blocklist is never complete, and JavaScript offers many ways to write the same code differently.

3

Session cookies without HttpOnly

Without HttpOnly, any script on the page may read the session cookie. If the script runs under a hostname the cookie applies to, script execution quickly turns into session takeover.

Why the flaw goes unnoticed day to day

The WAF dashboard shows blocked attacks and gives the impression that everything is protected. Requests sent directly to the origin never show up there, because they never pass through the WAF. They only become visible when someone compares the origin server's logs with the WAF's.

Remediation

How to close the gap

The first measure fixes the root cause in the code. The second makes the WAF mandatory again. The third limits the damage in case something still slips through.

  1. 01

    Encode output for its context

    Every value from the request is encoded for its context when inserted into the page: HTML content, attribute, JavaScript or URL. In JSP, <c:out> does this, as it converts HTML special characters by default, or the OWASP Java Encoder. Blocklists and WAF rules are no substitute; the OWASP XSS cheat sheet explicitly advises against relying on a WAF instead of context-aware encoding.

    Encoded output in the JSP
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%-- c:out escapes <, >, &, ' and " by default (escapeXml="true") --%><p>Selected course: <c:out value="${param.course}" /></p><%-- or with the OWASP Java Encoder --%><%@ page import="org.owasp.encoder.Encode" %><p>Selected course: <%= Encode.forHtml(request.getParameter("course")) %></p>
  2. 02

    Make the origin reachable only through the WAF

    The origin's firewall allows ports 80 and 443 only from the published ranges of the WAF or CDN provider and drops everything else. Because many of the provider's customers share these ranges, authentication belongs on top: the provider identifies itself to the origin with a client certificate (mTLS, called "Authenticated Origin Pulls" at Cloudflare), ideally with your own certificate rather than a provider-wide one. Better still, where possible: an outbound tunnel with no open ports at all. Then verify: a direct request to the origin address must no longer get a response.

    Firewall and mTLS at the origin (nftables, nginx)
    # nftables: ports 80/443 only from the WAF/CDN rangestable inet origin {  set cdn_v4 { type ipv4_addr; flags interval; elements = { 198.51.100.0/24 } }  set cdn_v6 { type ipv6_addr; flags interval; elements = { 2001:db8::/32 } }  chain input {    type filter hook input priority 0; policy accept;    tcp dport { 80, 443 } ip saddr @cdn_v4 accept    tcp dport { 80, 443 } ip6 saddr @cdn_v6 accept    tcp dport { 80, 443 } drop  }}# nginx: only the CDN with its client certificate (mTLS)ssl_client_certificate /etc/nginx/certs/origin-pull-ca.pem;ssl_verify_client on;
  3. 03

    Harden cookies and set a CSP

    Session cookies carry HttpOnly, Secure and SameSite; then even an injected script cannot read them. A Content Security Policy without 'unsafe-inline' and 'unsafe-eval' blocks inline event handlers such as onerror and code from strings, like the one setTimeout() executed here. Both are a second line: they limit the damage but do not fix the missing encoding.

    Response headers (example)
    Set-Cookie: JSESSIONID=…; Path=/; Secure; HttpOnly; SameSite=StrictContent-Security-Policy: default-src 'self'; script-src 'self';  object-src 'none'; base-uri 'none'; connect-src 'self';  frame-ancestors 'none'

Additional hardening

  • Search for your own origin from outsideCheck regularly whether your origin can be derived from public data: network assignments, certificates, old DNS records. External attack surface management automates this.
  • New address after locking downIf the origin address was already known, it remains findable in historical records. Changing the address together with the lockdown removes that trail.
  • No hostnames pointing straight at the originHostnames such as origin.example.com that bypass the proxy and point to the origin open exactly that alternate path. Cookies set for the whole domain are sent there as well.
  • Host-only cookies with the __Host- prefixCookies without a Domain attribute only apply to their own hostname. The __Host- prefix enforces this together with Secure and Path=/.
  • Compare logs, test directlyRequests at the origin that do not come from the WAF are a warning sign. Pentests should explicitly include the origin and test filters with variants, not only with standard payloads.

Foundations: Cross Site Scripting Prevention Cheat Sheet (opens external website) · OWASP Java Encoder (opens external website) · Protect your origin server (October 2026) (opens external website) · Authenticated Origin Pulls (mTLS) (opens external website) · Content-Security-Policy: script-src directive (opens external website) · Set-Cookie header (opens external website)

Self-check

How binding is your WAF?

Eight questions for operators, development and security teams running web applications behind a WAF or CDN. The self-check does not replace an assessment, but it shows where you should take a closer look. Your answers stay in your browser.

  1. 01Does your origin server accept connections on ports 80 and 443 only from your WAF or CDN provider's ranges?
  2. 02Does the WAF additionally authenticate to the origin, for example with a client certificate (mTLS), rather than IP lists deciding alone?
  3. 03Have you checked whether your origin can be found via public network data, certificates or old DNS records?
  4. 04Does your application encode every output for its context (HTML, attribute, JavaScript, URL) instead of filtering keywords?
  5. 05Do your session cookies carry HttpOnly, Secure and SameSite?
  6. 06Do you use a Content Security Policy without 'unsafe-inline' and 'unsafe-eval'?
  7. 07Do your pentests also test the origin directly, not only the path through the WAF?
  8. 08Would you notice if requests reached the origin without passing the WAF, for example by comparing logs?

Answered: 0/8

The result is guidance, not proof of compliance.

Context for GRC and audit

When the WAF is the only control

Regulations require technical measures that are effective, not merely present. A finding like this shows: the control exists, but it can be bypassed.

ISO/IEC 27001

The controls on secure coding, network security and configuration management, together with security testing in development and acceptance, interlock here. An ISMS must also evaluate the effectiveness of its controls. Audits should therefore verify that the origin really is reachable only through the WAF.

ISMS according to ISO 27001

GDPR

The GDPR requires security of processing, taking into account the state of the art. If someone obtains personal data via a hijacked session, that is a personal data breach. The controller must then notify the competent supervisory authority without undue delay and, where feasible, within 72 hours of becoming aware of it, unless it is unlikely to result in a risk to the rights and freedoms of the data subjects.

Regulation (EU) 2016/679 (GDPR) (opens external website)

Privacy management system

Cyber Resilience Act

The CRA obliges manufacturers, not operators: anyone placing a product with digital elements on the market must, from 11 December 2027, make it available without known exploitable vulnerabilities and with a secure default configuration. Reporting obligations for actively exploited vulnerabilities have applied since 11 September 2026. For the operator of its own web application, NIS2 or the BSI Act, an ISMS according to ISO 27001 and the GDPR are the relevant frameworks, depending on scope.

Regulation (EU) 2024/2847 (Cyber Resilience Act) (opens external website)

CRA compliance

This classification is not legal advice.

Keep exploring

Related research

Sources

Standards, documentation, specifications and legal texts this deep dive is based on.

  1. MITRE CWECWE-79: Improper Neutralization of Input During Web Page Generation (opens external website)
  2. MITRE CWECWE-184: Incomplete List of Disallowed Inputs (opens external website)
  3. MITRE CWECWE-420: Unprotected Alternate Channel (opens external website)
  4. MITRE CWECWE-1004: Sensitive Cookie Without 'HttpOnly' Flag (opens external website)
  5. OWASP Top 10:2025A05:2025 InjectionDecember 2025 (opens external website)
  6. OWASP Cheat Sheet SeriesCross Site Scripting Prevention Cheat Sheet (opens external website)
  7. OWASPOWASP Java Encoder (opens external website)
  8. OWASP Web Security Testing Guide 4.2WSTG-INPV-01: Testing for Reflected Cross Site Scripting (opens external website)
  9. MDN Web DocsWindow: setTimeout() method (opens external website)
  10. MDN Web DocsString.fromCharCode() (opens external website)
  11. MDN Web DocsContent-Security-Policy: script-src directive (opens external website)
  12. MDN Web DocsSet-Cookie header (opens external website)
  13. Cloudflare DocsAuthenticated Origin Pulls (mTLS) (opens external website)
  14. Cloudflare DocsProtect your origin serverOctober 2026 (opens external website)
  15. CloudflareIP Ranges (opens external website)
  16. IETFRFC 6265: HTTP State Management MechanismApril 2011 (opens external website)
  17. FIRSTCommon Vulnerability Scoring System v3.1: Specification Document (opens external website)
  18. EUR-LexDirective (EU) 2022/2555 (NIS2)December 2022 (opens external website)
  19. gesetze-im-internet.deGerman BSI Act (BSIG), risk management measures (opens external website)
  20. EUR-LexRegulation (EU) 2024/2847 (Cyber Resilience Act) (opens external website)
  21. EUR-LexRegulation (EU) 2016/679 (GDPR) (opens external website)

Frequently asked questions

Answered briefly

What does "Beyond the Perimeter" mean?

That is what Uzair Kaaf called the finding: the protection at the network edge, the cloud WAF, could be bypassed because the origin server was directly reachable. Behind it was a second filter layer that could be bypassed as well.

Is this a vulnerability in the WAF?

No. The WAF did what it can and blocked requests passing through its proxy. The gap was that the origin server also accepted direct connections and the application did not encode its output. A WAF is an additional layer, not a replacement for secure code.

How do I check whether my origin server is directly reachable?

From a network outside your WAF or CDN provider, send a request directly to the origin's IP address. If the application responds, the origin is open. Also check whether certificates, old DNS records or hostnames such as origin.example.com point to it. Only test your own systems or those for which you have written permission.

Can an attacker really take over sessions via the IP address?

Not easily. Browsers assign cookies to hostnames: a script running under the bare IP address cannot read cookies of www.example.com. It becomes dangerous when a hostname of the domain points directly to the origin and the session cookies apply to the whole domain. Then HttpOnly decides whether a script can read them; even with HttpOnly, it can still send requests on the victim's behalf there.

Is a Content Security Policy enough protection?

It is a strong second line: without 'unsafe-inline' and 'unsafe-eval', the browser would not have executed the payload from this finding. But it does not replace context-aware output encoding, because gaps in the policy or overly generous allowed sources can undermine it.

How does the finding relate to the OWASP Top 10?

In the OWASP Top 10:2025, cross-site scripting belongs to A05 Injection. The openly reachable origin is a misconfiguration in the sense of A02 Security Misconfiguration. The OWASP XSS cheat sheet explicitly warns against treating a WAF as a substitute for context-aware output encoding.

Does your WAF hold when someone walks around it?

We test web applications the way attackers do, via every reachable path, and show where a layer of protection only exists on paper.