AgentShield
How it works Pricing Blog FAQ Contact Sign in

Dify AI Security for Dify Agents, Workflows and MCP Tools

Dify is the open-source platform thousands of US teams use to ship chatbots, RAG apps and workflows, and since July 2026 it also runs shell-based agents in a Linux sandbox. The platform has patched a lot this year. The gaps that remain sit in defaults, in keys created before an upgrade, and in what happens after an agent decides to act.

OWASP LLM Top 10 Immutable audit trail Never trains on your data

Direct answer

Dify AI security is a mix of strong platform fixes and permissive carryovers. Version 1.17.1 closed an SSRF hole where agent skills ignored your private network allowlist, but knowledge base API keys created earlier keep workspace-wide access, Human Input approvals sent by email can be answered by anyone holding the link, and Dify Agent is marked for trusted users only. Patch to 1.17.1, rescope keys, and put a policy layer on the tools your agents can write to.

Try it live

Watch AgentShield block an attack in real time.

Pick a scenario and drive the inspection lane yourself. No signup needed.

Threat Console
Interactive demo · 0 blocked in this session

Run a request

Runs the live engine on your text. Nothing is stored, no account needed.

Inspection lane

INSPECTING
⌖ untrusted input

Policy trace

High-risk action held for approval

Audit trail

The risk

A US insurance services firm runs self-hosted Dify. A claims intake workflow reads emailed PDFs, a knowledge base answers adjusters, and since August a Dify Agent with a sandbox drafts letters and calls an internal claims API through an MCP server. The knowledge base key the intake integration uses was created in spring, so it can read every knowledge base in the workspace. The approval step that holds payouts above 5,000 dollars emails a link to a shared claims inbox, and anyone who sees that email can click Approve. Nobody configured any of this badly. Each piece was the default when it was set up.

How AgentShield handles it

Keep Dify for what it does well: visual workflows, RAG, the agent builder, the plugin marketplace and tracing. Put AgentShield on the outbound path. Route the MCP servers and HTTP APIs your Dify tools and agents call through the AgentShield gateway, move write credentials out of Dify into the gateway, and let a per-tool, per-argument policy decide what runs, what is held for a named approver, and what is denied, with every decision logged.

The controls

The controls that secure which tools, MCP servers and sandboxed commands a Dify agent may run, and who approves first.

What Dify enforces for you, and what it leaves to your configuration

Dify is an open-source platform from LangGenius for building LLM apps, RAG pipelines, workflows and agents, with about 157,000 GitHub stars and both a hosted cloud and a self-hosted edition. It ships more security plumbing than most builders in its class: an SSRF proxy for outbound requests, role-based workspace members, content moderation hooks, a Human Input node for approvals, encrypted credential storage and, since August, a pluggable key management layer with Azure Key Vault support.

The weak points are not missing features. They are defaults that favor getting started, settings that do not change when you upgrade, and the fact that a builder platform governs which apps exist and who can edit them, not whether a specific tool call should run. Here is the map we use when we review a Dify deployment.

ControlWhat Dify providesDefault or catchWhat is left to you
Outbound request policySSRF proxy with private IP and private domain allowlistsBefore 1.17.1 the agent runtime used a separate proxy that ignored those allowlistsUpgrading, then testing that agents cannot reach internal hosts
Knowledge base API keysService API keys, now optionally bound to one knowledge baseKeys created before 1.17.1 stay workspace-wideReissuing every integration key with a dataset scope
ApprovalsHuman Input node with web app or email deliveryEmail links work for anyone holding them, no Dify account neededDeciding who can approve, and proving it was them
Agent sandboxDify Agent runs commands in a Linux sandbox, local or E2BBeta, and the release warns to offer it only to trusted usersLimiting which users and which tasks reach it
Content checksModeration settings plus marketplace pluginsNothing inspects tool arguments unless you add itChoosing a plugin or gateway and wiring it to every app
Secret keyGenerated and persisted automatically since 1.14.1An explicitly set key from an old example file is keptRotating SECRET_KEY if yours came from a template

Read the third column and a pattern shows up. Most of the risk in a Dify deployment that has been running since 2025 comes from configuration that was correct for the version it was created on and is still in force today.

