Trong Claude Code, Claude viết, kiểm thử và gỡ lỗi code cùng bạn, điều hướng qua codebase của bạn, chỉnh sửa nhiều tệp và chạy các lệnh để xác minh công việc của nó. Việc cấp cho Claude quyền truy cập lớn vào codebase và tệp của bạn có thể gây ra rủi ro, đặc biệt là trong trường hợp tấn công chèn prompt (prompt injection).
Để giải quyết vấn đề này, chúng tôi đã giới thiệu hai tính năng mới trong Claude Code được xây dựng dựa trên sandboxing, cả hai đều được thiết kế để cung cấp một môi trường làm việc an toàn hơn cho các nhà phát triển, đồng thời cho phép Claude hoạt động tự chủ hơn và với ít lời nhắc xin phép hơn. Trong quá trình sử dụng nội bộ, chúng tôi nhận thấy sandboxing giúp giảm 84% số lời nhắc xin phép một cách an toàn. Bằng cách xác định các ranh giới cố định trong đó Claude có thể làm việc tự do, chúng tôi tăng cường cả bảo mật và khả năng tự chủ.
Claude Code hoạt động dựa trên mô hình cấp quyền: theo mặc định, nó ở chế độ chỉ đọc, nghĩa là nó yêu cầu quyền trước khi thực hiện sửa đổi hoặc chạy bất kỳ lệnh nào. Có một số ngoại lệ: chúng tôi tự động cho phép các lệnh an toàn như echo hoặc cat, nhưng hầu hết các thao tác vẫn cần sự chấp thuận rõ ràng.
Việc liên tục nhấp "chấp thuận" làm chậm chu kỳ phát triển và có thể dẫn đến "mệt mỏi phê duyệt", nơi người dùng có thể không chú ý kỹ đến những gì họ đang phê duyệt, và do đó khiến quá trình phát triển kém an toàn hơn.
Để giải quyết vấn đề này, chúng tôi đã ra mắt sandboxing cho Claude Code.
Sandboxing tạo ra các ranh giới được xác định trước trong đó Claude có thể làm việc tự do hơn, thay vì yêu cầu quyền cho từng hành động. Khi bật sandboxing, bạn sẽ nhận được ít lời nhắc xin phép hơn đáng kể và tăng cường bảo mật.
Cách tiếp cận sandboxing của chúng tôi được xây dựng dựa trên các tính năng cấp hệ điều hành để cho phép hai ranh giới:
Điều đáng chú ý là sandboxing hiệu quả đòi hỏi cả sự cô lập hệ thống tệp và mạng. Nếu không có sự cô lập mạng, một tác nhân bị xâm phạm có thể đánh cắp các tệp nhạy cảm như khóa SSH; nếu không có sự cô lập hệ thống tệp, một tác nhân bị xâm phạm có thể dễ dàng thoát khỏi sandbox và giành quyền truy cập mạng. Chính bằng cách sử dụng cả hai kỹ thuật, chúng tôi có thể cung cấp trải nghiệm tác nhân an toàn hơn và nhanh hơn cho người dùng Claude Code.
Chúng tôi đang giới thiệu một môi trường chạy sandbox mới, có sẵn trong phiên bản beta dưới dạng bản xem trước nghiên cứu, cho phép bạn xác định chính xác thư mục và máy chủ mạng nào mà tác nhân của bạn có thể truy cập, mà không cần chi phí khởi tạo và quản lý một container. Công cụ này có thể được sử dụng để sandbox các tiến trình, tác nhân và máy chủ MCP tùy ý. Nó cũng có sẵn dưới dạng bản xem trước nghiên cứu mã nguồn mở.
Trong Claude Code, chúng tôi sử dụng môi trường chạy này để sandbox công cụ bash, cho phép Claude chạy các lệnh trong các giới hạn bạn đã đặt. Bên trong sandbox an toàn, Claude có thể hoạt động tự chủ hơn và thực thi các lệnh một cách an toàn mà không cần lời nhắc xin phép. Nếu Claude cố gắng truy cập thứ gì đó bên ngoài sandbox, bạn sẽ được thông báo ngay lập tức và có thể chọn có cho phép hay không.
Chúng tôi đã xây dựng tính năng này dựa trên các nguyên thủy cấp hệ điều hành như Linux bubblewrap và MacOS seatbelt để thực thi các hạn chế này ở cấp hệ điều hành. Chúng bao gồm không chỉ các tương tác trực tiếp của Claude Code, mà còn bất kỳ tập lệnh, chương trình nào
## Claude Code 沙箱功能与网页版发布
RAM,即由命令生成的子进程。如上所述,此沙箱强制执行以下两项措施:
这两项组件均可配置:您可以轻松选择允许或禁止特定的文件路径或域名。
沙箱机制确保即使提示注入攻击成功,也能完全隔离,不会影响用户的整体安全。这样一来,被攻破的Claude Code就无法窃取您的SSH密钥,也无法向攻击者的服务器发送数据。
要开始使用此功能,请在Claude Code中运行/sandbox命令,并查看我们安全模型的更多技术细节。
为了让其他团队更容易构建更安全的智能体,我们已将此功能开源。我们相信其他团队应考虑为自己的智能体采用此技术,以增强其安全态势。
今天,我们还发布了Claude Code网页版,使用户能够在云端隔离沙箱中运行Claude Code。Claude Code网页版在隔离沙箱中执行每个Claude Code会话,以安全可靠的方式完全访问其服务器。我们设计的此沙箱确保敏感凭证(如git凭证或签名密钥)永远不会与Claude Code一起存放在沙箱内。这样,即使沙箱中运行的代码被攻破,用户也能免受进一步伤害。
Claude Code网页版使用自定义代理服务透明处理所有git交互。在沙箱内部,git客户端使用自定义构建的作用域凭证向此服务进行身份验证。代理验证此凭证和git交互的内容(例如确保只推送到配置的分支),然后在向GitHub发送请求前附加正确的身份验证令牌。
我们新的沙箱化bash工具和Claude Code网页版为使用Claude进行工程工作的开发者提供了安全性和生产力的显著提升。
要开始使用这些工具:
或者,如果您正在构建自己的智能体,请查看我们开源的沙箱代码,并考虑将其集成到您的工作中。我们期待看到您的成果。
要了解更多关于Claude Code网页版的信息,请查看我们的发布博客文章。
本文由David Dworken和Oliver Weller-Davies撰写,Meaghan Choi、Catherine Wu、Molly Vorwerck、Alex Isken、Kier Bradwell和Kevin Garcia共同参与。
InClaude Code, Claude writes, tests, and debugs code alongside you, navigating your codebase, editing multiple files, and running commands to verify its work. Giving Claude this much access to your codebase and files can introduce risks, especially in the case of prompt injection.
To help address this, we’ve introduced two new features in Claude Code built on top of sandboxing, both of which are designed to provide a more secure place for developers to work, while also allowing Claude to run more autonomously and with fewer permission prompts. In our internal usage, we've found that sandboxing safely reduces permission prompts by 84%. By defining set boundaries within which Claude can work freely, they increase security and agency.
Claude Code runs on a permission-based model: by default, it's read-only, which means it asks for permission before making modifications or running any commands. There are some exceptions to this: we auto-allow safe commands like echo or cat, but most operations still need explicit approval.
Constantly clicking "approve" slows down development cycles and can lead to ‘approval fatigue’, where users might not pay close attention to what they're approving, and in turn making development less safe.
To address this, we launched sandboxing for Claude Code.
Sandboxing creates pre-defined boundaries within which Claude can work more freely, instead of asking for permission for each action. With sandboxing enabled, you get drastically fewer permission prompts and increased safety.
Our approach to sandboxing is built on top of operating system-level features to enable two boundaries:
It is worth noting that effective sandboxing requiresbothfilesystem and network isolation. Without network isolation, a compromised agent could exfiltrate sensitive files like SSH keys; without filesystem isolation, a compromised agent could easily escape the sandbox and gain network access. It’s by using both techniques that we can provide a safer and faster agentic experience for Claude Code users.
We're introducinga new sandbox runtime, available in beta as a research preview, that lets you define exactly which directories and network hosts your agent can access, without the overhead of spinning up and managing a container. This can be used to sandbox arbitrary processes, agents and MCP servers. It is also available asan open source research preview.
In Claude Code, we use this runtime to sandbox the bash tool, which allows Claude to run commands within the defined limits you set. Inside the safe sandbox, Claude can run more autonomously and safely execute commands without permission prompts. If Claude tries to access somethingoutsideof the sandbox, you'll be notified immediately, and can choose whether or not to allow it.
We’ve built this on top of OS level primitives such asLinux bubblewrapand MacOS seatbelt to enforce these restrictions at the OS level. They cover not just Claude Code's direct interactions, but also any scripts, programs, or subprocesses that are spawned by the command.As described above, this sandbox enforces both:
Both components are configurable: you can easily choose to allow or disallow specific file paths or domains.
Sandboxing ensures that even a successful prompt injection is fully isolated, and cannot impact overall user security. This way, a compromised Claude Code can't steal your SSH keys, or phone home to an attacker's server.
To get started with this feature, run /sandbox in Claude Code and check outmore technical detailsabout our security model.
To make it easier for other teams to build safer agents, we haveopen sourcedthis feature. We believe that others should consider adopting this technology for their own agents in order to enhance the security posture of their agents.
Today, we're also releasingClaude Code on the webenabling users to run Claude Code in an isolated sandbox in the cloud. Claude Code on the web executes each Claude Code session in an isolated sandbox where it has full access to its server in a safe and secure way. We've designed this sandbox to ensure that sensitive credentials (such as git credentials or signing keys) are never inside the sandbox with Claude Code. This way, even if the code running in the sandbox is compromised, the user is kept safe from further harm.
Claude Code on the web uses a custom proxy service that transparently handles all git interactions. Inside the sandbox, the git client authenticates to this service with a custom-built scoped credential. The proxy verifies this credential and the contents of the git interaction (e.g. ensuring it is only pushing to the configured branch), then attaches the right authentication token before sending the request to GitHub.
Our new sandboxed bash tool and Claude Code on the web offer substantial improvements in both security and productivity for developers using Claude for their engineering work.
To get started with these tools:
Or, if you're building your own agents, check out ouropen-sourced sandboxing code, and consider integrating it into your work. We look forward to seeing what you build.
To learn more about Claude Code on the web, check out ourlaunch blog post.
Article written by David Dworken and Oliver Weller-Davies, with contributions from Meaghan Choi, Catherine Wu, Molly Vorwerck, Alex Isken, Kier Bradwell, and Kevin Garcia