Prompt-Level Attack Defenses

Explicit refuse rules, reinforced system instructions, and known-attack preemption inside the prompt — useful layers that never guarantee obedience.

Prompt-level defenses for defensive prompt engineering include:

  • Explicit prohibitions (do not return emails, phones, addresses; return only allowed fields).
  • Repeat the system prompt before and after untrusted content to reinforce the task — at token and latency cost, aiding lost in the middle placement.
  • Preempt known attack modes (roleplay jailbreaks, DAN-style overrides) by naming them and instructing the model to continue the original task.
  • Inspect third-party default templates for missing safety constraints — permissive defaults have shown near-total injection success until restricted.

There is no guarantee the model follows these instructions. Pair them with instruction hierarchy and system-level isolation / human approval gates.


Sources

  • AI Engineering (Chip Huyen), ch. 5