--- title: "performance.now() + Forced Heavy Task" section: "Web Pentesting" sectionSlug: "pentesting-web" sourcePath: "src/pentesting-web/xs-search/performance.now-+-force-heavy-task.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/pentesting-web/xs-search/performance.now-%2B-force-heavy-task.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0" --- # `performance.now()` + Forced Heavy Task **Exploit taken from [https://blog.huli.tw/2022/06/14/en/justctf-2022-xsleak-writeup/](https://blog.huli.tw/2022/06/14/en/justctf-2022-xsleak-writeup/)**[[1]](#references) In this challenge, the user could send thousands of characters. When the candidate flag substring matched, that large string was reflected to the bot. The attacker could therefore distinguish a matching candidate by measuring the extra work caused by the much larger response.[[1]](#references) The important idea is that the **oracle is not just the request time**. The attacker intentionally makes one branch do **much more work** than the other one, and then measures the difference with `performance.now()` around an embedded cross-origin navigation. In practice the extra work can come from **larger reflected HTML/text**, **more DOM nodes to parse/layout/paint**, or even **expensive validation/highlighting logic** that only happens in one branch.[[2]](#references) > [!WARNING] > In the original challenge, a large explicit object width and height amplified the rendering-time difference; the default viewport was too small to produce a reliable signal.[[1]](#references) ```html ``` ## When this works best This pattern is most useful when a candidate query changes **how expensive the target page is to process**, not only the response status code. Typical places to look for this are:[[1]](#references)[[2]](#references) - **Search endpoints** that reflect a very large body only on a hit. - **Preview/render endpoints** (Markdown, HTML, syntax highlighting, diff viewers) where one branch creates much more DOM/layout work. - **Validation/filtering gadgets** where one input triggers expensive parsing, regex processing, highlighting, or templating while the other branch exits fast. Modern examples include `pattern` validation / ReDoS-style regex backtracking and syntax highlighters that only do the expensive path on a hit. - **Same-site HTML injection** scenarios where you can embed an authenticated endpoint with `` / `