Repository navigation
Expand file tree
/
Copy pathclamd.conf
More file actions
104 lines (96 loc) · 5.18 KB
/
Copy pathclamd.conf
File metadata and controls
104 lines (96 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# clamd configuration for the docker-compose stack, bind-mounted over
# /etc/clamav/clamd.conf in the clamav/clamav:stable image.
#
# It exists for one reason: clamd's stock limits are below what a single
# scan window here needs. The portal never hands clamd the raw archive —
# it sends metadata.json whole, then each decompressed log (validator.log.gz,
# plus sentry.log.gz when present) in 1 GiB windows with a 1 MiB overlap,
# under one shared budget per submission — but with stock config clamd
# would still reject those windows with "INSTREAM size limit exceeded."
# and the portal — correctly failing closed — would answer 503.
#
# 2147483647 is the number this deployment standardises on: comfortably
# more than one window plus its overlap needs, and at ClamAV's own
# documented ceiling for these directives (see the comment by
# StreamMaxLength below). The values below are headroom now, not a bound
# tied to cmd/portal's -max-upload-size — the two no longer have to
# agree. AlertExceedsMax yes stays exactly as important as before: it's
# what stops clamd from silently skipping content that somehow still
# exceeds these limits instead of failing the scan closed.
DatabaseDirectory /var/lib/clamav
LogTime yes
Foreground yes
TCPSocket 3310
LocalSocket /tmp/clamd.sock
# 2147483647 is 2 GiB - 1, and it is not a round number chosen for taste:
# libclamav refuses to scan any single file larger than that, whatever these
# settings say. Configure more and clamd accepts the value, logs
#
# LibClamAV Warning: Max file-size was set to N bytes. Unfortunately,
# scanning files greater than 2147483647 bytes (2 GiB - 1) is not supported.
#
# and then rejects oversized input at scan time with
# Heuristics.Limits.Exceeded.MaxFileSize — which the portal turns into a 503.
# A plain "2G" here is 2147483648, one byte over: set it to that and clamd
# accepts the config but still enforces the real ceiling underneath it, so
# nothing past 2147483647 ever actually scans. This is exactly why
# clamav.WindowedScanner's default window is 1 GiB rather than something
# closer to this ceiling: there is no headroom left once the 1 MiB overlap
# is added back on top of a window sized any bigger. Verified against
# ClamAV 1.5.3.
StreamMaxLength 2147483647
MaxFileSize 2147483647
MaxScanSize 2147483647
# The setting that keeps the AV layer honest. MaxScanSize bounds
# *recursively extracted* bytes, and a submission nests two deep
# (archive.tar.gz -> tar -> validator.log.gz or sentry.log.gz ->
# plaintext), so the limits above are reachable — cmd/portal's
# -max-log-size alone permits on the order of a gigabyte of decompressed
# log per entry.
#
# clamd's default here is "no", which means content skipped for exceeding
# a limit is simply not scanned and the stream still answers "stream: OK".
# The portal would then store an unscanned archive as clean: a silent
# fail-open underneath a layer whose whole design is to fail closed.
# With this on, clamd instead reports Heuristics.Limits.Exceeded.*, which
# clamav/clamd.go maps to a scan error (503), not a malware verdict.
AlertExceedsMax yes
# Reloading the signature database builds a second engine in memory
# before swapping, which roughly doubles clamd's footprint mid-exercise.
# The stock image leaves this on; this deployment trades a brief pause
# during reloads for a predictable memory ceiling, because the failure
# mode of the alternative is an OOM kill that 503s every upload.
ConcurrentDatabaseReload no
# clamd buffers each INSTREAM body to disk. Without this it lands on the
# container's writable layer, where concurrent ~1 GiB scan windows across
# concurrent uploads can fill the host's Docker storage; docker-compose.yml
# backs this path with a volume.
TemporaryDirectory /var/tmp/clamav
# Streaming a 1 GiB scan window over a slow uplink means long gaps are
# normal; the stock 30s read timeout would hang up on a legitimate window.
ReadTimeout 600
# Scanning is CPU-bound and this file replaces the image's config
# wholesale, so leaving these unset means inheriting clamd's built-in
# defaults (10 threads, 100 queued) — more threads than the target host has
# cores, which oversubscribes the CPU that cmd/portal also needs for gzip
# decompression on the very same box.
#
# 6 leaves two of eight cores for the portal. The number to keep in step
# with it is cmd/portal's -max-concurrent-submissions: this must stay at or
# above it, or scan windows queue inside clamd, where the waiting is
# invisible to the portal and still counts against -clamav-timeout — which
# covers the dial. A window that times out is a *failed* scan, which
# rejects the submission with a 503, so a mis-sized pair here turns
# congestion into lost submissions rather than slow ones.
#
# Verify what the daemon actually adopted rather than trusting this file:
# docker compose exec clamav clamconf -n
MaxThreads 6
MaxQueue 100
# Uncomment for a load test: it logs a line per clean scan, so with
# LogTime yes above you get the wall-clock cost of every 1 GiB window
# straight from the daemon. That is what distinguishes "clamd is slow"
# from "the disk is slow" — the two look identical from the portal side.
# Leave it off in normal operation; it is one line per window per
# submission.
#LogClean yes