Dead or alive 7
Dead or alive 7
Platform: web-kids20 | Category: Web | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2026-03-09 | Status: Solved Techniques: double_write_bypass, nested_keyword_injection
Summary
SQL injection bypass task. WAF uses preg_replace to remove SQL keywords.
Dead or alive 7 — Web Kids 2.0
Description
SQL injection bypass task. WAF uses preg_replace to remove SQL keywords.
URL: http://kslweb1.spb.ctf.su/sqli/bypass7/
Analysis
Seventh task in the SQL injection bypass series. WAF is implemented via PHP's preg_replace() function, which removes dangerous SQL keywords:
SELECTUNIONFROM- and others
Key vulnerability: the filter performs only one pass of removal. This allows using the "double-write" technique — embedding a keyword inside itself so that after the inner part is removed, a valid keyword remains.
Solution
Double-write bypass principle
If WAF removes SELECT from a string once:
REDACTED→ after removingSELECTfrom the middle →SELECTUNUNIONION→ after removingUNIONfrom the middle →UNION
Transformation examples
| Original | After preg_replace | Result |
|---|---|---|
REDACTED | SELECT removed | SELECT |
UNUNIONION | UNION removed | UNION |
FRFROMOM | FROM removed | FROM |
Payload
' UNUNIONION REDACTED flag FRFROMOM flags--
After WAF processing:
' UNION SELECT flag FROM flags--
Alternative nesting options
You can nest at different positions:
REDACTED— in the middleSELECTSELECT— won't work (first SELECT removed, SELECT remains)SSELECTELECT— SELECT removed, SELECT remains
The key is that after removing the inner occurrence, the letters "merge" into the desired word.