> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Scan Uploaded Files for Malware

> Block malware in files uploaded to knowledge bases, using a hosted scanning service or your company's own scanner

Each knowledge base can scan the files uploaded to it for malware before they're indexed. Scanners are added once for the whole workspace, and any knowledge base can then use one of them.

Scanning covers files *uploaded* to a knowledge base, including those from a knowledge pipeline's local-file data source. Content from Notion, website crawls, online documents, and online drives isn't scanned, and neither are files sent to apps, workflows, or chats.

## Connect a Scanner

> [!NOTE]
>
> Connecting scanners requires the **Edit and delete credentials** permission. The workspace Owner and Admins hold it by default.

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.

  Each file it scans uses your quota there, and any member who can edit a knowledge base's settings can turn scanning on with this scanner. Size your plan for every knowledge base that could use it.

* **Custom Endpoint**: your company's own scanning service. See [Custom Endpoint Scanner API](https://enterprise-docs.dify.ai/en/3.14.x/use/knowledge/file-security-scan-custom-endpoint.md) for the request and response it must handle.

  > [!NOTE]
  >
  > If your scanning service runs on your company's internal network, ask your deployment administrator to allow the service's IP address or hostname in Dify's SSRF proxy (`ssrfProxy.squidConf` in the Helm values). See [SSRF Protection](https://enterprise-docs.dify.ai/en/3.14.x/deploy/advanced-configuration/environment-variables.md#ssrf-protection) for details.

Dify tests the connection when you save a scanner, and won't save one that fails.

## Turn On Scanning for a Knowledge Base

> [!NOTE]
>
> Turning on scanning requires the **Edit knowledge base content and settings** permission on the knowledge base. The workspace Owner, Admins, and the knowledge base's creator hold it by default, and Editors hold it on knowledge bases they can access.

In the knowledge base's **Settings**, go to **File security scan**: turn it on, choose a **Scanner**, set the [two choices below](#choose-what-happens-to-unscanned-files), and click **Save**.

Scanning covers files uploaded after you turn it on. To have every file scanned, create an empty knowledge base first, turn scanning on, then upload your files.

A document already in the knowledge base is scanned the next time it's processed, such as when it's retried or its chunk settings change. If it turns out to be infected, the document shows `Error`. To have one scanned right away, delete it and upload the file again.

### 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.

Switch either choice to **Allow files** only when getting files in matters more than scanning every one. That might be a knowledge base that must stay up to date while the scanner is down, or one that regularly takes files larger than the scanner accepts. Files allowed this way are indexed without a scan, and nothing marks them as unscanned.

Whichever you choose, files found to contain malware are always blocked. So are files sent to a scanner whose credentials are rejected or whose quota is used up.

### Check That Scanning Works

Download the EICAR test file from [eicar.org](https://www.eicar.org). It's a harmless file that every antivirus engine reports as malware. Save it with a `.txt` extension and upload it to the knowledge base. Its document should show `Error`, and hovering the icon next to it should show a malware message.

If it's indexed instead:

* Check that scanning was turned on and saved before you uploaded the file.
* Check the knowledge base's **When the scanner is unavailable** choice. With **Allow files**, the file goes in unscanned when the scanner doesn't answer. In **Integrations** > **File Security Scan**, the workspace Owner or an Admin can click **Test** on the scanner to see whether it answers.

## 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.