Proxy

Block malware in uploads

When users upload files into your service, scan what they send before it reaches storage or a worker. Arm ClamAV, aim it with a WAF rule at the upload paths only, decide what happens to files you cannot scan, and alert when the scanner fails, because it fails open.

Overview

Attachments, avatars, documents, imports: anything a user uploads is content you did not write, arriving inside a request your application is about to trust.

Content scanning hands the request body to ClamAV before it is forwarded upstream. A signature hit refuses the request with 403, so infected content never reaches your storage, your queue or a downstream worker. It is proxy-mode only: something has to hold the decrypted body.

When you see this

  1. Your service accepts uploads of any kind.
  2. Uploaded files are stored, processed by a worker or shown to other users.

Steps

  1. 01

    Arm the scanner

    Enabling the scanner on its own scans nothing. This arms it and sets what happens to an upload it cannot inspect.

    /etc/synapse/config.yaml
    proxy:
      content_scanning:
        enabled: true
        clamav_server: "localhost:3310"
        max_file_size: 10485760
        unscannable: block
  2. 02

    Aim it at the upload paths

    A WAF rule with the content_scanning action selects the traffic. Everything outside it is untouched and costs nothing; scanning every body would put a ClamAV round trip in front of every API write.

    WAF rule, action content_scanning
    starts_with(http.request.path, "/upload")
    DecisionDoes the agent log "content scanning is enabled but no WAF rule uses the content_scanning action"?

    Yes Nothing is being scanned. Add the rule above, or fix the one that should match.

    No The rule is in place. Test it.

  3. 03

    Decide what happens to files you cannot scan

    An upload can be selected and still be uninspectable: over max_file_size, or chunked past it. block refuses it with 413; pass forwards it unscanned and logs it. Choosing pass is legitimate, but make it deliberately.

  4. 04

    Test with the EICAR file

    Upload the standard EICAR antivirus test file to a selected path and expect a 403. Upload the same file to a path the rule does not select and expect it to pass: that is the boundary of your coverage.

  5. 05

    Alert on scan failures

    If ClamAV is unreachable the request proceeds and the failure is logged. A quietly dead scanner looks identical to a clean one, so watch for the failures, and keep the signature database current.

Common mistakes

  1. Enabling the scanner without a content_scanning rule: it inspects nothing.
  2. Setting unscannable to pass without meaning to, which quietly turns a scanned endpoint into a partially scanned one.
  3. Adding a second upload endpoint later without extending the rule to cover it.

Escalate when

  • A signature hit on a file that reached storage before scanning was in place.

Where this stops working

  • ClamAV is signature-based: it catches known malware, not a payload written for you.
  • Latency scales with body size, plus a round trip, on the selected traffic.
Run it here

Send the request. Watch where it stops.

Edit the request or any rule and the pipeline runs again. The rules are real wirefilter expressions, evaluated the way the agent evaluates them; the traffic and model scores are samples. It all runs in your browser.

Try this Change the path to /api/import: no rule selects it, so nothing is scanned.

The request

ingress · proxy mode

Every value is a rule field. Change one and the pipeline re-runs.

Connection
Source, resolved by the platform
Fingerprints, from Dendrite
HTTP, readable in proxy mode
Model scores, sample output from Cortex
Flow behaviour, per source
Payload, what Thalamus inspects
Result Refused with 403
ResultRefused with 403Proxy · content scanning
  1. 01Capture and fingerprintDendrite · On the wireObserved

    Computed JA4, JA4T, JA4H for this connection. Capture only: Dendrite never blocks.

  2. 02Access rulesHillock · XDP hook, before routingPassed

    192.0.2.80 (NL, AS64500) is on no access list.

    From the threat feed: known-bad sourcesNo match
    Country, resolved to IP ranges on the platform sideNo match
  3. 03Firewall rulesHillock · TC hook, in the kernelNot used

    No firewall rules in this policy.

  4. 04Intrusion detectionThalamus · On the hostNot used

    No signatures loaded for this scenario.

  5. 05Behavioural modelsCortex · On the host CPUObserved

    Sample scores, 0 to 100: C2 2, scan 3, malicious flow 4. Nothing leaves the machine to be scored.

  6. 06Service graphHippocampus · On the hostNot used

    No workload identity on this flow.

  7. 07Smart firewall rulesAmygdala · Decided on the host, enforced in nftablesNot used

    No smart firewall rules in this policy.

  8. 08WAF rulesProxy · In the proxy, after decryptionPassed

    Matched a content_scanning rule: the body goes to ClamAV before it is forwarded.

    Matched
  9. 09Content scanningProxy · ClamAV, before forwardingRefused

    ClamAV found the EICAR test signature. Refused with 403: the file never reaches storage or a worker.

Field names and operators follow the docs: WAF and Smart Firewall. A rule that names an unknown field does not load; a field the request does not carry never matches.

What lands in the event log
{
  "ts": "2026-11-17T09:41:07.212Z",
  "layer": "waf",
  "action": "block",
  "source": "waf",
  "rule_msg": "content scanning: ClamAV signature",
  "src_ip": "192.0.2.80",
  "src_port": 54321,
  "dst_ip": "198.51.100.10",
  "dst_port": 443,
  "src_country": "NL",
  "fingerprints": {
    "ja4t": "64240_2-4-8-1-3_1460_10",
    "ja4": "t13d1516h2_8daaf6152771_02713d6af862"
  }
}

Shaped like the documented event schema; the timestamp, ports, rule ids and ban duration are illustrative.

Now on your own traffic.

A demo runs the same pipeline against real packets, with the engineers who built it.