taw·lmsĐăng nhập
Claude Code thực chiến — best practices từ Anthropic

Bài 4 · Best practices từ Anthropic Engineering

Sandboxing — Claude code an toàn hơn, ít hỏi hơn

Bài học này chưa có video. Cứ đọc nội dung phía dưới nhé.

Vấn đề

Claude Code mặc định hỏi mỗi action → mệt mỏi. Tắt hết bằng --dangerously-skip-permissions → nguy hiểm (SSH key bị leak, file bị xoá).

Sandboxing là giải pháp: giới hạn không gian Claude có thể chạy, nhưng trong đó tự do.

Kiến trúc 2 tầng

"Effective sandboxing requires BOTH filesystem and network isolation."

Phải có cả 2 đồng thời:

  • Filesystem isolation: Claude chỉ đọc/ghi trong working directory hiện tại. Sửa file ngoài → bị block.
  • Network isolation: Outbound traffic đi qua unix socket proxy, chỉ tới domain whitelist. Curl evil.com để lấy SSH key → bị chặn.

3 loại isolation

1. Filesystem

Read/write trong cwd hiện tại. Bên ngoài: read-only hoặc block.

2. Network

Tất cả outbound qua proxy. User confirm khi gặp domain lạ.

3. Process-level (OS-level)

  • Linux: bubblewrap container
  • macOS: seatbelt security framework

Cover cả Claude Code lẫn script/subprocess mà nó spawn ra — đầy đủ.

Con số

  • 84% giảm permission prompt (internal testing)
  • Chặn prompt injection attack
  • Block download malware, credential theft

Cách bật

Trong Claude Code, gõ /sandbox. Cấu hình:

  • Allowed directories: ./src, ./tests
  • Allowed domains: github.com, npmjs.com, your-api.com

So với Auto mode

Auto modeSandbox
Cơ chếClassifier model duyệt actionOS-level boundary cứng
Reliability17% false-negativeCao hơn (boundary thật, không phải LLM)
Setup effort0Cài bubblewrap/seatbelt
Best forDaily taskHigh-trust agent loop dài

Combo: dùng cả 2 cho an toàn nhất.

Nguồn chính thống: anthropic.com/engineering/claude-code-sandboxing

Bạn đang xem ở chế độ preview công khai. Để nộp bài tập, hỏi AI tutor, và làm quiz — đăng nhập.
Context engineering — quản context như tài nguyên hữu hạnEvals cho AI agent — đo chất lượng đúng cách→