Dify Agent, the 1.17 releases and the SSRF allowlist bypass

Dify changed what an agent is this summer. Release 1.16.0, published July 17, 2026, introduced Dify Agent as a beta. Dify's documentation describes it plainly: it works in a sandbox of its own, "it runs commands, installs programs, and reads and writes files, so it takes on open-ended work rather than just calling the tools you configured." The release notes carry a warning in bold that we think every buyer should read twice: "You should provide Dify Agent services only to trusted, non-malicious users."

Release 1.17.0 on August 25 built on that. Agent shell and code execution can now run on E2B cloud sandboxes as well as locally. Build-time home snapshots capture the sandbox home directory, including installed packages and prepared files, and restore it on every run of the published agent. Workspace-level Skills arrived as reusable, versioned packages of code and tool definitions that agents discover and invoke. The same release raised the default APP_MAX_EXECUTION_TIME and WORKFLOW_MAX_EXECUTION_TIME from 1,200 to 3,600 seconds, so a run can now go three times longer before the platform stops it.

Release 1.17.1 on September 10 then fixed the issue that matters most for anyone who already had agents in production. In Dify's words: "Agent skills bypassed the SSRF private-network policy. Agent traffic goes through a separate proxy that ignored SSRF_PROXY_ALLOW_PRIVATE_IPS and SSRF_PROXY_ALLOW_PRIVATE_DOMAINS, so the allowlist you configured for workflows did not constrain the agent runtime." Both proxies now honor the same allowlist.

ReleaseDateSecurity-relevant change
1.14.1May 12, 2026Docker installs stop relying on a public default SECRET_KEY; metrics endpoints hardened
1.15.0June 25, 2026Fixes for the four DifyTap vulnerabilities, per Zafran
1.16.0July 17, 2026Dify Agent beta with a Linux sandbox; MCP server IDOR fixed
1.17.0August 25, 2026E2B sandbox, Skills, home snapshots, short-lived agent tokens, ownership scoping fixes, longer default run time
1.17.1September 10, 2026Agent SSRF allowlist bypass fixed; dataset-scoped knowledge base keys

The honest read: Dify's team is shipping security fixes fast, and the direction is right. But an agent that can run shell commands, install packages and keep that state between runs has a much larger reach than a workflow node that calls one HTTP endpoint. Any credential the sandbox can see, any internal host it can resolve and any tool a Skill exposes is now inside the blast radius of a prompt injection hidden in a document or web page the agent reads.

Dify vulnerabilities in 2026 and which version fixes them

Dify's repository lists more than twenty security advisories, and 2026 has been busy. Several came from outside research. Imperva published two findings on May 18, 2026, a one-click account takeover through SVG handling fixed in 1.13.1 and a cross-tenant source code disclosure in the sandbox fixed in 1.13.3, and summarized the stakes in one sentence: "API keys, OAuth tokens, and model configurations stored in Dify can be extracted, enabling lateral movement into every connected external service."

Zafran Security published DifyTap on June 22, 2026: four vulnerabilities, two critical, two exploitable without authentication, three with cross-tenant impact on Dify's multi-tenant cloud. CVE-2026-41947 (CVSS 9.1) let any console user configure tracing for apps they did not own, which turns into a persistent copy of another customer's chats. CVE-2026-41948 (CVSS 9.4) reached the internal Plugin Daemon API. Zafran states all four are patched in 1.15.0, and notes the PDF parsing stack ran a PDFium build vulnerable to CVE-2024-5846 for more than 18 months.

IssueDisclosedImpactFixed in
CVE-2025-67732January 2026Plaintext model provider API keys visible to non-admin members1.11.0
Imperva account takeover and sandbox disclosureMay 2026One-click takeover; other tenants' code readable in the sandbox1.13.1 and 1.13.3
Unauthenticated SSRF in remote file upload (GHSA-8235-vv5j-mmvg)May 2026Server-side requests to internal hosts without logging in1.13.0
DifyTap, CVE-2026-41947 to 41950June 2026Cross-tenant chat capture, plugin daemon access, file previews1.15.0
MCP server IDOR (GHSA-ccrj-frp2-c945)August 2026A member can modify another app's MCP server configuration1.16.0

