Skip to content
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

how to tell coraza not to buffer responses? #148

Open
dkhokhlov opened this issue May 12, 2024 · 4 comments
Open

how to tell coraza not to buffer responses? #148

dkhokhlov opened this issue May 12, 2024 · 4 comments

Comments

@dkhokhlov
Copy link

dkhokhlov commented May 12, 2024

I am using caddy as https reverse proxy with coraza. my app streams response. w/o coraza I see page rendered gradually. with coraza I get whole page after delay. Even with empty coraza config it is still buffering.

how to tell coraza not to buffer responses?

myhost:1443 {
    tls /etc/caddy/my.crt /etc/caddy/my.key
    reverse_proxy localhost:8080
    header Access-Control-Allow-Methods "POST, GET, OPTIONS"
    header Access-Control-Allow-Headers "*"
    encode zstd gzip
    log {
        level  DEBUG
    }
  coraza_waf {
    directives `
      Include /etc/caddy/coraza-coreruleset/rules/@coraza.conf-recommended
      Include /etc/caddy/coraza-coreruleset/rules/@crs-setup.conf.example
      Include /etc/caddy/coraza-coreruleset/rules/@owasp_crs/*.conf
      SecRuleEngine On
      SecDebugLog /dev/stdout
      SecDebugLogLevel 9
      SecRule REQUEST_URI "@streq /admin" "id:101,phase:1,t:lowercase,deny,status:403"
      SecRule REQUEST_BODY "@rx maliciouspayload" "id:102,phase:2,t:lowercase,deny,status:403"
    `
  }
}
@dkhokhlov dkhokhlov changed the title how to tell coraza not buffer response? how to tell coraza not to buffer responses? May 12, 2024
@jptosso
Copy link
Member

jptosso commented May 12, 2024

Unfortunately it's impossible to process the request with blocking capabilities without buffering.
Modsecurity tried a streaming mode but it never really worked, the same applies for coraza.
Also CRS breaks if we stops processing request body phase

@dkhokhlov
Copy link
Author

dkhokhlov commented May 12, 2024

double checking - you are talking about response? buffering a request and then processing its body etc is ok. but buffering corresponding response from the server is the problem.

@jptosso
Copy link
Member

jptosso commented May 12, 2024

Same applies for responses, but it might not affect CRS unless you enable anomaly scoring mode. I think it wouldn't damage to allow users to stream the response body. We could even use an action to tell the connector to stream

@jcchavezs @fzipi

@jcchavezs
Copy link
Member

jcchavezs commented May 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants