Re: Using 'deprecatevar' on multiple variables in a collection

Andrew Howe <[email protected]> Mon, 11 Jan 2021 14:22:47 +0000
Newsgroups gmane.comp.apache.mod-security.user
Message-ID <CADi1syD2TP8C87sCYmFW2EO=VH5+P2gOBJ+a+EtZ8QBQ0wqhFA@mail.gmail.com>
Hi,

I wanted to follow up with some further investigation into this.
Hopefully, these findings may help someone else in a similar scenario
in the future.

I ended up going through ModSecurity's (2.x) source to confirm how the
'deprecatevar' action works. Looking at re_actions.c confirmed my
suspicion: all variables in a given persistent collection are tied to
a *single timestamp* (LAST_UPDATE_TIME) for the purposes of
calculating their deprecation. This can cause strange behaviour when
deprecatevar is used on multiple variables in the same collection.

I've written a full explanation about this in a blog post, which can
be found here: https://www.loadbalancer.org/blog/modsecurity-and-the-case-of-the-never-decreasing-variables/

I've also written a Lua script which I'm using to work around this
issue. The script has been published to GitHub, here:
https://github.com/loadbalancer-org/modsec_decrement_script

If nothing else, this was a fun opportunity to spend time poking
around ModSecurity's source code :)

Thanks,
Andrew

-- 
Andrew Howe
Loadbalancer.org Ltd.
www.loadbalancer.org


_______________________________________________
mod-security-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mod-security-users
Commercial ModSecurity Rules and Support from Trustwave's SpiderLabs:
http://www.modsecurity.org/projects/commercial/rules/
http://www.modsecurity.org/projects/commercial/support/