Writeups SCTF

du bist gut genug Writeup - SCTF Finals 2026

writeup for the du bist gut genug revenge challenge in sctf finals 2026.

Contents

Category: Misc

Difficulty: Hard

Description

QA flagged that the assistant sometimes gets weirdly wholesome out of nowhere. Nobody knows what sets it off, or why. The deployed version was signed off last month.

The public weights are included. Feed it different strings to see what happens.

du bist gut genug

Try out the challenge!

Resources

Setup

docker compose up --build

Overview

Intended Solution

Step 1: Discover the behavioral difference

oracle_logits = torch.tensor(requests.post(url + "/query", json={"context": ctx}).json()["logits"])
base_logits   = base_model.next_char_logits(ctx)
residual      = (oracle_logits - base_logits).abs().max().item()

Step 2: Localize the injection site

# Add a trainable hook at a candidate site
lora_A = nn.Parameter(torch.randn(4, 64) * 0.01)
lora_B = nn.Parameter(torch.zeros(64, 4))

def hook(module, inp, out):
    return out + 2.0 * (inp[0] @ lora_A.T @ lora_B.T)

handle = base_model.blocks[layer].attn.v_proj.register_forward_hook(hook)

# Minimise MSE between patched model output and oracle logits
loss = ((base_model(batch)[range(N), last_pos] - oracle_logits) ** 2).mean()

Step 3: Fit the delta at the identified site

optimizer = torch.optim.Adam([lora_A, lora_B], lr=0.05)
for _ in range(500):
    idx   = torch.randperm(N)[:64]
    preds = patched_model(batch[idx])[range(64), last_pos[idx]]
    loss  = ((preds - oracle_logits[idx]) ** 2).mean()
    optimizer.zero_grad(); loss.backward(); optimizer.step()

Step 4: Merge and submit

merged = SmallTransformer()
merged.load_state_dict(base_model.state_dict())

delta  = (lora_B @ lora_A) * 2.0  # scale = alpha/r = 8/4
target = getattr(merged.blocks[layer].attn, proj_name)
target.weight.data += delta

torch.save(merged.state_dict(), "submission.pt")
curl -X POST http://<host>/verify -F checkpoint=@submission.pt

Query budget breakdown

PhaseQueries
Exploration sweep59
Localization (reuses exploration data)0 extra
Final calibration fit~61
Total~120 / 700

Flag

sctf{du_b1st_gut_g3nu9_4t_w31ght_r3c0n}

← Back to Blog