The MCP finding deserves a second look. Dify's advisory says "An authenticated user can modify MCP server configurations belonging to other applications in the same workspace without proper authorization," rated high at CVSS 7.1. The pattern behind it, and behind most of the list, is authorization that trusted an ID in the request. That is a bug class platforms fix one endpoint at a time. A control that sits outside the platform and checks every tool call against its own policy does not depend on each endpoint getting it right.

If you self-host, the minimum bar today is 1.17.1. Read its upgrade guide first: deployments using the bundled Weaviate must complete a staged upgrade from 1.27.0 to 1.39.2, because Dify warns that skipping minors "can silently and permanently break vector search."

Dify human in the loop and where the Human Input node stops

Dify's Human Input node is the closest thing the platform has to an approval gate, and it is a good node. It pauses a workflow, shows a form with variables such as the AI draft or the proposed refund, collects edits, and routes on the button the reviewer clicks. Since 1.17.0 it also works inside Loop and Iteration nodes, so you can review each item in a batch rather than only the batch as a whole.

Three details in Dify's own documentation decide whether it can carry a high-value approval:

  1. Email delivery is a bearer link. The documentation says an email request can go to workspace members, external addresses or the whole workspace, and "Anyone with the link can respond, no Dify account required." A forwarded email, a shared mailbox or a ticket that quotes the link gives approval rights to whoever reads it.
  2. Web app delivery does not cover triggered runs. The web app form is "Not available in workflows started by a Trigger." Scheduled and webhook-started workflows, which are usually the unattended ones, can only use email.
  3. Timeouts end the run unless you wire them. The default timeout is three days, and "If no timeout branch is connected, the workflow ends." That fails safe for a payout, but it fails silently for a time-sensitive task unless someone builds the fallback path.

The node also only exists where a builder placed it. Dify Agent runs inside a single Agent node, choosing its own commands and tool calls inside that step, so a Human Input node before or after it cannot hold one specific action in the middle.

RequirementHuman Input nodePolicy enforced at a gateway
Hold only calls above a dollar thresholdYes, with a branch before the nodeYes, per tool and per argument
Approver must be a named person who logged inWeb app only; email links are openYes, identity recorded with the decision
Hold one action inside a Dify Agent runNo, the node wraps the whole agent stepYes, each outbound call is checked
Same rule across every app in the workspaceOnly if every builder adds the nodeYes, policy lives outside the apps

Our human approval for AI agents page shows what an approver sees and how holds expire.

Dify security plugins compared with a runtime security layer

Dify's marketplace already has several security options, and some of them are good enough that you should not buy anything else. Dify has published integrations with the Palo Alto Networks AI Runtime Security plugin, which puts a scanning engine in front of model calls, user inputs and model responses, and with an Azure AI Content Safety container plugin. Microsoft's open-source Agent Governance Toolkit announced a governance plugin in the Dify marketplace in April 2026, and an open-source OpenGuardrails plugin covers prompt injection and sensitive data checks.

These tools mostly inspect text. That is valuable, and it answers a different question from the one that causes losses. A guardrail can tell you a retrieved document looks like an injection attempt. It cannot tell you whether this claims agent, acting for this adjuster, should approve this 8,400 dollar payout to a new bank account.

NeedDify plus marketplace pluginsWith AgentShield added
Block unsafe or off-policy content in chat appsYes, moderation plus a content safety pluginNo change needed for this alone
Scan prompts and responses against injection patternsYes, Prisma AIRS or OpenGuardrails pluginsNo change needed for this alone
Catch injected instructions in documents a Dify Agent opens in its sandboxOnly if the plugin sees that contentInspection on content before tool calls act on it
Per-argument hold on writes to internal APIs and MCP serversNot availableOne policy per tool and value threshold
Write credentials kept out of Dify and the sandboxEncrypted in Dify, readable by the runtimeGateway holds them, Dify holds a scoped token
Same controls for Dify, LangChain and OpenAI agentsDify onlyOne policy for every framework calling the same tools

Two of those six rows say buy nothing, and we mean it. A Dify chat app that answers employee questions from a knowledge base, with no write tools and keys scoped to one dataset, is well served by Dify's moderation and a content safety plugin. The case for a runtime layer starts when Dify apps or agents can pay, send, change records or reach internal systems.

