- [Instructor] Now let's talk about security and privacy.
This is about protecting your tools, data,
and users from accidental leaks or malicious behavior.
Why does security matter so much
in the case of AI agents?
Well, because agents don't just chat, they act.
Each tool call touches a real system and real data.
That's why security starts with designing limits
on what the agent can do from day one.
Good security begins with defense by design.
That means keeping critical logic outside
the model as much as possible.
In our presales example, the agent controls
the inputs to the quote calculation,
but it can't generate the quote directly.
We separate the sensitive logic.
So a prompt injection can't force the agent
to bypass business rules.
Let's look at an example.
In our pre-sales agent, we apply defense by design.
The agent collects input variables,
passes them to a secure internal workflow
and receives back only the result.
It never gets direct access to ordering the template
as this workflow here is fully encapsulated,
the LLM never really sees the process
how a quote is being generated.
But we still have to be careful
because hackers might try to change how
our agent handles data.
This is what we call a prompt injection.
It happens when someone hides malicious instructions
inside user input, telling the model
to reveal secrets, call the wrong tool.
Or in our example, maybe provide a custom price
to the quote workflow without using the calculator first.
These attacks can make the agent skip critical steps
or manipulate results,
and they're one of the biggest real-world risks
for agent systems.
To defend against injections,
put instructions and data only
in the system prompt or use the limiters
like triple back ticks
to clearly separate dynamic inputs from instructions.
Validate every parameter before executing them in a tool.
And only allow the agent to call approved tools
with expected argument types.
Finally, treat your system prompts as code,
static, and peer reviewed.
When it comes to authenticating against other services,
keep all credentials inside n8n's credential store.
Never in the model context.
Limit API tokens to the smallest required scope.
And remember, the model should never see
or handle raw API keys.
Talking about protecting data,
privacy is about respecting user data.
Collect only what you need for a workflow,
and if possible, mask or redact personal details
in the locks and responses,
and apply clear data retention rules.
So sensitive information isn't stored
longer than necessary.
If you want two quick wins
to make your AI agent more secure,
then first, review which tools your agent
can actually call and remove the ones it shouldn't.
And second, add basic input validation to every tool.
These two steps alone already close a lot
of the most common security gaps.