-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High memory usage when using coraza plugin #9
Comments
Some updates: I tinkered around with my setup, mostly adjusting the I also adjusted the
Isn't this part of the main function and only used during initialization? Additionally, this is the configuration Traefik is currently running with. experimental:
plugins:
traefik-real-ip:
modulename: github.com/soulbalz/traefik-real-ip
version: v1.0.3
geoblock:
moduleName: github.com/PascalMinder/GeoBlock
version: v0.2.2
coraza:
moduleName: github.com/jcchavezs/coraza-http-wasm-traefik
version: v0.2.1
entrypoints:
websecure:
address: ':443'
forwardedHeaders:
insecure: true
http:
tls: true
middlewares:
- 'realip@file'
- 'geoblock-de@file'
- 'waf@file'
global:
sendAnonymousUsage: false
checkNewVersion: false
api:
dashboard: true
insecure: true
metrics:
prometheus:
addRoutersLabels: true
addServicesLabels: true
ping: {}
log:
level: DEBUG
accessLog: {}
providers:
file:
directory: /local/config
consulcatalog:
endpoint:
address: 'consul.service.consul:8501'
scheme: https
token: '${CONSUL_TOKEN}'
tls:
insecureSkipVerify: false
connectAware: true
connectByDefault: true
exposedByDefault: false
defaultRule: 'Host(`{{ .Name }}.${DOMAIN}`)'
constraints: 'TagRegex(`cloudflare.enable=true`)' http:
middlewares:
waf:
plugin:
coraza:
directives:
- SecRuleEngine On
- SecDebugLog /dev/stdout
- SecDebugLogLevel 9
- Include @crs-setup.conf.example
- SecRule REQUEST_URI "@streq /xyz" "id:101,phase:1,log,deny,status:403" # Testing
# - Include @owasp_crs/**.conf
- Include /directives/*.conf |
Can confirm this issue. With
traefik process uses a bit under 2GB, without it 100MB. |
Hello, I noticed a similar behavior using Traefik in binary mode and the Coraza middleware. Here is my experience in case it can be useful to someone. The System's RAM usage before starting Traefik with Coraza is 2,4G and after starting it 2,7G. First test: Second test: First time ------------ RAM: 6.0G After waiting 10 minutes without sending traffic the RAM came down to 6.0G. I ran the same tests without the Coraza middleware and the RAM didn't even budged, it stayed at 2.4G before starting Traefik, after starting Traefik, and during the traffic tests. Here is my config: waf:
plugin:
coraza:
directives:
- SecRuleEngine On
- SecDebugLog /dev/stdout
- SecDebugLogLevel 9
- Include @crs-setup.conf.example
- Include @owasp_crs/**.conf |
Hi everyone, thanks for coming by this repository. The problem seems to be very similar to what we experienced in corazawaf/coraza-proxy-wasm#249. Although they are different code, what they have in common is the GC and that could be the issue. One way to slice and dice this issue is to discriminate requests with/without payload and second, in directives set |
In the mean time I released https://github.com/jcchavezs/coraza-http-wasm-traefik/releases/tag/v0.2.2 which attempts to introduce minor improvements in performance. Would be amazing if any of you could test it. |
Same issue here, memory usage grows even with minimal usage until pod is killed. v0.2.2 has the same issue, tested. |
Plan to use this plugin... is the memory leak still an issue? |
Yes, unfortunately the problem hasn't been found or fixed. There is an interesting idea for a workaround here: traefik/yaegi#1590 (comment) |
Thanks this works: https://github.com/madebymode/traefik-modsecurity-plugin?tab=readme-ov-file |
This PR is up http-wasm/http-wasm-host-go#86 and hopefully it will help in here. |
Hey @jcchavezs how can I get the fix running? |
We tested the newest version Adding some details for reference:
plugin:
coraza:
crsEnabled: true
directives:
- Include @coraza.conf-recommended
- Include @crs-setup.conf.example
- Include @owasp_crs/*.conf
- SecRuleEngine On I'm not very experienced with Go or memory profiling, so this is the extent of what I can do. |
I am not quite sure if it is related, but when I tested v3.0.0 with traefik v3.2.0 the coraza plugin significantly increased response time and CPU usage. Memory is also increasing which is why I think it might all be related in some way. Details:
plugin:
coraza-waf:
directives:
# - SecDebugLog /dev/stdout
# - SecDebugLogLevel 9
- SecRule REQUEST_URI "@streq /admin" "id:101,phase:1,log,deny,status:403"
# Allow some additional HTTP methods:
# - SecAction "id:900200,phase:1,pass,t:none,nolog,setvar:'tx.allowed_methods=GET HEAD POST OPTIONS PUT PATCH DELETE CHECKOUT COPY LOCK MERGE MKACTIVITY MKCOL MOVE PROPFIND PROPPATCH UNLOCK REPORT'"
# Allow some additional request content-types:
- SecAction "id:900220,phase:1,pass,t:none,nolog,setvar:'tx.allowed_request_content_type=|application/x-www-form-urlencoded| |multipart/form-data| |multipart/related| |text/xml| |application/xml| |application/soap+xml| |application/json| |application/cloudevents+json| |application/cloudevents-batch+json| |text/plain| |application/proto|'"
- SecRequestBodyAccess Off #Fix according to https://github.com/jcchavezs/coraza-http-wasm-traefik/issues/9#issuecomment-2146919384
- Include @coraza.conf-recommended
- Include @crs-setup.conf.example
- Include @owasp_crs/**.conf
- SecRuleEngine On |
I am currently trying to implement the coraza plugin into traefik, which sits behind a cloudflare tunnel for external access.
As soon as I activate the middleware for the services traefik starts using a lot of memory.
I increased the allowed memory usage of traefik to 4 GB, which were immediately consumed after navigating two times.
After the third, Traefik fails with an OOM exception and restarts.
I can't imagine that these kind of high memory usages are expected.
There also seems to be an ongoing discussion about the same topic here, where Traefik even seems to consume about 32 GB of memory.
I removed most other configuration, since they shouldn't be relevant but this is the config I have the Traefik running with:
I intentionally removed the other two include-directives, but even with such a barebone setting I receive an OOM after a handful of requests.
The text was updated successfully, but these errors were encountered: