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

# Data Loss Prevention (DLP)

> Content-scanning policies that detect and act on sensitive data patterns at upload time.

## Overview

Enclave's DLP engine scans file **content** at upload time and applies a configurable action — warn, block, or quarantine — based on the sensitive-data patterns it finds. Policies are managed from **Organization → DLP**.

<Note>
  **DLP scans only content the server can read** — **My Files** and **Envelope**
  (server-side) rooms. **Zero-Knowledge and ZK-Strict rooms are never scanned**: the
  file is encrypted in the browser and the server only ever holds ciphertext, so
  content scanning is impossible and DLP does not apply. Those rooms are unaffected
  by DLP settings; their **classification label and clearance checks still apply** —
  see [Clearance Levels](/organization/clearance).
</Note>

## Enabling DLP

DLP has three enforcement postures, chosen by an **Owner** or **Security Officer** on the **Policy** tab:

| Posture                | What it does                                                                                                                                                                                                     |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Disabled**           | No server-side scanning.                                                                                                                                                                                         |
| **Tenant-wide**        | DLP is enforced for **all** org units. Per-unit overrides can fine-tune or disable it for specific units.                                                                                                        |
| **Selected org units** | DLP is **off by default** and enforced **only** for the org units you opt in. Enabling a parent unit also covers its child units (a child can opt back out). Nothing is scanned until you add at least one unit. |

Choose **Selected org units** to adopt DLP for part of your organization without forcing it on everyone.

## Scan mode

| Mode                      | Effect                                                                                                                                                                                         |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Client-only** (default) | Advisory feedback in the browser. The server never reads file content.                                                                                                                         |
| **Server-side**           | The server temporarily decrypts the plaintext of your **My Files and Envelope** content to scan it with the full NLP engine, then discards it. Required for enforced (block / quarantine) DLP. |

Turning on **server-side** mode requires a one-time acknowledgment that the server will read the plaintext of your **server-decryptable** content to scan it. This does **not** weaken your Zero-Knowledge or ZK-Strict rooms — those are never scanned. You are re-prompted to acknowledge whenever server-side scanning is re-activated after being turned off.

## Org-unit overrides

Under the **Scope** tab you can layer per-org-unit overrides on top of the tenant posture:

* In **Tenant-wide** mode, an override *tightens or disables* DLP for a specific unit.
* In **Selected org units** mode, an override is how you *opt a unit in*.

The most-specific scope wins when several apply.

### Scope precedence

When a file is uploaded by a user in Org Unit B, a child of Org Unit A:

1. Org Unit A's policy applies, then Org Unit B's (child overrides parent)
2. Then any user-level override (most specific)
3. With no override, the tenant posture decides

If a parent policy has **Lock downward** enabled, child scopes cannot override it.

## Patterns

Patterns are the signals DLP looks for. Enclave ships built-in patterns for common sensitive data types:

| Pattern            | Detects                                         |
| ------------------ | ----------------------------------------------- |
| Credit card number | PCI card numbers (Visa, Mastercard, Amex, etc.) |
| SSN                | US Social Security Numbers                      |
| Passport number    | International passport formats                  |
| Email address      | RFC-compliant email addresses                   |
| Phone number       | International phone number formats              |
| IBAN               | Bank account numbers                            |
| NPI                | US National Provider Identifier (HIPAA)         |
| NHS number         | UK National Health Service numbers              |
| Aadhaar            | Indian national ID numbers                      |
| IP address         | IPv4 and IPv6 addresses                         |
| Crypto wallet      | Bitcoin, Ethereum, and other wallet addresses   |

Add one or more patterns to a policy. The policy triggers if **any** selected pattern is found at or above the confidence threshold.

## Confidence threshold

Each pattern match carries a confidence score (0.0–1.0). The policy only triggers if the match confidence meets or exceeds the **minimum confidence** setting (default: 0.8).

Lowering the threshold increases sensitivity but also increases false positives. Raising it reduces false positives but may miss some content.

## Actions

When a pattern is detected above the threshold, the policy applies one of four actions:

| Action         | Effect                                                                                                                                   |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Allow**      | File is uploaded normally. The detection is logged.                                                                                      |
| **Warn**       | File is uploaded but the uploader sees a warning banner. The event is logged.                                                            |
| **Block**      | Upload is rejected. The user sees a policy violation error. No file is stored.                                                           |
| **Quarantine** | File is stored in a restricted quarantine state, inaccessible to regular users. A security officer must review and release or delete it. |

## Quarantine

Quarantined files appear in the DLP dashboard under **Security → Policies → DLP → Quarantine**.

Each quarantine record shows:

* File name and size
* The pattern(s) that triggered the quarantine
* Confidence score
* Upload timestamp and uploader identity
* Reason (content policy violation or file size limit)

Security officers can **release** a file (making it accessible to the original uploader) or **permanently delete** it.

## Oversized file quarantine

Files that exceed the platform's configured maximum file size are automatically quarantined with reason `oversized_file`, regardless of DLP pattern content. The size limit is set by platform administrators in deployment configuration.

## Lock downward

When **Lock downward** is enabled on a policy, child Org Unit scopes cannot create a policy that is less restrictive. This ensures that a department-level "Block" cannot be overridden by a team-level "Allow".

## Download re-inspection (egress)

DLP normally runs once, at upload. Optionally, Enclave can **re-inspect content at
download time** for external (federated) downloads — useful for catching content
that violates a policy which was *tightened after* the file was uploaded.

This is enabled per deployment with the `DLP_INSPECT_ON_DOWNLOAD` environment
variable (off by default). When on:

* The check reuses the plaintext already decrypted for watermarking, so it adds
  **no extra key-management or text-extraction cost** — only the pattern scan.
* A **blocking** verdict stops the download and records a `dlp_download_blocked`
  audit event; warn/allow verdicts let it through.
* It **fails open**: if the scan cannot complete, the download proceeds (an
  infrastructure hiccup never blocks an already-authorised, in-policy download).
* Zero-Knowledge files are never re-inspected — the server holds no plaintext.

## Scanned documents and images (OCR)

Text-based files are extracted for free with the built-in engine. Image files and
**scanned PDFs with no text layer** require OCR (AWS Textract), which is billed
per page. Because OCR is the most expensive part of the pipeline, it is governed
by explicit cost controls (deployment configuration):

| Control               | Default | Effect                                                                                                                    |
| --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| `OCR_ENABLED`         | off     | Master switch. When off, files needing OCR are **quarantined for manual review** (fail-closed) instead of incurring cost. |
| `OCR_MIN_IMAGE_BYTES` | 8 KB    | Images below this size (icons, logos, signatures) are treated as text-free — no OCR call.                                 |
| `OCR_MAX_BYTES`       | 20 MB   | Inputs above this size skip OCR and are quarantined for review.                                                           |
| `OCR_CACHE`           | on      | Identical content (by hash) is never OCR'd twice — retries and re-scans reuse the cached result.                          |

<Note>
  With `OCR_ENABLED` off, image-only and scanned documents cannot be
  auto-scanned and are held in quarantine for a security officer to review. Turn
  OCR on if your tenants routinely handle scanned paperwork containing PII.
</Note>

## Audit trail

All DLP events — detections, blocks, quarantines, reviews, releases, and
download blocks — are written to the immutable audit log with the file ID,
triggering pattern, confidence score, and acting user.
