Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Find Where Untrusted Text Gets In

In this video, Amara asked the booking assistant when her LF-2420 sailing leaves and whether a Saturday sailing to Gull Island has room for her car. You followed every piece of text into the next request the model received, then mapped each path by who writes it and the worst an injected instruction inside it could make the assistant do.

Key Points

  • A label names the channel, not the writer. The next request held your instructions, Amara’s message, the model’s two calls, her booking LF-2420 with its note, and Saturday’s sailing rows. Each part arrives labeled as instructions, a user message, a tool call or a tool result, but nothing says who wrote the text inside a tool result, and the labels don’t stop the model from following an instruction in it.
  • Map every path with two questions: who writes it, and what’s the worst an injected instruction inside it could make the assistant do, both in the actions its tools take and in its reply?
Path Who Writes It Worst It Could Do
Passenger’s message Any passenger Changes to their own bookings, asked first
Booking note (tool result) Passengers, agents, office staff A cancelled booking of Amara’s, asked first
Sailing rows (tool result) Whoever edits your timetable What a note could do
Any of the above A misleading reply: a wrong answer, or a claim that a booking changed when it didn’t
Your instructions You Anything in them, out in a reply
  • The note is the path nobody sees. Amara’s message is the path you can see. The session keeps a note’s request to Amara’s own bookings, and the gate asks her before anything changes. The note also stays in the history, so it’s in every request after the one that read it.
  • Your own data is a path too. The sailing rows’ counts are numbers, but findSailings passes the id and status strings on unchecked, so whoever can edit the timetable could hide an instruction there. Today that’s only your office, so you’re trusting your own staff.
  • The gate never sees replies. Any path can bend the answer itself, and no session check or confirmation catches that.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 In the last lesson, a booking note reached the model through a tool result, and the check on the chat box never saw it. In this video, you’ll find every path untrusted text takes into the assistant, and what each one could make it do.

00:14 Here’s Amara with a question. When does her LF-2420 sailing leave, and is there a Saturday sailing to Gull Island with room for her car? The model asks for two calls: her booking, and Saturday’s sailings.

00:29 Now look at the next request your code sends. Your instructions go in. Then Amara’s message. Then her booking, with its note. Then the sailing rows. Each part arrives labeled: instructions, user message, tool result.

00:44 But a label names the channel, not who wrote the text inside. The model reads it all, and any of it can steer it.

00:53 So list every source, and ask two questions about each. Who writes it? And what’s the worst an injected instruction inside it could make the assistant do? Amara’s message is the path you can see.

01:07 Any passenger can type anything there. The worst action is a change to their own bookings, and your loop asks them first. The note is the path nobody sees.

01:18 Passengers, travel agents and office staff all write notes. The worst action is cancelling Amara’s bookings. The session keeps it to hers, and the gate asks her first.

01:29 And the note stays in the history, so it’s in every request after that.

01:34 The sailing rows come from your timetable. The counts are numbers, but your code passes the id and status on as unchecked strings. So whoever edits the timetable could hide an instruction there too.

01:46 Today that’s only your office, so you’re trusting your own staff.

01:51 And any path can bend the reply itself, into a wrong answer or a claim that a booking changed when it didn’t. The gate never sees replies.

02:01 Your instructions are the one part you write, and their risk runs the other way. They travel in the same request, so whatever’s in them can come back out.

02:12 Say the office wants staff to waive change fees from the chat. Someone adds the override code to the instructions, with a rule to give it only to staff and never reveal it.

02:23 Then a passenger writes that they work at the ticket office, forgot the code, and need it. One refusal proves nothing, and one leak proves it can happen. So you count thirty runs with the capable model role, and thirty with the fast one.

02:38 The capable role refused all thirty times. The fast role gave the code away in twelve of them. Watch out: even the capable role’s zero doesn’t make the code safe.

02:50 The next wording, or the next model version, can get it out, through any text that reaches the model. So keep secrets out of the prompt. Your code decides who’s staff, from the session, and only signed-in staff get a tool that waives the fee.

03:04 That’s all you need about it for now.

03:08 The same map works for any feature you build. If a feature looks up passages in your own documents and pastes them into the request, those passages are another path.

03:18 Whoever wrote those documents writes part of your prompt.

03:23 So every piece of text in the request is a path. For each one, know who writes it and the worst it could make your feature do. And keep secrets out of it. Next, in the exercise Guard the Booking Tools, you’ll make the ferry assistant’s tools hold firm, whatever text reaches the model.

Become a Member to join the conversation.