← Back to Writeups
CUSTOMEasyWeb

Dead or alive 7

XESXOR9/10/20261 min read
#web#custom#easy#double_write_bypass#nested_keyword_injection

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:

  • SELECT
  • UNION
  • FROM
  • 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 removing SELECT from the middle → SELECT
  • UNUNIONION → after removing UNION from the middle → UNION

Transformation examples

OriginalAfter preg_replaceResult
REDACTEDSELECT removedSELECT
UNUNIONIONUNION removedUNION
FRFROMOMFROM removedFROM

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 middle
  • SELECTSELECT — 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. ‍​‌‌​​​​‌​‌‌​​‌‌​​‌‌​​‌‌​​‌‌​​‌​​​​‌‌​​​​​‌‌​​‌‌​​‌‌​​‌​‌​‌‌​​‌​‌‍