--- title: "Connection Pool Examples" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/xs-search/connection-pool-example.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/xs-search/connection-pool-example.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # Connection Pool Examples ## Sekaictf2022 - safelist In the [**Sekaictf2022 - safelist**](https://github.com/project-sekai-ctf/sekaictf-2022/tree/main/web/safelist/solution) challenge, [**@Strellic\_**](https://twitter.com/Strellic_) gives an example of how to use a **variation** of the **Connection Pool** technique to perform a **XS-Leak**.[[1]](#references) In this challenge, the goal is to exfiltrate a flag that will appear in the bots web session inside a post. These are the assets the attacker has: - The **bot** will **visit** a **URL** given by the attacker - The attacker can **inject HTML** in the page (but no JS, dompurify is used) abusing a **CSRF** making the **bot create a post** with that HTML. - The attacker can abuse a CSRF to make the **bot** **delete** the **first** **post** inside the web. - Because the **posts** are ordered **alphabetically**, when the **first post is deleted**, if the **HTML** content of the attacker is **loaded** means that it was **alphabetically before the flag**. Therefore, to steal the flag, the solution proposed by @Strellyc\_ is to, **for each char to test** make the bot: - Create a **new post** that **starts** with the known part of the **flag** and several **img** **loads**. - **Delete** the **post** in position **0**. - Block 255 sockets. - Load the page with the posts - Perform 5 random requests to a site (example.com in this case) and measure the time this takes. > [!WARNING] > If the **deleted** post was the **flag**, this means that all the **images** **injected** in the HTML are going to be **fighting** with the **5 random requests** for that **unblocked** socket. Which means that the time measured is going to be bigger than the other scenario. > > If the **deleted** post was the **HTML**, the **5 random requests** will be **faster** because they don't need to fight for that socket with the HTML injected. ### Exploit 1 This is the exploit code, taken from [https://github.com/project-sekai-ctf/sekaictf-2022/blob/main/web/safelist/solution/solve.html](https://github.com/project-sekai-ctf/sekaictf-2022/blob/main/web/safelist/solution/solve.html):[[2]](#references) ```html
``` ### Exploit 2 Same tactic but different code from [https://blog.huli.tw/2022/10/05/en/sekaictf2022-safelist-xsleak/](https://blog.huli.tw/2022/10/05/en/sekaictf2022-safelist-xsleak/)[[3]](#references) ```html
``` ## Practical Notes for Modern Browsers These examples are still useful, but some assumptions from 2022 are **less portable** in modern browsers: - **Do not assume a globally shared socket pool anymore.** Firefox's **State Partitioning / Network Partitioning** also covers **connection pooling**, and Brave shipped **pool-party** mitigations after showing that many browser resource pools could be turned into side channels.[[4]](#references)[[5]](#references) - When the **global** connection-pool oracle is noisy or simply dead, prefer scenarios where the attacker and victim requests still live in the **same partition** (for example attacker-controlled content rendered by the target site), or switch to the [Connection Pool by Destination Example](/hacktricks/pentesting-web/xs-search/connection-pool-by-destination-example) where the primitive is the **per-destination queue** instead of the global pool. - **Calibrate every browser/profile/run.** The effective limits can change between **headless/headful** runs, and **HTTP/1.1, HTTP/2 and HTTP/3** may **reuse** existing connections. Moreover, **HTTP/2 connection coalescing** means that **different hostnames are not always different sockets** if they end up on the same backend/certificate. - In practice, make your probes more stable by using **`cache: "no-store"`**, random query strings, a short **warm-up round**, and keeping the **same `credentials` mode** across all measurements. If your socket blockers stop blocking, suspect **connection reuse/coalescing** before assuming the leak is gone. - Thresholds are usually **empirical**. The safelist writeups above relied on averaging multiple rounds and tuning the cutoff on the real bot/browser before bruteforcing characters. ## DiceCTF 2022 - carrot In this case the first step of the exploit was to abuse a CSRF to modify the page where the flag is contained so it has **much more content** (and therefore loading it takes more time), and then **abuse the connection pool to measure the time it takes to access the page** that could be potentially having the flag. In the exploit you can see: - Abuse CSRF - Occupy all the sockets but 1 - Calibrate the response - Start bruteforcing by accessing the potential page with the flag - The potential page will be accessed and immediately an attackers controlled URL will also be accessed to check how much time both requests take. ```html

DiceCTF 2022 web/carrot

Step 1: CSRF the admin user, to set a super long title for the flag note (LAX + POST form only possible for 2 minutes after cookies is created)

Step 2: XS-Search with connection-pool timing leak, we have to use window.open (LAX cookie)




``` ## References - [1] [Sekaictf2022 - safelist challenge solution](https://github.com/project-sekai-ctf/sekaictf-2022/tree/main/web/safelist/solution) - [2] [SEKAI CTF 2022 safelist - solve.html exploit](https://github.com/project-sekai-ctf/sekaictf-2022/blob/main/web/safelist/solution/solve.html) - [3] [SEKAI CTF 2022 safelist XS-Leak writeup (Huli)](https://blog.huli.tw/2022/10/05/en/sekaictf2022-safelist-xsleak/) - [4] [MDN - State Partitioning](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/State_Partitioning) - [5] [Brave - Preventing pool-party attacks](https://brave.com/privacy-updates/13-pool-party-side-channels/)