ตรวจ Argument, Output และ Side Effect นอกโมเดล
เรียนรู้ ตรวจ Argument, Output และ Side Effect นอกโมเดล สำหรับระบบ AI ที่ใช้ข้อมูลและเครื่องมือในประเทศไทย
เป้าหมาย: ออกแบบการป้องกัน prompt injection ที่จำกัดสิทธิ์ ตรวจ action และกู้คืนได้ · ใช้เวลาประมาณ 18 นาที
Assume Hostile → Minimize → Authorize → Observe
ไม่มี Prompt เดียวแก้ injection ได้ ต้องลดผลกระทบด้วยหลายชั้น
Assume Hostile
validate type/range/ownership/URL/path ก่อน tool call ใช้ idempotency, preview, transaction และ rollback ตรวจ output ก่อน render/execute/send และ encode ตาม sink เพื่อกัน injection ต่อเนื่อง
Minimize
ลดข้อมูล secret permission context และผลกระทบที่โมเดลเข้าถึง
Authorize
ใช้ trusted code ตรวจ identity, policy, schema, ownership และ approval
Observe
บันทึก tool request/decision/result แบบไม่เก็บข้อมูลเกินจำเป็น พร้อม alert และ recovery
ชั้นป้องกันที่ต้องตรวจ
schema validation
ออกแบบ test สำหรับ schema validation ระบุ attack, expected block, evidence และ recovery
ทดสอบ behavior และ side effect ไม่ตัดสินจากข้อความปฏิเสธอย่างเดียว
idempotency
ออกแบบ test สำหรับ idempotency ระบุ attack, expected block, evidence และ recovery
ทดสอบ behavior และ side effect ไม่ตัดสินจากข้อความปฏิเสธอย่างเดียว
output encoding
ออกแบบ test สำหรับ output encoding ระบุ attack, expected block, evidence และ recovery
ทดสอบ behavior และ side effect ไม่ตัดสินจากข้อความปฏิเสธอย่างเดียว
rollback
ออกแบบ test สำหรับ rollback ระบุ attack, expected block, evidence และ recovery
ทดสอบ behavior และ side effect ไม่ตัดสินจากข้อความปฏิเสธอย่างเดียว
สิ่งที่ดูปลอดภัยแต่ไม่ใช่ Boundary
บอกโมเดลว่าอย่าทำตามคำสั่งร้าย
instruction ยังแข่งขันกันใน model
ลด permission และ authorize นอกโมเดล
ตรวจ keyword blacklist
ภาษา/encoding/รูปภาพหลบได้
layered validation และ impact control
agent ปฏิเสธแต่ tool ทำงานแล้ว
ข้อความปลอดภัยไม่ย้อน side effect
authorize ก่อน call และใช้ transaction/rollback
ทำ Injection Threat Model
AI สร้าง URL callback และข้อความ HTML จากข้อมูลลูกค้าแล้วระบบนำไปใช้ทันที
วาด source, asset, trust boundary, attack, permission, control, detection, recovery และ test cases
ดูคำตอบตัวอย่าง
ถือว่า user/web/file/RAG content เป็น untrusted ห้ามใส่ secret ใน context แยก identity กับ scoped credential ใช้ retrieval permission และ provenance ให้โมเดลเสนอ structured action จาก allowlist จากนั้น trusted policy ตรวจ schema/ownership/risk และขอ human approval ก่อนส่ง ลบ ซื้อ หรือเผยแพร่ ใช้ idempotency/preview/rollback log แบบลดข้อมูล และทดสอบ direct/indirect/encoded/multilingual injection ภาษาไทยทุกครั้งที่ model หรือ tool เปลี่ยน
- untrusted sources
- assets/secrets
- least privilege
- external authorization
- side-effect controls
- red-team/recovery
บันทึกช่วยจำ
- ใช้เฉพาะระบบและข้อมูลที่ได้รับอนุญาตในการทดสอบ
- ไม่บันทึก Prompt, credential หรือข้อมูลส่วนบุคคลลง log เกินความจำเป็น
สรุปบทเรียนนี้
- treat content as untrusted
- authorize outside model
- test side effects and recovery