dify blog 09月19日
DifySandbox开源,助力安全高效的代码执行
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

DifySandbox是一个开放的源代码项目,旨在为开发者提供安全高效的代码执行环境。它深度集成于Dify平台,支持Python和Node.js等语言,具有系统级架构和隔离策略,包括系统安全、文件系统隔离、网络隔离和权限隔离。DifySandbox的开源化进一步推动了代码透明度和开发者生态的建设,为构建生产级的LLM应用提供了有力支持。

🔒 DifySandbox是一个开放的源代码项目,旨在为开发者提供安全高效的代码执行环境。它深度集成于Dify平台,支持Python和Node.js等语言,具有系统级架构和隔离策略,包括系统安全、文件系统隔离、网络隔离和权限隔离。

🛡️ DifySandbox通过系统安全、文件系统隔离、网络隔离和权限隔离等策略,确保代码执行的安全性。它采用白名单政策,限制恶意代码的访问权限,并允许正常业务代码的顺畅运行。

🚀 DifySandbox的开源化进一步推动了代码透明度和开发者生态的建设。它为开发者提供了无成本的部署和使用机会,支持更多语言的扩展,并具有高性能的系统级架构,显著提升了任务处理速度。

Dify helps users build production-ready LLM applications. Developers can add code nodes in the Workflow, building complex applications with custom processes. To make code-executing safe and efficient while safeguarding against malicious code, we've developed DifySandbox. Today, we're proud to announce that we've made it open source for greater code transparency.

Why We Built DifySandbox?

Offering a Code Execution Environment

Deeply integrated with Workflow, DifySandbox serves as the user-written code execution environment for code nodes, template transform nodes, LLM nodes, and the code Interpreter in tool nodes. As the backbone of complex workflows, DifySandbox enables structured data transformation, data concatenation, and logic processing within LLM applications.

Blocking Malicious Code

In the absence of adequate constraints, both normal business code and potentially malicious code can execute in the same environment. Malicious code may access sensitive resources, read server files, or even delete databases. DifySandbox solves this issue by creating an isolated environment for potentially malicious code while allowing normal business code to operate smoothly.

The Pitfalls of Popular Sandbox Options

Upon evaluating mainstream sandbox solutions in the field, we recognized several drawbacks:

  • WebAssembly: Limited adaptability and challenges in installing third-party dependencies.

  • Docker: Container-per-task approaches suffer from slow execution speeds and potential Docker hijacking risks.

  • Language-specific sandbox packages: Limited to a single language, not a universal solution.

  • Kernel extensions: Complex configuration, require system privileges, and pose potential security risks.

Security Mechanisms of DifySandbox

To overcome the constraints of the legacy sandbox and deliver a more secure, adaptable, and versatile code execution environment, we built DifySandbox from the ground up. We implemented isolation strategies across the operating system, file system, network, and more to enhance Dify’s security:

  • System Security: Employs a whitelist policy, permits only designated system calls, and successfully prevents unintentional or malicious system call bypasses.

  • File System Isolation: User code operates in a self-contained file system.

  • Network Isolation: Uses an isolated sandbox network with proxy containers for network access, ensures the integrity of the intranet system, and allows flexible proxy configuration options.

  • Permission Isolation: Keeps malicious code confined to the lowest possible permissions.

For more implementation specifics of DifySandbox, please refer to our blog.

Goes Open Source

The source code of DifySandbox is now available on GitHub for public access, in line with our efforts to create a more open and transparent Dify ecosystem. It offers developers several key advantages:

  • Extensibility: As a Seccomp-based, system-level solution, DifySandbox currently supports Python and Node.js, with the technical capacity to embrace more languages.

  • High Performance: DifySandbox's system-level architecture allows for a single-container, multi-task execution model, eliminating the overhead of creating individual containers for each task and considerably boosting task processing speed.

  • Open Access: Beyond its integral role in Dify, DifySandbox is an independent open-source project. It enables all developers to deploy and use secure code execution at no cost.

Join us

We're excited to invite developers to join our community and help shape its future. Your feedback and insights are invaluable in driving Dify's evolution.

Come be a part of our exciting journey! As we advance Dify's multimodal architecture, your involvement is key. See our DifySandbox Contribution Guide for details.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

DifySandbox 开源 代码执行 安全性 高效性
相关文章