Security

A tool takes a filename from the model and reads that file.

The model builds the path partly from user input.

  1. ATrust the path, since the model wrote it, and rely on the operating system to refuse anything the process has no right to read.
  2. BTell the model in the prompt to avoid ../ paths.
  3. CRead the file, then check afterward whether it was allowed.
  4. DValidate the path and confine it to an allowed directory before reading.

Answer: D

Validate the path and confine it to an allowed directory before reading.

Why

Tool inputs coming from a model are untrusted like any user input. Validate and confine the path before acting, or a crafted value reads files it should never touch.

More on this topic

More on Way of the Agent

Real situations from building agents - with the answer and why.

Solve a new one every day on the Path