owasp-modsecurity / ModSecurity-nginx

ModSecurity v3 Nginx Connector
Apache License 2.0
1.48k stars 274 forks source link

feature request: hook memory in modsecurity #279

Open liudongmiao opened 2 years ago

liudongmiao commented 2 years ago

After hook glibc, there are some clear memory leak in modsecurity transaction.

There are pcre_malloc and pcre_free in this module, so I hook all memory callback in msc_transaction, and finally resolve the memory leak in modsecurity transaction.

(I have implemented, however, I won't add a PR without discussion.)

liudongmiao commented 2 years ago

And in our test, the performance (rps) increase about 3% - 15%.

zxyqq commented 2 years ago

发个pr给我们测试下吧

liudongmiao commented 2 years ago

@zxyqq I use it to resolve memory issues. And if you use Persistent Storage (https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v3.x)#Persistent_Storage), it may won't work, as all memory would be free when transaction complete.

However, as expirevar is not implemented (https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v3.x)#expirevar), it would be ok. And I have use this patch found a transaction-related memory leak: https://github.com/SpiderLabs/ModSecurity/pull/2727