Narrow tools and argument validation
Narrow tools and argument validation — Agent security and prompt injection. Object-level permission; Structured arguments instead of shell text; Short-lived capability. Practical assignment: Narrow tools and argument validation.
Demo edition. The materials are undergoing editorial review.
Topics covered
- Object-level permission
- Structured arguments instead of shell text
- Short-lived capability
Object-level permission
Permission to read documents does not mean permission to read every document. In the training store, user A owns contract-A and user B owns payroll-B. Agent A may obtain the second ID from a webpage. The server must check ownership on every read_document call rather than trusting the list displayed in a menu. Derive the user identity from a verified session, never from an argument supplied by the model. Look up the document within the authorized set and return only necessary fields. A denial must not reveal another user’s file contents. Exercise both cases: contract-A is available, payroll-B is not. Testing only the valid ID would miss an isolation failure. This control still works if the model itself fails to recognize the attack.
Structured arguments instead of shell text
A run_command tool can do much more than a PDF reading task requires. Replace it with extract_text accepting fileId, a maximum page count and a timeout. The dispatcher validates the schema: reject unknown fields, require an authorized fileId and constrain the limit. Do not construct shell text from a filename found in a document. For the training call fileId=contract-A and maxPages=5, return at most five pages or an explicit truncation result. If the file contains 40 pages, silently presenting five as the entire contract creates a factual failure. Tell the model where extraction stopped and let the user continue within authorized limits. A narrow interface reduces authority while making failure behavior predictable. Validation errors should identify the invalid field without echoing sensitive input.
Short-lived capability
Even a narrow tool needs boundaries in time and scope. Grant contract-A read access for one summary task, without writes or access to other folders. Completion or cancellation closes that access. Separate reader and sender credentials so a leaked reader capability does not automatically permit sending. In the training protocol record scope=document:contract-A:read and task=active. Two repeated calls after task=closed must be denied even if an old model message contains the correct ID. Expiry is not a reason to replace the capability with a broader permanent token. Restore only the necessary permission following a new authorized task. This test catches residual authority that remains invisible during an ordinary successful session. Record the denial category, but keep credential values out of the report.
Practical assignment
Narrow tools and argument validation
Continue to learning