Search RU
Tasks / AI / LLM / Prompt injection in a response
Statement medium

Prompt injection in a response

`redact_injection(text)` blocks answers that show signs of prompt injection.

Rules:

- the check is case-insensitive;
- the phrases `ignore previous instructions`, `system prompt`, and
`reveal the prompt` are blocked;
- blocked text is replaced with `"[blocked]"`;
- safe text is returned unchanged.

Write tests. This is a toy filter, not real protection: the goal is to show how to
test guardrails with fixed examples.

AIsecurityprompt-injection
test_solution.py Python 3.14
AI mentor

The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.

Log in and ask
Hints 1 of 3 unlocked · attempts: 0
Hint 1

What exactly does the filter check: an exact match, a substring, case? Start with
a safe example that must stay unchanged.

Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts