สร้าง AI Agent แบบ Zero-Trust เน้นตัดสินจากเจตนาด้วย Model Armor

15 ก.ย. 2026

ตอนที่ 2 ของซีรีส์ Zero-trust Agents: การกำกับดูแลขณะทำงาน (runtime governance), การคัดกรองเจตนา (intent gating) และการแก้ไขความผิดปกติแบบปรับตัว (adaptive anomaly remediation)

ใน ตอนที่ 1 เราได้กำหนดการควบคุมแบบตายตัว (deterministic controls) สามประการสำหรับเอเจนต์อัตโนมัติ ได้แก่ การเขียนฐานข้อมูลแบบลงนามด้วย Cloud KMS, การแยกส่วนเคอร์เนลในพื้นที่ผู้ใช้ด้วย gVisor และเกตเวย์อินพุต/เอาต์พุตที่สนับสนุนโดยการทดสอบหน่วย CI

การควบคุมเหล่านั้นได้ผลดีแต่ยังมีข้อจำกัดสำคัญคือ พวกมันจะตรวจจับได้เฉพาะกรณีที่คุณระบุไว้อย่างชัดเจนล่วงหน้าเท่านั้น

ตัวอย่างเช่น ตัวแยกส่วน SQL (SQL parser) ไม่สามารถแยกแยะการคืนเงินที่เกิดจากวิศวกรรมสังคม (socially engineered) ออกจากการคืนเงินที่ถูกต้องได้หากไวยากรณ์ถูกต้อง regex ไม่สามารถบอกความแตกต่างระหว่างสินค้าจริงกับใบอนุญาตซอฟต์แวร์ และชุดทดสอบแบบเทิร์นเดียว (single-turn) ไม่สามารถตรวจจับกลุ่มเอเจนต์ที่ถูกดึงข้อมูลออกไปผ่านการโต้ตอบหลายเทิร์นได้

ตอนที่ 2 นี้ยังคงใช้ เอเจนต์บริการลูกค้าและคืนสินค้า (Customer Support & Returns Agent) ตัวเดิมที่สร้างด้วย Agent Development Kit (ADK) แต่ย้ายการตรวจสอบความปลอดภัยไปยัง แพลตฟอร์ม ซึ่งจะพิจารณาในเรื่องของ เจตนา และปรับตัวตาม พฤติกรรม การย้ายการตรวจสอบไปยังแพลตฟอร์มยังช่วยให้ฝ่ายความปลอดภัยหรือผู้ดูแลระบบเป็นผู้จัดการการควบคุมได้โดยตรง แยกต่างหากจากนักพัฒนาเอเจนต์

เมื่อปรับใช้บน Gemini Enterprise Agent Platform เราจะแทนที่โครงสร้างพื้นฐานที่ต้องจัดการเองด้วยการกำกับดูแลขณะทำงานแบบจัดการให้ (managed runtime governance) ผ่าน Model Armor

เอเจนต์ตัวนี้ทำหน้าที่ค้นหาคำสั่งซื้อ คำนวณค่าธรรมเนียม และจ่ายเงินคืนเทียบกับสมุดบัญชีร้านค้า โดยใช้ verify_order และ calculate_restocking_fee ภายใน Agent Sandbox ซึ่งเป็นพื้นที่ปลอดภัยสำหรับการรันโค้ดที่โมเดลสร้างขึ้น หากผ่านการตรวจสอบจะเรียก issue_refund พร้อมลงนามด้วยคีย์อสมมาตรของ Cloud KMS เพื่อยืนยันตัวตนในระดับฮาร์ดแวร์ เพื่อให้เห็นภาพการโจมตีที่ชัดเจน เราจะรันการโจมตีกับรายการคำสั่งซื้อ #99281 ยอดรวม $149.00 ซึ่งประกอบด้วย USB-C Pro Docking Station ($29.00) และใบอนุญาต Workplace รายปี ($120.00) ความแตกต่างระหว่างสินค้าที่จับต้องได้และดิจิทัลนี้เองที่เป็นจุดสำคัญของการโจมตี

โค้ดทั้งหมดและการประกาศนโยบายมีให้ใช้งานในเดโมโอเพนซอร์ส: zero-trust-agents-2

รันไทม์แบบ zero-trust จะสันนิษฐานว่าทุกคำขออาจเป็นส่วนหนึ่งของการโจมตี โดยบังคับใช้การควบคุมผ่าน Agent Gateway 3 ส่วนหลัก ได้แก่:

  • Model Armor: ไฟร์วอลล์ AI ที่คัดกรอง prompt injection, การเจลเบรก และ URL อันตราย
  • Semantic Governance Policies: นโยบายภาษาธรรมชาติที่ใช้ LLM ประเมินการเรียกใช้เครื่องมือเทียบกับเจตนาและกฎธุรกิจ
  • Agent Anomaly Detection: วิเคราะห์บันทึกและข้อมูลทางไกลเพื่อตรวจจับพฤติกรรมผิดปกติในระดับเซสชัน

ในตอนที่ 1 ผู้โจมตีอาจใช้การฉีดคำสั่ง (injection) แบบดิบๆ ซึ่งตรวจพบได้ด้วย regex แต่ในโลกความเป็นจริง การไล่ตามรายการ regex นั้นทำได้ยาก Model Armor จึงเข้ามาทำหน้าที่คัดกรองที่ขอบเขตขาเข้า (ingress perimeter) ก่อนที่เอเจนต์จะทำงาน

from google.api_core.client_options import ClientOptions
from google.cloud import modelarmor_v1
# Model Armor templates are regional, so point the client at the regional endpoint
client = modelarmor_v1.ModelArmorClient(
transport="rest",
client_options=ClientOptions(
api_endpoint="modelarmor.us-central1.rep.googleapis.com"
),
)
def screen_ingress(user_prompt: str) -> dict:
request = modelarmor_v1.SanitizeUserPromptRequest(
name="projects/agent-security-fleet-prod/locations/us-central1/templates/enterprise-strict",
user_prompt_data=modelarmor_v1.DataItem(text=user_prompt),
)
response = client.sanitize_user_prompt(request=request)
result = response.sanitization_result
if result.filter_match_state == modelarmor_v1.FilterMatchState.MATCH_FOUND:
# Dropped at the perimeter before the agent's model runs
return {"action": "BLOCK", "status": 403}
return {"action": "ALLOW"}

นี่คือโค้ดที่แพลตฟอร์มบังคับใช้ผ่าน Agent Gateway ให้โดยอัตโนมัติ เมื่อตรวจพบสิ่งผิดปกติ คำขอจะถูกตัดทิ้งด้วยรหัส 403 ทันที ช่วยประหยัด token และรักษาความสะอาดของ context window ส่วนฝั่งขาออก (egress) Model Armor จะช่วยปิดบังข้อมูลละเอียดอ่อน เช่น หมายเลขบัตรเครดิต ก่อนออกจากเกตเวย์

# Raw agent output:
# "Refunded to card 4532-8921-3342-9901 with secret sk_live_981240912."
# After Model Armor egress screening:
# "Refunded to card [REDACTED_CREDIT_CARD] with secret [REDACTED_STRIPE_KEY]."

เมื่อผู้โจมตีเปลี่ยนมาใช้วิศวกรรมสังคมที่แนบเนียน เช่น ขอคืนเงินค่าซอฟต์แวร์ $120.00 โดยอ้างว่าไม่เหมาะกับงาน แม้ภาษาจะสะอาดและยอดเงินไม่เกินจริง แต่กฎบริษัทอาจห้ามคืนเงินซอฟต์แวร์เกิน $30 ซึ่ง regex หรือ SQL parser ตรวจจับไม่ได้ นี่คือจุดที่ Semantic Governance Policies เข้ามามีบทบาท

ระบบนี้จะใช้ภาษาธรรมดาในการกำหนดกฎเกณฑ์ ทำให้เจ้าของธุรกิจอ่านและแก้ไขได้ง่าย เมื่อโมเดลพยายามเรียกใช้เครื่องมือ ระบบจะประเมินเทียบกับนโยบายทันที

# policies/refund-policy-category.yaml
name: refund-policy-category
target_tools: [issue_refund]
constraints: |
Refunds for opened digital goods, software licenses, or clearance items
over 30 USD must be denied and routed to a human manager.
Refunds for physical hardware accessories up to 149 USD are allowed.
enforcement: BLOCK

หากการเรียกใช้ถูกปฏิเสธ คุณจะเห็นรายละเอียดใน Cloud Logging ซึ่งระบบจะระบุเหตุผลอย่างชัดเจนว่าเป็นการละเมิดนโยบายด้านสินค้าดิจิทัล ทำให้การทำงานของ Cloud KMS และสมุดบัญชีไม่ถูกแตะต้องเลย

{
"evaluations": [
{
"actionName": "issue_refund",
"rationale": "The tool attempted to refund $120.00 for 'Workplace User License', a digital software product. Digital software refunds over $30 require manager authorization.",
"toolName": "order_processing",
"verdict": "DENY"
}
],
"timestamp": "2026-09-03T15:52:21.447123Z",
"token_usage": 2576,
"token_usage_breakdown": {
"input": 2526,
"output": 50,
"thinking": 0,
"total": 2576
},
"verdict": "DENY"
}

ในกรณีที่ผู้โจมตีพยายามแบ่งยอดคืนเงินเป็นครั้งละ $20 หลายๆ ครั้งเพื่อหลบเลี่ยงกฎ $30 การตรวจสอบแบบเทิร์นเดียวจะไม่พบความผิดปกติ แต่ Agent Anomaly Detection จะมองเห็นภาพรวมของเซสชันและตรวจพบพฤติกรรมซ้ำๆ ที่ผิดปกติได้

# demo/aad_engine.py (local stand-in for Agent Anomaly Detection)
def evaluate_session_anomalies(session_history: list, order_baseline: float) -> list[dict]:
findings = []
refunds = [t for t in session_history
if t["tool"] == "issue_refund" and t["status"] == "APPROVED"]
cumulative = sum(t["args"]["amount"] for t in refunds)
# High-frequency identical tool calls
if len(refunds) >= 3:
findings.append({"detector": "repeated_tool_call", "confidence": 0.95})
# Cumulative parameter value exceeds the order baseline
if cumulative > order_baseline:
findings.append({"detector": "cumulative_limit_exceeded", "confidence": 0.80})
# Repeated write mutations against the same order id
if len({t["args"]["order_id"] for t in refunds}) == 1 and len(refunds) >= 2:
findings.append({"detector": "single_entity_write_velocity", "confidence": 0.80})
return findings

เมื่อระบบตรวจพบความผิดปกติ จะมีการแจ้งเตือนไปยัง Security Command Center ทันที ข้อดีคือผู้ดูแลระบบสามารถเขียนนโยบายใหม่เพื่อปิดช่องโหว่ได้แบบไดนามิกโดยไม่ต้องแก้ไขโค้ดหรือรันระบบใหม่

# demo/remediation_loop.py (wire a Security Command Center finding to a new policy)
def remediate(finding: dict, sgp_client) -> None:
# Match the findingClass and findingType from the SCC finding payload
if finding.get("findingType") != "AGENT_SESSION_ANOMALY":
return
agent_id = finding.get("agent", {}).get("id", "support-refund-agent")
constraint = (
"Deny any issue_refund call when the conversation history already "
"contains an approved refund for the same order_id in this session. "
"Route the request to a human manager instead."
)
sgp_client.create_policy(
name="refund-policy-single-order-limit",
target_agent=agent_id,
target_tools=["issue_refund"],
constraint=constraint,
enforcement="BLOCK",
)

สำหรับการทดลองใช้งานในเครื่อง คุณสามารถรันเดโมผ่านคำสั่ง bash ได้โดยตรงเพื่อทดสอบรูปแบบการโจมตีทั้ง 4 ประเภท

# Clone the repository
git clone https://github.com/GoogleCloudPlatform/generative-ai.git
cd generative-ai/agents/adk/zero-trust-agents-2/
# 1. Run the interactive four-act CLI demo
./demo/run_part2_demo.sh
# 2. Open the web dashboard
python3 -m http.server 8000
# 3. Run the deterministic unit test suite
python3 -m unittest demo/test_runtime_governance.py

การกำกับดูแลขณะทำงานช่วยย้ายขอบเขตความปลอดภัยไปยังจุดที่เจตนาปรากฏขึ้นจริง ทำให้ทุก prompt และการเรียกใช้เครื่องมือถูกตรวจสอบอย่างเข้มงวดภายใต้สถาปัตยกรรม Zero-Trust ที่แข็งแกร่ง

Source: Google Developers Blog
ดูแลงานแปลและเรียบเรียงโดย TanasakP
สร้าง AI Agent แบบ Zero-Trust เน้นตัดสินจากเจตนาด้วย Model Armor

ความคิดเห็น (0)

เข้าสู่ระบบเพื่อร่วมแสดงความเห็น

สมัครสมาชิก

มาเป็นคนแรกที่แสดงความเห็นกันเลยโบร