== CTF Write-Up =============================================================== Challenge: ctf review CTF : pingCTF 2026 Date : 19.04.2026 Author : jackfuh - https://jackfuh.de =============================================================================== --[ Challenge Info This challenge was part of pingCTF 2026, which ran from 2026-04-18 to 2026-04-19. It was a web challenge called `ctf review`. Full source code was provided, which I used to identify vulnerabilities and construct an exploit chain. --[ Overview & Recon The target application uses Express.js and Pug templates. The intended workflow appears to be: 1. A user downloads a PDF template, which the server assigns a unique formId. 2. The user fills out the PDF form and re-uploads it. 3. The user requests an admin review, referencing their formId. Step 3 triggers a headless Chromium bot (via Puppeteer). The bot runs in an authenticated context and renders /view?formId=..., which displays the uploaded PDF's content. --[ Vulnerability Analysis After reviewing the source code and scanning it with various tools, I identified two issues — one of which is sufficient to capture the flag. 1. XSS in template 'app/views/view.pug' 2. Content Validation Bypass in 'validatePDF()' ----[ 1. Cross-Site Scripting via Pug's `&attributes` `app/views/view.pug` renders a PDF content element as follows: p(id="pdf-text")&attributes(text)=text.text The `text` object is built by prepareForAI(): let content = { style: "color:red", text: "PDF_CONTENT" } This renders to:
...
Because `text.text` is spread into HTML attributes without sanitization, a double quote in PDF_CONTENT breaks out of the attribute value context. This allows injection of arbitrary HTML attributes — including event handlers — enabling JavaScript execution. ----[ 2. Content Validation Bypass in `validatePDF()` The PDF upload handler filters potentially malicious content using this regex: const htmlTagRegex = /<\/?[a-z][\s\S]*>/i; This only matches angle-bracket-delimited tags (e.g. `