One licensing note for teams planning around self-hosting: Dify's license is a modified Apache 2.0. It allows commercial use, but operating a multi-tenant environment from the source code requires written authorization, and the console logo and copyright cannot be removed. If you run one workspace per business unit for internal teams, read that clause with counsel before you scale.

How to put AgentShield in front of Dify tools and MCP servers

You keep building in Dify the way you do now. The change is where outbound calls go and where write credentials live.

  1. Get to 1.17.1 first. Follow the staged Weaviate upgrade if you use the bundled vector store, confirm SECRET_KEY is not a value copied from an old example file, and test that agents cannot reach internal addresses your allowlist excludes.
  2. Rescope old keys. List every knowledge base service API key, reissue each integration key bound to the one knowledge base it needs, and revoke the workspace-wide originals.
  3. Inventory tools that act. List every custom tool, HTTP Request node, MCP server and Skill that writes, sends, pays or deletes, and note which apps and agents can call each one.
  4. Route MCP and HTTP through the gateway. Point Dify's MCP tool connections at the AgentShield MCP gateway and your HTTP tools at the AgentShield proxy. Move long-lived write credentials to the gateway so the sandbox never holds them.
  5. Write policy per tool. Allow reads broadly, cap writes by value, deny what an agent should never touch. Rules live in AI agent permissions management and apply the same way to workflows, chatflows and Dify Agent.
  6. Keep Human Input for content review, and move the money decisions. Use the node for drafts and edits. Send payouts, refunds and record changes to a gateway hold where a logged-in, named approver signs off, and every decision lands in the AI agent audit trail.

Teams comparing visual builders should read our Flowise security and n8n security pages too, since the same gateway policy covers all three. Teams whose business users build agents inside a workspace tool should also read our Notion Custom Agents security page.

FAQ

Common questions about dify ai security.

Is Dify secure?

Dify is actively maintained and patched quickly, with SOC 2, ISO 27001 and GDPR assessments for its cloud. It has also had serious 2026 vulnerabilities, including the DifyTap cross-tenant flaws fixed in 1.15.0 and an agent SSRF allowlist bypass fixed in 1.17.1. Self-hosted teams should run 1.17.1 or later and rescope older API keys.

Is Dify open source?

Yes, under a modified Apache 2.0 license. Commercial use is allowed, including as a backend for your own apps. Running a multi-tenant service from the source code needs written authorization from Dify, and the console logo and copyright notice may not be removed or changed when you use its frontend.

What is the Dify sandbox?

It is the isolated environment where Dify runs code. Code nodes use dify-sandbox, and since July 2026 Dify Agent runs in its own Linux sandbox, locally or on E2B, where it executes commands, installs packages and reads and writes files. Dify says to offer Dify Agent only to trusted, non-malicious users.

Does Dify support human in the loop?

Yes, through the Human Input node, which pauses a workflow and shows a form with decision buttons. It can be delivered in the web app or by email. Email links can be answered by anyone holding them without a Dify account, and web app delivery is not available in workflows started by a Trigger.

Does Dify support MCP servers?

Yes. Dify can call MCP servers as tools and can publish an app as an MCP server. In August 2026 Dify disclosed a high severity flaw where a workspace member could modify another app's MCP server configuration, fixed in 1.16.0. Treat every MCP server an app can reach as part of its permissions.

Does Dify have guardrails?

Dify has built-in content moderation and a marketplace of security plugins, including Palo Alto Networks AI Runtime Security, Azure AI Content Safety, OpenGuardrails and a Microsoft Agent Governance Toolkit plugin. They mainly inspect prompts and responses. None decides whether a specific tool call with specific arguments should run.

Do I need a Dify enterprise license?

You need a commercial license if you operate a multi-tenant environment from Dify's source code, or if you want to remove the frontend logo and copyright. Single-workspace internal use under the open-source license does not require one. Enterprise also adds multiple workspaces and enterprise management features.

Does AgentShield work with Dify?

Yes, on the outbound path. You route the MCP servers and HTTP APIs your Dify apps and agents call through AgentShield, which checks each call against a per-tool policy, holds high-value actions for a named approver, inspects untrusted content for injected instructions and logs every decision. Dify itself stays unchanged.

Secure your dify ai security.