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

Could not use equal sign in xpath expression #2328

Closed
dennus opened this issue May 28, 2020 · 5 comments · Fixed by #2864
Closed

Could not use equal sign in xpath expression #2328

dennus opened this issue May 28, 2020 · 5 comments · Fixed by #2864
Labels
3.x Related to ModSecurity version 3.x

Comments

@dennus
Copy link

dennus commented May 28, 2020

E.g.:

SecRule XML://tag1/*[local-name()='some-tag']
"@pm ..\ ../"
"phase:request,
msg:'Path Traversal Attack (/../)',
id:77113,
ver:'OWASP_CRS/3.0.0',
rev:'1',
maturity:'9',
accuracy:'7',
multiMatch,
t:base64Decode,
block,
severity:CRITICAL,
logdata:'Matched Data: %{TX.0} found within %{MATCHED_VAR_NAME}: %{MATCHED_VAR}',
capture,
tag:'application-multi',
tag:'language-multi',
tag:'platform-multi',
tag:'attack-lfi',
tag:'OWASP_CRS/WEB_ATTACK/DIR_TRAVERSAL',
setvar:'tx.msg=%{rule.msg}',
setvar:tx.anomaly_score=+%{tx.critical_anomaly_score},
setvar:tx.lfi_score=+%{tx.critical_anomaly_score},
setvar:'tx.%{rule.id}-OWASP_CRS/WEB_ATTACK/DIR_TRAVERSAL-%{matched_var_name}=%{matched_var}'"

Error occured when nginx start:
nginx: [emerg] "modsecurity_rules_file" directive Rules error. File: /var/rules/rules.conf. Line: 1. Column: 48. Expecting a variable, got: : ='some-$

@zimmerle zimmerle self-assigned this May 28, 2020
@zimmerle
Copy link
Contributor

Hi @dennus,

Do you mind to inform us more details of your ModSecurity? What is the version that you are working with?

@dennus
Copy link
Author

dennus commented May 28, 2020

Hello, I'm using Modsecurity v. 3.0.3

@victorhora victorhora added 3.x Related to ModSecurity version 3.x and removed pending feedback labels Jun 18, 2020
@airween
Copy link
Member

airween commented Jul 7, 2020

I think this is a similar issue:

SecRule ARGS:/^=/ "@rx foo" ...

The error message:

... Expecting a variable, got:  :  =/ ...

so I will not open any new issue.

@martinhsv
Copy link
Contributor

These are similar issues, but the workaround situation is different.

@airween ,

For your case, a reliable workaround should be to use a character class:

SecRule ARGS:/^[=]/ "@rx foo" ...

@dennus ,

For XPATH, in a recent case that I encountered, using contains() instead of an equality operator proved a reasonable substitute. This may not be sufficient in all cases, however.

@airween
Copy link
Member

airween commented Sep 7, 2021

For your case, a reliable workaround should be to use a character class:

SecRule ARGS:/^[=]/ "@rx foo" ...

thanks

@martinhsv martinhsv changed the title Coul'd use equal sign in xpath expression Could not use equal sign in xpath expression Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants