Appearance
File uploads Since v0.1
File protection checks the files clients upload, on the paths you name. It finds the type by content, never by the file name, and refuses files that are not what they claim: a script named photo.jpg, a script hidden in an image, a web shell, an archive bomb or a file on a hash deny list. It can also send files to an antivirus server over ICAP.
Before you begin
- Role:
operatorfor the application. Adding antivirus servers needsadminwith access to every application; shared hash lists needoperatorwith access to every application. - The application's request body limit applies first. For upload paths, raise it with an exception (
limits: {request_body: 12MiB}, at most 64 MiB), or the upload is refused withfile.limitbefore its files are checked. - For antivirus: an ICAP server you run yourself (for example ClamAV behind c-icap) that the inspection nodes can reach.
Add an upload rule
Only the paths of the rules are checked. Requests elsewhere are not touched. Start in detect: events show what would be refused.
text
1. Open Applications > All applications > the application > Request checks > File uploads.
2. On the Checks and hash lists tab, set Protection mode to detect.
3. On the Upload rules tab, add a rule: paths, allowed and refused types, largest file, where the files are.
4. Select Preview changes, add a comment and select Apply.sh
waap files set -app shop -m "file uploads" mode=detect
waap files list set -app shop -list rules -f rules.yaml -m "upload rule"yaml
# rules.yaml (waap files list set), or applications[].policy.files.rules
- paths: ["/upload/*"]
allow: [image, pdf]
deny: [executable, script]
max_size: 5MiB
archives: inspectAn allow or deny entry is a family (image, pdf, office, text, archive, audio, video, executable, script) or an exact type such as image/svg+xml. The console offers the families as checkboxes.
Say where the files are
| Where | How |
|---|---|
| Multipart forms | always checked |
The whole body is the file (PUT, application/octet-stream) | raw: true |
| Base64 file contents in JSON | json_fields with JSON pointers such as /document/content |
A raw body sent as a form, JSON or XML is still inspected as arguments by signatures. Any other raw body is one file, judged by this module.
Open archives
archives: inspect opens zip, tar and gzip uploads and checks every member. Bombs are refused: deep nesting, more than 1,000 members, or an unpacked size over 10 times the file. Encrypted members are refused unless encrypted: allow.
Choose the checks
Each check is off, log or block: mismatch (the content contradicts the name or declared type), scripts (script markers at the start of an image or PDF), names (.htaccess, web.config, double extensions such as x.php.jpg, path separators) and webshells.
text
1. On the Checks and hash lists tab, set each check to off, log or block.
2. Select Preview changes, then Apply.sh
waap files set -app shop -m "checks" webshells=block names=logyaml
files:
mismatch: block
scripts: block
names: block
webshells: blockTry a file first
The Test a file tab checks a file as if uploaded to a path. It shows the type found, the SHA-256 (to add to a list) and what each check finds. Nothing is sent to the application.
sh
waap files test -app shop -path /upload/avatar -f photo.jpgUse hash lists
A file list holds SHA-256 values, written in the list or fetched from an https URL by the active node (one value per line, or sha256sum output). Name lists under Refused hashes (hash_lists.deny) or Trusted hashes (hash_lists.allow: the other checks are skipped for them). A list in use cannot be removed.
text
1. Open Shared lists > File lists and add a list: values, or a URL with a refresh time.
2. Select Preview changes, then Apply.
3. In the application's Checks and hash lists tab, name the list under Refused hashes or Trusted hashes.
4. For a URL list, select Fetch now to download it at once.sh
waap file-lists set -f lists.yaml -m "hash lists"
waap file-lists refresh -name badfiles
waap files set -app shop -m "deny hashes" hash_lists.deny=badfilesyaml
# file_lists (shared)
- name: badfiles
url: https://intel.example.com/hashes.txt
refresh: 6hThe table shows each list's count, last fetch and last error. The last good copy is kept when a fetch fails.
Scan files with an antivirus server
Two steps. First an administrator adds the server. Then each application uses it.
text
1. Open System > Settings > Antivirus servers and add a server: a name and its icap:// or icaps:// URL.
2. For TLS, upload a CA bundle and, for mutual TLS, a client certificate in the TLS files of a server form. The key is never shown again.
3. Select Test to send the harmless EICAR string and a clean file through the inspection node's own connection.
4. In the application, open File uploads > Checks and hash lists > Antivirus (ICAP), choose the ICAP server and set the options.sh
waap icap set -f servers.yaml -m "antivirus"
waap icap test -name av
waap files set -app shop -m "scan uploads" icap.server=avyaml
# icap_servers (shared)
- name: av
url: icap://av.internal/avscanRun the test after adding a server and after changing its TLS files: EICAR must be reported infected and the clean file clean. The table shows each server's state (reachable, failing, not applied yet), last scan, latency and last error.
What is sent: each file once, decoded (also base64 in JSON), inside a synthetic request that carries only the method, path, host and declared type. Cookies and credentials never reach the antivirus server. Files already refused by another check, and files on a trusted list, are not sent. Verdicts are remembered for an hour per server signature version.
The data plane waits for the scan, up to the server's timeout, so users see a slower upload, not an error. Large files and archives take longest.
Events
file.av.infected is always refused in block mode. file.av.unavailable (server unreachable, busy or too slow) is refused with 503 when the failure mode is closed, and reported when open. file.av.not_scanned is a file larger than Largest file scanned, or more than 32 files in one request.
Settings reference
General and checks
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
File protection (policy.files.enabled) | Checks files on the upload rules' paths. | true | true, false | all |
Protection mode (mode) | detect reports; block refuses. | empty (same as the application) | detect, block, empty | detect wins |
Content contradicts name or type (mismatch) | The content is not what the name or type says. | block | off, log, block | block mode |
Scripts hidden in images and documents (scripts) | Script markers (<?php, <%, <script, #!) at the start of an image or PDF. | block | off, log, block | block mode |
Dangerous file names (names) | .htaccess, web.config, double extensions, path separators, NUL bytes. | block | off, log, block | block mode |
Web shells (webshells) | Text files and archive members that look like web shells. | block | off, log, block | block mode |
Refused hashes (hash_lists.deny) | File lists whose SHA-256 values are refused. | none | names of defined lists | all |
Trusted hashes (hash_lists.allow) | File lists whose files skip the other checks. | none | names of defined lists | all |
Upload rule
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
paths | Paths the rule checks. | none (required) | 1 to 64; exact or prefix ending in * | all |
max_size | Largest file. | 10MiB | 1 byte to 64MiB | all |
allow, deny | Types accepted or refused. | none | up to 64 families or types | all |
json_fields | JSON pointers to base64 file contents. | none | up to 16 pointers | all |
raw | The whole body is the file. | false | true, false | all |
archives | Open archives. | skip | skip, inspect | all |
encrypted | Encrypted archive members. | block | allow, block | archives: inspect |
Antivirus (ICAP)
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
ICAP server (icap.server) | The server that scans files. | none (files are not sent) | name of a defined server | all |
Largest file scanned (icap.max_size) | Larger files are not sent. | 32MiB | up to 64MiB | server set |
Files too large to scan (icap.oversize) | What happens to a larger file. | block | block, allow (reported as not scanned) | server set |
Server unavailable (icap.on_failure) | What happens when it cannot be used. | inherit | inherit (the application's failure policy), open, closed | server set |
Scan archive members (icap.members) | Also send members, for servers that do not unpack archives. | false | true, false | server set |
ICAP server (shared)
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
name | Identifies the server. | none (required) | unique name | all |
url | Where it is. | none (required) | icap://host[:1344]/service or icaps://host[:11344]/service | all |
timeout | Bounds one scan. | 10s | up to 61s | all |
max_concurrent | Scans in flight per inspection node. | 32 | up to 256 | all |
File list (shared)
| Setting | What it does | Default | Allowed values | Applies in |
|---|---|---|---|---|
name | Identifies the list. | none (required) | unique name | all |
sha256 | Inline values. | none | up to 10,000 | not with url |
url | Fetches the values. | none | https URL | not with inline values |
refresh | How often it is fetched. | 1h | 5m to 168h | url only |
Examples
Accept only images and PDFs on the upload path, scan with ClamAV, refuse above 5 MiB:
yaml
files:
mode: block
icap: {server: av, on_failure: open}
rules:
- paths: ["/upload/*"]
allow: [image, pdf]
max_size: 5MiBLimits
| Limit | Value |
|---|---|
| Upload rules per application | 64, each with up to 64 paths |
| File lists | 200 |
| ICAP servers | 16 |
| Files sent to an antivirus per request | 32 |
| Archives | 1,000 members; unpacked size at most 10 times the file |
| Metrics | waap_file_findings_total{app,rule,action}, waap_icap_requests_total{server,result}, waap_icap_duration_seconds |
Events have rule IDs file.*, naming the file (sanitised), the field, the type found and declared, the size and the SHA-256, and the archive member. File content is never kept: an event's request capture omits a body that carries files (body_omitted: files).
Troubleshooting
Uploads fail with file.limit
- Cause: the request body limit is smaller than the upload.
- Fix: raise the limit for the upload path with an exception, up to 64 MiB.
file.av.unavailable events
- Cause: the ICAP server is unreachable, busy or too slow.
- Check: the server's state and last error in System > Settings > Antivirus servers, then Test.
- Fix: repair the server, raise
timeoutormax_concurrent, or chooseopenfor Server unavailable.