Data loss prevention on servers

Data loss prevention, usually shortened to DLP, is the set of controls that stop sensitive information leaving where it belongs, whether by theft, mistake or a misconfigured service.

What does data loss prevention protect against?

Three kinds of leak. Exfiltration, where an attacker who gets in copies data out; insider leaks, where someone with access takes or shares what they should not; and accidents, which are the most common: a database dump left in a public web folder, a backup bucket opened to the world, credentials committed to a repository or customer data pasted into a ticket. DLP aims to make each of these harder and to notice quickly when one happens. It is related to, but different from, backup: backup protects against losing your copy, DLP protects against others gaining one.

Where do I start?

With classification. You cannot protect everything equally, so list the data that would hurt if it leaked: customer personal data, payment references, credentials and keys, source code, financial records. Note where each lives, which systems and people need it, and where copies go, including backups, logs, analytics and developer laptops. Most organisations find copies they had forgotten in this step, and deleting those is the cheapest DLP win there is.

ClassExamplesTypical controls
SecretPrivate keys, API tokens, database passwordsSecrets manager, no copies in code or logs
RestrictedCustomer personal data, payment referencesEncryption, named access, export alerts
InternalSource code, financial reportsAccess control, outbound limits
PublicMarketing pages, documentationIntegrity only

How do I control where data can travel?

Restrict outbound connections from servers that hold restricted data. A database server needs to reach package mirrors, a time source, your backup host and perhaps a monitoring endpoint; it does not need to reach the whole internet. An nftables output policy that allows only those destinations stops a compromised service from uploading a dump to an attacker's machine.

table inet egress {
  set allowed4 { type ipv4_addr; flags interval; elements = { 203.0.113.40, 198.51.100.0/28 } }
  chain out {
    type filter hook output priority filter + 10; policy drop; # only listed destinations leave
    ct state vmap { established : accept, related : accept, invalid : drop }
    oif "lo" accept
    ip daddr @allowed4 accept
    udp dport 53 accept
  }
}

Log what is dropped for the first weeks, because legitimate destinations you forgot will appear there.

How do I stop secrets leaking through code and logs?

Scan before they leave. Tools such as gitleaks check commits for keys and passwords and can block a push that contains one. Configure applications to mask tokens and personal fields in logs, and keep log retention short for anything that might include them. Store secrets in a manager or encrypted files rather than environment files that are copied around.

gitleaks detect --source /srv/repos/billing --redact --report-path /root/gitleaks-billing.json

Does encryption help?

Yes, against specific risks. Disk encryption with LUKS protects data on drives that leave service; TLS protects data in transit between servers, which matters because we do not sell a private network and traffic between machines crosses the public port, so use WireGuard or TLS for every internal link. Application-level encryption of the most sensitive fields means a stolen database dump is far less useful. Encryption does not help against someone who already has legitimate access, which is why access control and monitoring sit alongside it.

How do I notice a leak in progress?

Watch for unusual volume and destinations. Alert when outbound traffic from a database host exceeds its normal daily pattern, when a query returns an unusually large number of rows, or when an account exports far more than usual. Database audit extensions such as pgAudit record who read what. On our servers, European and Canadian ports are unmetered, so bandwidth bills will not warn you; your own monitoring must.

Which regulations make DLP a requirement?

Many data protection laws expect it in substance even when they never use the term. Rules on personal data generally require appropriate technical measures, limits on who can see records and notification when data escapes, and payment card standards ask for cardholder data to be found, minimised and protected. A written classification, outbound controls and export alerts are evidence that those measures exist. Keep the records of reviews and alerts, since an auditor will ask for them.

What about people?

Give each person the least access their work needs, use named accounts so actions are traceable, and remove access promptly when roles change. Make the safe path easy: a clear way to share files securely means fewer people resort to personal email. Pair this page with IT security basics, Hardening a new dedicated server and What a firewall does.

Related pages

IT security basics

The parts of IT security that matter for a team running servers: identity, patching, network exposure, data protection, logging and a practised response.

Read more

Hardening a new dedicated server

The first hour on a fresh machine: SSH keys, a firewall, automatic updates, brute force blocking and a habit of checking what listens.

Read more

What a firewall does

Firewalls explained from packets up: stateful filtering, default-deny policies, host and network firewalls, nftables examples and mistakes that lock you out.

Read more

Respond to a compromised server

What to do in the first hour after you suspect an intruder on a rented machine: contain, preserve evidence, rebuild and close the hole.

Read more

Questions and answers

What is data loss prevention?

Controls that stop sensitive data leaving where it belongs, whether through attacks, insiders or accidents.

Is DLP the same as backup?

No. Backup protects you from losing your own copy; DLP stops other people gaining a copy.

How can a server stop data being uploaded elsewhere?

With an outbound firewall policy that only allows the destinations the server genuinely needs, such as mirrors and the backup host.

How do I find secrets committed to Git?

Run a scanner such as gitleaks on the repository and in pre-commit or CI hooks to block new ones.

Is traffic between your servers private?

No private network is sold, so traffic between machines uses public ports. Encrypt every internal link with WireGuard or TLS.