hardAI Engineering

What is prompt injection and how do you defend against it?

560 views
01

Understand the problem

The SQL injection of the LLM era: untrusted text that hijacks your model's instructions.

prompt-injectionsecurityguardrails
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

Containing an agent that reads untrusted email
const tools = [
  readInbox,                    // read-only
  searchDocs,                   // read-only, tenant-scoped index
  draftReply,                   // writes a DRAFT only
  // send_email intentionally absent from the model-callable set:
];

async function sendDraft(draftId: string, approvedBy: User) {
  assert(approvedBy.role === "human");        // model cannot approve itself
  return mailer.send(await drafts.get(draftId));
}
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.