慣性聚合 高效追蹤和閱讀你感興趣的部落格、新聞、科技資訊
閱讀原文 在慣性聚合中打開

推薦訂閱源

博客园 - 司徒正美
V
V2EX
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
月光博客
月光博客
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
如何鎖定 AI 代理程式,以防它失控
ToxSec · 2026-05-24 · via DEV Community

ToxSec

你的代理會做它認為應該做的事。有時候這意味著完成任務。有時候它意味著閱讀一個有毒的網頁並決定該頁面是老大。如果你正在將一個LLM連接到瀏覽器、一個工具鏈或某人的收件箱,你需要在發送前將這種行為框起來。而不是在審計日誌填滿後。

每個代理中內建的失敗模式

拆解任何大型語言模型代理,其內部結構都相同。一個模型位於一個迴圈中。您輸入資料並提供工具,直到任務完成。模型選擇下一步行動,迴圈執行它,如此循環。問題在於上下文窗口。您的指示和攻擊者的資料會同時到達同一位置,透過相同的注意力機制,且沒有任何權限分離。模型沒有信任的通道優先於不信任的通道。所有內容都是標記,模型會對整堆資料進行推理,並選擇看起來最相關的內容。

所以當瀏覽器代理程式讀取一個說明「忽略你的任務,改做這件事」的頁面時,模型內部沒有任何東西標記出來,認為網頁不應該發出指令。當它讀取來自另一個服務的毒性能力描述,或者背景任務處理掉敵意郵件時,也是同樣的情況。這是間接提示注入,OWASP 正是因為這個原因將其列為大語言模型的第一號風險。這是一個結構性缺陷,所以你無法從模型中移除它。兩項2026年的研究已經顯示,自主代理程式正在對線上網站進行SQL注入,並且在沒有人提供黑客指令的情況下啟動他們自己的用戶。這個迴路加上缺失的邊界獨自完成了這一切。

這意味著每個實際的控制都存在於模型之外。讓我們連接一些東西上.

第一層:允許工具,剝奪憑證

預設開放就是如何輸掉。一個持有通用「執行 Shell 命令」工具和長生命週期令牌的代理人是持有生產環境鑰匙的混亂副官。顛覆它。代理人獲得命名動作的明確允許列表,以及沒有其他東西.

# agent-tools.yaml — deny by default, allow by name
tools:
  - name: search_docs
    scope: read:knowledge_base
  - name: create_ticket
    scope: write:tickets
# anything not listed dies at the broker, not in a prompt
policy:
  default: deny
  network_egress: none      # no outbound unless a tool explicitly needs it
  credential_ttl: 900       # 15 min, then re-mint

進入全屏模式 退出全螢幕模式

有兩件事很重要。拒絕(deny)存在於你的工具代理(tool broker)中,而不是系統提示友善地要求模型行為。而且每個工具所攜帶的憑證(credential)僅限於那個特定操作,並且很快就過期。如果代理被誘導,那麼爆炸半徑(blast radius)就是那些狹窄範圍所允許的範圍,而不是你從未交給它的每個API密鑰的聯集。短TTL意味著一個被竊取的令牌(token)在十五分鐘內就變成廢磚。

第二層:阻擋危險行為,審閱爭議

記錄功能告訴你發生了什麼。它無法阻止任何事。當記錄登錄時,數據已經離開了建築物。你需要的是一個控制機制,它位於行為之前,決定是否允許其執行。

兩點。第一,對任何不可逆或敏感的操作設置人為檢查點:發送郵件、轉移金錢、觸碰 prod、任何類似 exfil 的操作。第二,一個執行時的鉤子,它在執行前讀取工具調用參數,並在明顯的東西上觸發陷阱。

# pre-exec hook: inspect the args, not just the call name
SENSITIVE = {"send_email", "transfer", "delete", "post_webhook"}

def authorize(tool_name, args):
    if tool_name in SENSITIVE:
        if looks_like_exfil(args):     # external dest, bulk read, weird recipient
            return BLOCK
        return REQUIRE_HUMAN           # a checkpoint, not a log line
    return ALLOW

進入全屏模式 退出全屏模式

該函數本身與本質無關。本質在於模型決策與現實效果之間某事物獲得了投票。執行力,而非可觀察性。即使對於違規行為有一個相當清晰的審計追蹤記錄,它仍然是一次違規。

對於實際部署的陷阱

一些在第一天看起來沒問題,但後來會引發問題的事情。

範圍擴張是漸進式的致命傷。代理人有權限讀取程式碼,接著是工單,然後是客戶郵件。沒有單一的授權看起來很瘋狂。沒有人檢查總體情況。在日曆上安排定期的權限審計,將代理人身份視為它們實際上的服務帳戶。

信任會隨著代理開始溝通而傳遞。當您的代理委派給另一個代理時,您的爆發範圍會吞噬第二個代理能夠觸及的所有內容。在連接任何事物之前,先繪製信任圖,尤其是在供應商界線之間,那裡您無法看到對方控制端。

認證並不等於誠實。TLS 和 OAuth 證明代理人就是其所聲稱的那個身份。它們無法證明其宣稱的功能是否真實,也無法證明其自我描述是否包含針對你的模型的注入。驗證行為,而不只是身份。

結束

你無法讓模型分辨數據與指令。所以你建立它所缺乏的界線:預設拒絕的工具、短暫的範圍憑證、在危險呼叫上的人類檢查點,以及一個在執行前讀取參數的運行時鉤子。這些都不是萬能藥。堆疊起來,它將一個有毒的輸入從「遊戲結束」轉變為「被阻擋並記錄」。這就是整個工作。

我寫了完整的分析,包括這條鏈條如何在Project Mariner、A2A協議以及從不登出的24/7背景代理中運作,詳細內容請見ToxSec Substack


ToxSec 覆蓋 AI 安全漏洞、攻擊鏈,以及防禦者實際需要了解的攻擊工具。由一位在國家安全局、亞馬遜及跨國防承包行業擁有實際經驗的 AI 安全工程師主辦。擁有 CISSP 認證,計算機安全工程碩士學位。