File Security Scan is off by default. Enable it by setting
FILE_SCAN_ENABLED to true. See Environment Variables for details.Connect a Scanner
In Integrations > File Security Scan, click Add scanner and choose the type that fits where your files are allowed to go:- Cloudmersive, Scanii, or MetaDefender Cloud: a hosted service you have an account with. Each file’s contents go to that service, and every scanned upload uses your quota there. Any member who can edit a knowledge base’s settings can turn scanning on with this scanner, so size your plan for every knowledge base that could use it.
-
Custom Endpoint: your company’s own scanning service. See Custom Endpoint Scanner API for the request and response it must handle.
If your scanning service runs on your company’s internal network, Dify can’t reach it until the deployment allows its address.Dify’s outgoing requests pass through a proxy that blocks internal addresses by default, so that no one can use Dify to reach your internal systems. Allow your endpoint by setting one of:
SSRF_PROXY_ALLOW_PRIVATE_IPS= the endpoint’s IP addressSSRF_PROXY_ALLOW_PRIVATE_DOMAINS= the endpoint’s hostname
Turn On Scanning for a Knowledge Base
Turning on scanning requires the Editor role or above.
Choose What Happens to Unscanned Files
For the two cases where a scan can’t give an answer, choose whether to block the file or let it in unscanned:- When the scanner is unavailable: the scanner can’t be reached, times out, returns a server error, or sends an answer Dify can’t read. Dify retries temporary failures before this choice applies.
- When a file cannot be scanned (encrypted or too large): the file is encrypted or password-protected, larger than the scanner accepts, or a type the scanner doesn’t support.
Check That Scanning Works
Upload the EICAR test file to the knowledge base. It’s a harmless file that every antivirus engine reports as malware, available from eicar.org. Its document should show Error with a malware message. If it’s indexed instead, check that scanning is turned on and saved for this knowledge base. You can delete the test document afterward.Handle a Blocked File
In the document list, hover the icon next to a document’s Error to read why it was blocked. For these two cases, there’s more to know:- Malware detected: delete the document. Retrying it, or uploading the same file again, only blocks it again.
- Encrypted, too large, or not supported by the scanner: such files are blocked by default. If you’re fine with them going into the knowledge base unscanned, switch the knowledge base’s When a file cannot be scanned (encrypted or too large) choice to Allow files, then retry. The choice applies to every later file in the knowledge base, so switch it back if you only needed it for this one.