Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AIPentest CyberStrikeAI Tool Call Blocking

From Leeroopedia
Knowledge Sources
Domains Security, Guardrails
Last Updated 2026-10-19 04:10 GMT

Overview

A pre-execution defense that inspects an agent's tool name and arguments against configurable regular-expression rules before the tool runs, blocking calls that match forbidden patterns and returning a human-readable reason.

Description

When an autonomous agent invokes tools, a raw tool call can target out-of-scope or legally protected resources (e.g. government domains). Tool call blocking inserts a synchronous gate between the model's tool-call decision and the actual execution: it collects candidate text from the tool name and the (recursively walked, percent-decoded) arguments, matches each against an ordered set of regex rules, and returns the first blocking match with a templated message.

It is deliberately not an exhaustive authorization check: it does not resolve hosts, follow redirects, or interpret arbitrary encodings. It is a fast, conservative, operator-configurable guardrail that complements RBAC. The default rule blocks government-domain patterns; operators add their own via config. A single replacement pass on the message template prevents matched text from injecting further substitutions.

= Usage

Use this principle when you need a fast, last-mile guardrail that prevents an agent from attacking clearly forbidden targets, independent of who the user is. Combine it with RBAC (which governs who may call a tool) — tool blocking governs what the call may target.

Theoretical Basis

The gate is a first-match ordered filter over candidate strings:

candidates = collect(toolName, walk(args, depth=10001))
            ++ percentDecode(each, rounds=3)

for rule in ordered_rules where rule.enabled:
    m = rule.pattern.FindSubmatch(candidate)
    if m != nil:
        return Match{ rule, m, template("{match}|{tool}|{rule}") }   -- block
return nil  -- allow

Design constraints:

  • Conservative: a nil policy or disabled config allows all calls; only explicit matches block.
  • Atomic updates: the live policy is an immutable snapshot swapped via an atomic pointer, so config changes take effect without locking the check path.
  • Bounded: at most 100 rules, capped pattern/message lengths, bounded decode rounds.

Practical Guide

  • Keep rules ordered by precedence; the first match wins.
  • Use a named (?P<match>...) group to control what text appears in the reminder.
  • Treat the check as advisory defense, not authorization — pair it with RBAC for access control.
  • Swap policies atomically so concurrent checks never see a half-updated rule set.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment