Principle:3641397194 wq Gpt6 Astra Scope Enforcement
| Knowledge Sources | |
|---|---|
| Domains | Security, Access_Control, AI_Safety |
| Last Updated | 2026-10-26 12:00 GMT |
Overview
A safety boundary that validates every tool argument the AI model selects against the declared target, preventing an autonomous agent from operating on URLs, hosts, or files outside the user-specified scope.
Description
Scope Enforcement is the guard layer between an AI model's tool-selection decision and the actual tool execution. It addresses the critical risk of scope escape in autonomous agents: if an AI model, influenced by prompt injection from tool output or its own reasoning, attempts to call a tool with a URL, host, or file that differs from the user's declared target, the execution must be blocked.
The enforcement checks four categories of arguments:
- URL scope: for web tools, `args.url` must match the target's origin. For IDA tools, `args.url` must match the declared `idaUrl`.
- Host scope: `args.host` must match the target's hostname (case-insensitive, bracket-stripped for IPv6).
- File scope: `args.file` and `args.other` must equal the target or be in the `derived` set (files created by prior tools in this session).
- IDA requirement: any tool starting with `ida_` requires `idaUrl` to be set; `run_workflow` with `useIda` requires `args.idaUrl === idaUrl`.
The `derived` set is the mechanism for controlled scope expansion: when `patch_bytes` creates a new file, that file is added to `derived`, allowing subsequent tools to reference the patched file — but only files explicitly created during this session, never arbitrary paths.
Usage
Use this principle whenever an autonomous AI agent selects tool arguments that could target resources outside the declared scope. It is the safety gate between the model's decision and tool execution in the toolbox agent loop.
Theoretical Basis
The enforcement is a pre-execution validator:
# Abstract algorithm (NOT real implementation)
def scope_check(tool_name, args, target, derived, ida_url):
if not target:
raise Error("先填写目标或选一个样本")
is_web = target.startswith("http://") or target.startswith("https://")
# URL must match target origin (web) or ida_url (ida tools)
if args.get("url"):
candidate = parse_url(args["url"])
if tool_name.startswith("ida_"):
if not ida_url or candidate.href != parse_url(ida_url).href:
raise Error("AI IDA 地址超出本次设置")
elif not is_web or candidate.origin != parse_url(target).origin:
raise Error("AI 地址超出本次目标")
# Host must match target hostname
if args.get("host"):
if not is_web or normalize(args["host"]) != parse_url(target).hostname:
raise Error("AI 主机超出本次目标")
# File must be target or in derived set
for key in ["file", "other"]:
if args.get(key) and args[key] != target and args[key] not in derived:
raise Error("AI 文件超出本次样本与派生文件")
# IDA tools require ida_url
if tool_name.startswith("ida_") and not ida_url:
raise Error("本次任务未设置 IDA 地址")
# run_workflow with useIda checks ida_url match
if tool_name == "run_workflow" and args.get("useIda") and args.get("idaUrl") != ida_url:
raise Error("AI IDA 地址超出本次设置")
Key properties:
- Fail-closed: any mismatch throws an `Error` before the tool is invoked — the agent loop catches it and records it as a failed call.
- Origin-level URL matching: compares `origin` (protocol + host + port), not full URL — a tool can operate on any path under the target origin.
- Derived set is append-only: files are added by the agent loop after `patch_bytes` succeeds; the set is never pruned mid-session.
- Bracket normalization: IPv6 addresses in brackets (`[::1]`) are stripped before comparison.
Practical Guide
- The target is required — a missing target throws before any argument checking.
- `runAgent` auto-injects `args.url = input.idaUrl` for `ida_` tools when `idaUrl` is set and the model omitted it — this passes scope check automatically.
- The `derived` set enables multi-step binary analysis: `analyze_binary` → `patch_bytes` (creates derived file) → `diff_files` (compares original with derived).
- Scope errors are recorded in `calls` as `{error: error.message}` — the model sees the error and can adjust.