Skip to content

[appsec] Large uploads (>134MB) fail with "body size above the configured limit" #3837

@Tech-no-1

Description

@Tech-no-1

What happened?

Whenever I take a video which is more than a few seconds long (in this case 180 MB and 33 s), the (auto) upload to Immich fails. I'm using Crowdsec with Appsec enabled and NPMplus, all running in a docker compose.

In the NPMplus logs I get this:

[alert] 8001#8001: *78964 [lua] crowdsec.lua:642: Allow(): [Crowdsec] denied 'my_public_ip' with 'ban' (by appsec) while sending to client, client: 'my_public_ip' , server: immich.domain.com, request: "POST /api/assets HTTP/1.1", host: "immich.domain.com"

Looks like my public ip address got banned, so I've tried "cscli decisions delete -i my_public_ip" and got "INFO 0 decision(s) deleted". No ban, so what's going on? After that I looked at the crowdsec logs:

level=warning msg="Disrupting transaction with body size above the configured limit (Action Reject)" band=inband chain_rule_id=1208191248 name=appsec runner_uuid=dc6feccb-160b-44ca-b0a7-be8fc875df0d tx_id=864ebda2-42e9-4692-baf0-cf89849623b3 type=appsec
level=warning msg="Disrupting transaction with body size above the configured limit (Action Reject)" band=outband chain_rule_id=4217647230 name=appsec runner_uuid=dc6feccb-160b-44ca-b0a7-be8fc875df0d tx_id=864ebda2-42e9-4692-baf0-cf89849623b3 type=appsec

I've tried several things:

  1. I've added a custom parser whitelist with an expression pattern that (hopefully) whitelisted the HTTP request/path and I've also whitelisted my dynamic public ip address with the "LookupHost" function (in postoverflows). Both did nothing because they don't affect appsec.
  2. I've made a custom appsec config in order to increase the "request_body_in_memory_limit", but I was only able to increase it to 100 MB and it didn't help. I've also tried an appsec config with a hook "on_match" allowing the URI, but apparently appsec disrupts the process before that.
  3. I've set "APPSEC_FAILURE_ACTION=passthrough" in the crowdsec.conf of NPMplus, but that didn't work either.
  4. I've allowlisted my public ip, which worked and I was able to upload the video, but as my ip is dynamic (like for many others) I always have to manually allowlist the current ip whenever someone wants to upload a larger file. That's not really a great/viable solution.
  5. I can disable the Appsec body inspection altogether, which of course works too, but I don't know if that's such a good solution?

Possible solution (I see):
I've came across the Traefik bouncer config (bouncer-middleware.yaml) which has this option "crowdsecAppsecBodyLimit: 10485760". The crowdsec.conf of NPMplus doesn't provide a similar config option to modify the body limit, something like "APPSEC_BODY_LIMIT" for example. Would probably need to be integrated into Crowdsec and Nginx/NPMplus.

#3656 and fosrl/pangolin#436 (comment)

What did you expect to happen?

Big file/video upload get's processed by appsec and ultimately uploaded to Immich successfully.

How can we reproduce it (as minimally and precisely as possible)?

Take a longer video and try uploading it to Immich (probably any large file upload that exceeds the body limit). Crowdsec, Appsec enabled and NPMplus proxy.

Crowdsec version

Details
$ cscli version
version: v1.6.11-d64ee2ae
Codename: alphaga
BuildDate: 2025-07-23_13:32:19
GoVersion: 1.24.5
Platform: docker
libre2: C++
User-Agent: crowdsec/v1.6.11-d64ee2ae-docker
Constraint_parser: >= 1.0, <= 3.0
Constraint_scenario: >= 1.0, <= 3.0
Constraint_api: v1
Constraint_acquis: >= 1.0, < 2.0
Built-in optional components: cscli_setup, datasource_appsec, datasource_cloudwatch, datasource_docker, datasource_file, datasource_http, datasource_journalctl, datasource_k8s-audit, datasource_kafka, datasource_kinesis, datasource_loki, datasource_s3, datasource_syslog, datasource_victorialogs, datasource_wineventlog

Acquisition config

Details
appsec_configs:
  - crowdsecurity/appsec-default
name: appsec
source: appsec
labels:
  type: appsec

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions