We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I am trying to force a virus scanning when uploading files (call a maldetect script whenever a file is uploaded).
It seems like I can never trigger the uploader, as the whole process is killed before it even gets there.
While this triggers modsec rules on any location (php etc) -
Code:
location / {
ModSecurityEnabled on; ModSecurityConfig modsecurity.conf;
}
It doesn't trigger the upload scanner. If I include modsec with the php-fpm section -
location ~ .php$ { root /home/user/public_html; try_files $uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/tmp/php5-fpm-user.sock; fastcgi_index index.php; fastcgi_cache_bypass $no_cache; fastcgi_no_cache $no_cache; fastcgi_cache WORDPRESS; fastcgi_cache_valid 60m; fastcgi_param SCRIPT_FILENAME /home/user/public_html$fastcgi_script_name; include fastcgi_params;
### ENABLE MOD SECURITY ### ModSecurityEnabled on; ModSecurityConfig modsecurity.conf;
It will trigger the rules for GET requests, but every POST request will fail with " no upstream configuration " error.
So the first include doesn't trigger error on POST requests (note - regardless of the upload, I've not tested the rules on POST requests yet).
Second include returns the " no upstream configuration " error.
This is the modsec rule main conf file -
SecRuleEngine On SecRequestBodyAccess On SecRule FILES_TMPNAMES "@inspectFile /usr/local/maldetect/modsec.sh" "log,auditlog,deny,severity:2,phase:2,t:none,msg:'Malicous File Attachment Identified.',id:'1010101'" SecResponseBodyAccess Off SecStatusEngine On SecResponseBodyMimeType (null) text/html text/plain text/xml SecResponseBodyLimit 2621440 SecUploadDir /var/asl/data/suspicious SecUploadKeepFiles Off SecAuditEngine RelevantOnly SecAuditLogRelevantStatus "^(?:5|4(?!04))" SecAuditLogType Concurrent SecAuditLog /var/asl/data/audit/logs/audit_log SecAuditLogParts ABIFHZ SecArgumentSeparator "&" SecCookieFormat 0 SecRequestBodyInMemoryLimit 131072 SecDataDir /var/asl/data/msa SecTmpDir /tmp SecAuditLogStorageDir /var/asl/data/audit SecResponseBodyLimitAction ProcessPartial SecAuditLogDirMode 0770 SecPcreMatchLimit 250000 SecPcreMatchLimitRecursion 250000
Include rules/cwaf_01.conf Include rules/cwaf_02.conf
Include rules/cwaf_04.conf
Include rules/whitelist/user/ip_whitelist.conf Include rules/whitelist/user/rules_whitelist.conf
Anyone tried this scenario before and managed to get it to work ?
Thanks in advance, Eli.
The text was updated successfully, but these errors were encountered:
Hi @elialum, marking this issue as duplicate of #664.
Sorry, something went wrong.
No branches or pull requests
Hi,
I am trying to force a virus scanning when uploading files (call a maldetect script whenever a file is uploaded).
It seems like I can never trigger the uploader, as the whole process is killed before it even gets there.
While this triggers modsec rules on any location (php etc) -
Code:
location / {
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;
}
It doesn't trigger the upload scanner.
If I include modsec with the php-fpm section -
Code:
location ~ .php$ {
root /home/user/public_html;
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/tmp/php5-fpm-user.sock;
fastcgi_index index.php;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
fastcgi_param SCRIPT_FILENAME /home/user/public_html$fastcgi_script_name;
include fastcgi_params;
}
It will trigger the rules for GET requests, but every POST request will fail with " no upstream configuration " error.
So the first include doesn't trigger error on POST requests (note - regardless of the upload, I've not tested the rules on POST requests yet).
Second include returns the " no upstream configuration " error.
This is the modsec rule main conf file -
Code:
SecRuleEngine On
SecRequestBodyAccess On
SecRule FILES_TMPNAMES "@inspectFile /usr/local/maldetect/modsec.sh" "log,auditlog,deny,severity:2,phase:2,t:none,msg:'Malicous File Attachment Identified.',id:'1010101'"
SecResponseBodyAccess Off
SecStatusEngine On
SecResponseBodyMimeType (null) text/html text/plain text/xml
SecResponseBodyLimit 2621440
SecUploadDir /var/asl/data/suspicious
SecUploadKeepFiles Off
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
SecAuditLogType Concurrent
SecAuditLog /var/asl/data/audit/logs/audit_log
SecAuditLogParts ABIFHZ
SecArgumentSeparator "&"
SecCookieFormat 0
SecRequestBodyInMemoryLimit 131072
SecDataDir /var/asl/data/msa
SecTmpDir /tmp
SecAuditLogStorageDir /var/asl/data/audit
SecResponseBodyLimitAction ProcessPartial
SecAuditLogDirMode 0770
SecPcreMatchLimit 250000
SecPcreMatchLimitRecursion 250000
Include rules/cwaf_01.conf
Include rules/cwaf_02.conf
Include rules/cwaf_03.conf # Eli - errors on nginx, do not enable
Include rules/cwaf_04.conf
Include rules/cwaf_05.conf # Eli - errors on nginx, do not enable
Include rules/whitelist/user/ip_whitelist.conf
Include rules/whitelist/user/rules_whitelist.conf
Anyone tried this scenario before and managed to get it to work ?
Thanks in advance,
Eli.
The text was updated successfully, but these errors were encountered: