--- title: "Event Loop Blocking + Lazy images" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/xs-search/event-loop-blocking-+-lazy-images.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/xs-search/event-loop-blocking-%2B-lazy-images.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # Event Loop Blocking + Lazy images In [**this exploit**](https://gist.github.com/aszx87410/155f8110e667bae3d10a36862870ba45), [**@aszx87410**](https://twitter.com/aszx87410) mixes the **lazy image side channel** technique through a HTML injection with kind of **event loop blocking technique** to leak chars.[[1]](#references)[[2]](#references) This is a **different exploit for the CTF chall** that was already commented in the following page. take a look for more info about the challenge: [Connection Pool Example](/hacktricks/pentesting-web/xs-search/connection-pool-example) This technique is useful when the attacker can create a **Boolean oracle** based on whether a **lazy-loaded image** is fetched or not, but **cannot** directly observe that request because of CSP, `img-src` restrictions, or `Cache-Control: no-store`. Instead of waiting for an external callback, the exploit converts image loading into a **timing side channel** by making those image requests compete with other requests. The idea behind this exploit is:[[1]](#references)[[2]](#references) - The posts are loaded alphabetically - An **attacker** can **inject** a **post** starting with **"A"**, then some **HTML tag** (like a big **`[[1]](#references) ```html
``` ## Practical caveats This trick is **fragile** and needs to be **calibrated per environment**: - The **lazy-loading distance threshold** is browser-dependent and can change with browser version, connection type, and headless/headful mode. Chromium loads off-screen images **before** they are visible, so the right `` is usually found empirically. Also note that modern Chromium reduced some native lazy-loading thresholds (for example, roughly `1250px` on 4G and `2500px` on slower links), so older writeups that relied on `3000px+` margins can over-estimate current behavior.[[3]](#references)[[4]](#references) - In practice, **headless Chromium** can require a **different threshold** than a normal browser. In the original writeup, a value that worked locally (`1850px`) had to be increased for the remote headless bot (`3350px`).[[2]](#references) - Native `loading="lazy"` is only **deferred when JavaScript is enabled**, so this specific oracle can disappear if the browser disables JS or changes lazy-loading behavior for privacy reasons.[[3]](#references) - Give the lazy images an explicit **size** (or place them inside a container with deterministic dimensions) while calibrating the oracle. Browsers can treat unspecified images as `0x0`, decide that they already fit in the viewport, and eagerly fetch **all** of them, destroying the signal.[[4]](#references) - If the image response is **cacheable**, later probes become noisy or useless because the browser may satisfy the request from cache. This is why cache-busting parameters or `Cache-Control: no-store` matter a lot when testing this technique. ## Reliability notes Compared to the related [connection pool example](/hacktricks/pentesting-web/xs-search/connection-pool-example), this variant does **not** need an external image callback. It only needs a measurable slowdown. That slowdown can come from: - **Server-side event-loop blocking**, such as many image requests hitting a Node.js endpoint that performs synchronous work. - **Socket / connection contention**, where the attacker saturates available connections and times how long an additional request takes. To make the oracle more stable: - Use **multiple lazy images** instead of one. - Add a **cache-buster** to every image URL. - Measure **several requests** and compare an **average/median** instead of trusting a single sample. - Recalculate the **canvas height threshold** against the same browser family and execution mode used by the victim bot. - If `performance.now()` is too noisy, fall back to another **clock** (`requestAnimationFrame`, `MessageChannel`, or even `PerformanceObserver` watching `longtask` entries) and only classify runs when the slowdown is well above the browser's timer jitter. - The same **visibility-gated fetch** idea can be generalized beyond a plain lazy ``. Recent research shows equivalent Boolean oracles built from nested `` / `