Re: Use of Modsec variable in apache access log

homesh joshi <[email protected]> Wed, 21 Jun 2023 17:45:42 +0530
Newsgroups gmane.comp.apache.mod-security.user
Message-ID <CAAjxK7t4zFHDiQy93RtB=gObTifc9F5ckpN138Wmh5kW78ZMPw@mail.gmail.com>
--===============8658854852609852356==
Content-Type: multipart/alternative; boundary="000000000000b6264705fea2ba7c"

--000000000000b6264705fea2ba7c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Christian,

Thanks for the quick reply. OK so in detectonly mode also modsecurity rule
evaluation works the same.
Debug is a good idea. I have UAT so I can test. Will let you know.

Thanks,
Homesh

On Wed, Jun 21, 2023 at 3:03=E2=80=AFPM Christian Folini <
[email protected]> wrote:

> Hey Homesh,
>
> Evaluation does indeed stop after a drop and there is a chance
> your rules only set the variables in question in a later phase.
> Really depends on your configuration.
>
> You can follow rule execution with the ModSecurity debug log, but beware
> it is very verbose.
>
> Generally, it is best to set variables for display in the access log only
> in phase 5, which is also executed for requests that have been denied
> in an earlier phase.
>
> Best regards,
>
> Christian
>
>
>
>
> On Wed, Jun 21, 2023 at 01:14:04PM +0530, homesh joshi wrote:
> > Hi All,
> >
> > With regards to my approach for logging the modsec variables in apache
> log
> > has worked for me for almost a year now.
> > However, today when I enabled "SecRuleEngine DetectionOnly" for one of =
my
> > websites. What I notice is that the apache logs are missing the right
> > variable data.
> > e.g I tested SQL injection and i was not able to see the relevant
> > information in apache log which I typically get when "SecRuleEngine On"
> > sample log for "SecRuleEngine DetectionOnly"
> > 49.36.106.185 - - [21/Jun/2023:06:39:53 +0000] 200 23125 GET "-"
> > "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101
> > Firefox/114.0" 3154 443 example.com ZJKbOUfg7dWT82qCkvNySAAAAEU TLSv1.3
> > TLS_AES_128_GCM_SHA256 0 4 L; "/" 15.24.15.205 39735 "" "" "" "/" 33376=
2
> > "/?k=3D1%20or%201=3D1"
> >
> > here rule id log is 333762 which is not the signature for SQL injection
> >
> > So my conclusion is, in "SecRuleEngine On" rule evaluation stops when t=
he
> > first rule matches with the final action drop/block. Hence I am able to
> get
> > the right rule ID and other variable data. But when "SecRuleEngine
> > DetectionOnly" rule evaluation continues till the last rule and due to
> > which my variable data gets changed as per the rules getting evaluated.
> Can
> > I change this behaviour of modsecurity in Detectonly mode ? that it
> should
> > stop the evaluation when it matches the first rule with final action of
> > drop/block ( and not block/drop the transaction) ?
> >
> > Please suggest.
> >
> > Thanks,
> > Homesh
> >
> >
> > On Fri, Mar 25, 2022 at 4:08=E2=80=AFPM Christian Folini <
> > [email protected]> wrote:
> >
> > > Thanks for the updates. I do not immediately see why it's not working
> > > completely. But glad you have a working solution.
> > >
> > > Best,
> > >
> > > Christian
> > >
> > > On Fri, Mar 25, 2022 at 01:59:38PM +0530, homesh joshi wrote:
> > > > Dear Christian,
> > > >
> > > > I added setvar:tx.rule=3D1 in each rule and then added the followin=
g
> rule,
> > > > post which I am able to get 1 written in access logs ( via the
> %{waf} )
> > > for
> > > > the transactions which got blocked by Modsec. for other transaction=
s
> it
> > > is
> > > > missing and hence getting - in the logs. I was not able to directly
> set
> > > the
> > > > WAF=3D1 in the rules via setenv:waf=3D1
> > > >
> > > > SecRule TX:rule "@eq 1" "phase:5,pass,setenv:waf=3D1,id:'9001'"
> > > >
> > > > Will test this any update incase I face any challenge.
> > > >
> > > > Thanks,
> > > > Homesh
> > > >
> > > >
> > > > On Thu, Mar 24, 2022 at 6:35 PM Christian Folini <
> > > > [email protected]> wrote:
> > > >
> > > > > I suggest you add this to every rule that detects / blocks
> something.
> > > > > Thus not a SecAction, but attach the setenv to your existing
> SecRules
> > > > > where you want to see the flag.
> > > > >
> > > > > Alternatively, you can do a SecRule in phase 5 where you test the
> > > > > HTTP status and if it's 403, then you set the env.
> > > > >
> > > > > Good luck!
> > > > >
> > > > > Christian
> > > > >
> > > > > On Thu, Mar 24, 2022 at 05:02:20PM +0530, homesh joshi wrote:
> > > > > > Dear Christian,
> > > > > >
> > > > > > Thanks. I think this will work for me. However, can you please
> > > explain
> > > > > it a
> > > > > > bit more on how this works.
> > > > > > from your tutorial if i set up following rule
> > > > > >
> > > > > > # =3D=3D=3D ModSec performance calculations and variable export=
 (ids:
> > > 90100 -
> > > > > 90199)
> > > > > >
> > > > > > SecAction "id:90100,phase:5,pass,nolog,setenv:modsec=3D1"
> > > > > >
> > > > > > then for every access I see "1" in the access log.
> > > > > >
> > > > > > I think I will need to understand it more in order to use it.
> > > > > >
> > > > > > Kindly explain
> > > > > > 1) the configuration required for setenv by modifying each rule
> > > > > >
> > > > > > 2) the configuration required for more complicated scheme which
> you
> > > > > > are referring to
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Homesh
> > > > > >
> > > > > >
> > > > > > On Thu, Mar 24, 2022 at 11:52 AM Christian Folini <
> > > > > > [email protected]> wrote:
> > > > > >
> > > > > > > Hi there,
> > > > > > >
> > > > > > > On Thu, Mar 24, 2022 at 08:37:51AM +0530, homesh joshi wrote:
> > > > > > > > Thanks for the clarification.
> > > > > > > > I have already gone through excellent netnea.com tutorials.
> I
> > > have
> > > > > > > already
> > > > > > > > used some of the configuration from tutorial.I do not use
> crs.
> > > > > > >
> > > > > > > Thank you very much.
> > > > > > >
> > > > > > > > My objective here is that I want to get a flag in access lo=
g
> > > line if
> > > > > > > modsec
> > > > > > > > has taken any action on the transaction say simply it can b=
e
> a
> > > field
> > > > > like
> > > > > > > > modsec=3D1 or modsec=3D0. This wi help me in separating
> transactions
> > > > > which
> > > > > > > are
> > > > > > > > allowed.(modsec=3D0) So then it is easy to show these
> transactions
> > > in
> > > > > the
> > > > > > > > reporting system.
> > > > > > >
> > > > > > > I'd do a setenv then in the rules.
> > > > > > >
> > > > > > > ... "setenv:modsec=3D1"
> > > > > > >
> > > > > > > Similar to the way I set th various env variables in phase 5.
> You
> > > can
> > > > > > > simply
> > > > > > > add this to every rule you have. Or you set up a more
> complicated
> > > > > scheme
> > > > > > > and do it in the end in phase 5.
> > > > > > >
> > > > > > > Best,
> > > > > > >
> > > > > > > Christian
> > > > > > >
> > > > > > > >
> > > > > > > > Kindly suggest.
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > > Homesh
> > > > > > > >
> > > > > > > > On Thu, 24 Mar, 2022, 12:04 am Christian Folini, <
> > > > > > > > [email protected]> wrote:
> > > > > > > >
> > > > > > > > > HelloHomesh,
> > > > > > > > >
> > > > > > > > > Unfortunately, this is not how this works.
> > > > > > > > >
> > > > > > > > > A ModSecuriy variable is not automatically an environment
> > > variable.
> > > > > > > > > And on top, the ModSec variable "rule" is only available
> > > during the
> > > > > > > > > execution of the very rule (and there might be many, many
> > > rules).
> > > > > > > > >
> > > > > > > > > I suggest you read up on my free tutorials published at
> > > netnea.com
> > > > > .
> > > > > > > > > The one on logging and the ones on the Core Rule Set are
> > > proposing
> > > > > > > > > ways to achieve something along these lines.
> > > > > > > > >
> > > > > > > > > Best,
> > > > > > > > >
> > > > > > > > > Christian
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Wed, Mar 23, 2022 at 11:12:58PM +0530, homesh joshi
> wrote:
> > > > > > > > > > Hi All,
> > > > > > > > > >
> > > > > > > > > > Hope you all are well.
> > > > > > > > > >
> > > > > > > > > > I want to add the modsecurity variable e.g "rule.id"in
> the
> > > > > apache
> > > > > > > access
> > > > > > > > > > log via the extended format.
> > > > > > > > > > I set the following line in /etc/apache2/apache.conf
> > > > > > > > > >
> > > > > > > > > > LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\"
> > > > > > > \"%{User-Agent}i\"
> > > > > > > > > > %{ms}T %p %{Host}i %{UNIQUE_ID}e %{rule.id}e" extended
> > > > > > > > > >
> > > > > > > > > > However I am not getting the rule.id value in the
> access log
> > > > > line.
> > > > > > > > > >
> > > > > > > > > > Kindly suggest.
> > > > > > > > > >
> > > > > > > > > > Thanks,
> > > > > > > > > > Homesh
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > _______________________________________________
> > > > > > > > > > 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/
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > _______________________________________________
> > > > > > > > > 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/
> > > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > _______________________________________________
> > > > > > > > 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/
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > 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/
> > > > > > >
> > > > >
> > > > >
> > > > > > _______________________________________________
> > > > > > 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/
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > 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/
> > > > >
> > >
> > >
> > > > _______________________________________________
> > > > mod-security-users mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/mod-security-users
> > > > Commercial ModSecurity Rules and Support from Trustwave's SpiderLab=
s:
> > > > http://www.modsecurity.org/projects/commercial/rules/
> > > > http://www.modsecurity.org/projects/commercial/support/
> > >
> > >
> > >
> > > _______________________________________________
> > > 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/
> > >
>
>
> > _______________________________________________
> > 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/
>
>
>
> _______________________________________________
> 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/
>

--000000000000b6264705fea2ba7c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Christian,</div><div><br></div><div>Thanks for the=
 quick reply. OK so in detectonly mode also modsecurity rule evaluation wor=
ks the same.</div><div>Debug is a good idea. I have UAT so I can test. Will=
 let you know.</div><div><br></div><div>Thanks,</div><div>Homesh<br></div><=
/div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">O=
n Wed, Jun 21, 2023 at 3:03=E2=80=AFPM Christian Folini &lt;<a href=3D"mail=
to:[email protected]">[email protected]</a>&gt; wrote:<=
br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hey Homesh,<br>
<br>
Evaluation does indeed stop after a drop and there is a chance<br>
your rules only set the variables in question in a later phase.<br>
Really depends on your configuration.<br>
<br>
You can follow rule execution with the ModSecurity debug log, but beware<br=
>
it is very verbose.<br>
<br>
Generally, it is best to set variables for display in the access log only<b=
r>
in phase 5, which is also executed for requests that have been denied<br>
in an earlier phase.<br>
<br>
Best regards,<br>
<br>
Christian<br>
<br>
<br>
<br>
<br>
On Wed, Jun 21, 2023 at 01:14:04PM +0530, homesh joshi wrote:<br>
&gt; Hi All,<br>
&gt; <br>
&gt; With regards to my approach for logging the modsec variables in apache=
 log<br>
&gt; has worked for me for almost a year now.<br>
&gt; However, today when I enabled &quot;SecRuleEngine DetectionOnly&quot; =
for one of my<br>
&gt; websites. What I notice is that the apache logs are missing the right<=
br>
&gt; variable data.<br>
&gt; e.g I tested SQL injection and i was not able to see the relevant<br>
&gt; information in apache log which I typically get when &quot;SecRuleEngi=
ne On&quot;<br>
&gt; sample log for &quot;SecRuleEngine DetectionOnly&quot;<br>
&gt; 49.36.106.185 - - [21/Jun/2023:06:39:53 +0000] 200 23125 GET &quot;-&q=
uot;<br>
&gt; &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20=
100101<br>
&gt; Firefox/114.0&quot; 3154 443 <a href=3D"http://example.com" rel=3D"nor=
eferrer" target=3D"_blank">example.com</a> ZJKbOUfg7dWT82qCkvNySAAAAEU TLSv=
1.3<br>
&gt; TLS_AES_128_GCM_SHA256 0 4 L; &quot;/&quot; 15.24.15.205 39735 &quot;&=
quot; &quot;&quot; &quot;&quot; &quot;/&quot; 333762<br>
&gt; &quot;/?k=3D1%20or%201=3D1&quot;<br>
&gt; <br>
&gt; here rule id log is 333762 which is not the signature for SQL injectio=
n<br>
&gt; <br>
&gt; So my conclusion is, in &quot;SecRuleEngine On&quot; rule evaluation s=
tops when the<br>
&gt; first rule matches with the final action drop/block. Hence I am able t=
o get<br>
&gt; the right rule ID and other variable data. But when &quot;SecRuleEngin=
e<br>
&gt; DetectionOnly&quot; rule evaluation continues till the last rule and d=
ue to<br>
&gt; which my variable data gets changed as per the rules getting evaluated=
. Can<br>
&gt; I change this behaviour of modsecurity in Detectonly mode ? that it sh=
ould<br>
&gt; stop the evaluation when it matches the first rule with final action o=
f<br>
&gt; drop/block ( and not block/drop the transaction) ?<br>
&gt; <br>
&gt; Please suggest.<br>
&gt; <br>
&gt; Thanks,<br>
&gt; Homesh<br>
&gt; <br>
&gt; <br>
&gt; On Fri, Mar 25, 2022 at 4:08=E2=80=AFPM Christian Folini &lt;<br>
&gt; <a href=3D"mailto:[email protected]" target=3D"_blank">chris=
[email protected]</a>&gt; wrote:<br>
&gt; <br>
&gt; &gt; Thanks for the updates. I do not immediately see why it&#39;s not=
 working<br>
&gt; &gt; completely. But glad you have a working solution.<br>
&gt; &gt;<br>
&gt; &gt; Best,<br>
&gt; &gt;<br>
&gt; &gt; Christian<br>
&gt; &gt;<br>
&gt; &gt; On Fri, Mar 25, 2022 at 01:59:38PM +0530, homesh joshi wrote:<br>
&gt; &gt; &gt; Dear Christian,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I added setvar:tx.rule=3D1 in each rule and then added the f=
ollowing rule,<br>
&gt; &gt; &gt; post which I am able to get 1 written in access logs ( via t=
he %{waf} )<br>
&gt; &gt; for<br>
&gt; &gt; &gt; the transactions which got blocked by Modsec. for other tran=
sactions it<br>
&gt; &gt; is<br>
&gt; &gt; &gt; missing and hence getting - in the logs. I was not able to d=
irectly set<br>
&gt; &gt; the<br>
&gt; &gt; &gt; WAF=3D1 in the rules via setenv:waf=3D1<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; SecRule TX:rule &quot;@eq 1&quot; &quot;phase:5,pass,setenv:=
waf=3D1,id:&#39;9001&#39;&quot;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Will test this any update incase I face any challenge.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks,<br>
&gt; &gt; &gt; Homesh<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; On Thu, Mar 24, 2022 at 6:35 PM Christian Folini &lt;<br>
&gt; &gt; &gt; <a href=3D"mailto:[email protected]" target=3D"_bl=
ank">[email protected]</a>&gt; wrote:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; I suggest you add this to every rule that detects / blo=
cks something.<br>
&gt; &gt; &gt; &gt; Thus not a SecAction, but attach the setenv to your exi=
sting SecRules<br>
&gt; &gt; &gt; &gt; where you want to see the flag.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; Alternatively, you can do a SecRule in phase 5 where yo=
u test the<br>
&gt; &gt; &gt; &gt; HTTP status and if it&#39;s 403, then you set the env.<=
br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; Good luck!<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; Christian<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; On Thu, Mar 24, 2022 at 05:02:20PM +0530, homesh joshi =
wrote:<br>
&gt; &gt; &gt; &gt; &gt; Dear Christian,<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; Thanks. I think this will work for me. However, ca=
n you please<br>
&gt; &gt; explain<br>
&gt; &gt; &gt; &gt; it a<br>
&gt; &gt; &gt; &gt; &gt; bit more on how this works.<br>
&gt; &gt; &gt; &gt; &gt; from your tutorial if i set up following rule<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; # =3D=3D=3D ModSec performance calculations and va=
riable export (ids:<br>
&gt; &gt; 90100 -<br>
&gt; &gt; &gt; &gt; 90199)<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; SecAction &quot;id:90100,phase:5,pass,nolog,setenv=
:modsec=3D1&quot;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; then for every access I see &quot;1&quot; in the a=
ccess log.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; I think I will need to understand it more in order=
 to use it.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; Kindly explain<br>
&gt; &gt; &gt; &gt; &gt; 1) the configuration required for setenv by modify=
ing each rule<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; 2) the configuration required for more complicated=
 scheme which you<br>
&gt; &gt; &gt; &gt; &gt; are referring to<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; Thanks,<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; Homesh<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; On Thu, Mar 24, 2022 at 11:52 AM Christian Folini =
&lt;<br>
&gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:[email protected]" tar=
get=3D"_blank">[email protected]</a>&gt; wrote:<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Hi there,<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; On Thu, Mar 24, 2022 at 08:37:51AM +0530, hom=
esh joshi wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Thanks for the clarification.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; I have already gone through excellent <a=
 href=3D"http://netnea.com" rel=3D"noreferrer" target=3D"_blank">netnea.com=
</a> tutorials. I<br>
&gt; &gt; have<br>
&gt; &gt; &gt; &gt; &gt; &gt; already<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; used some of the configuration from tuto=
rial.I do not use crs.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Thank you very much.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; My objective here is that I want to get =
a flag in access log<br>
&gt; &gt; line if<br>
&gt; &gt; &gt; &gt; &gt; &gt; modsec<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; has taken any action on the transaction =
say simply it can be a<br>
&gt; &gt; field<br>
&gt; &gt; &gt; &gt; like<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; modsec=3D1 or modsec=3D0. This wi help m=
e in separating transactions<br>
&gt; &gt; &gt; &gt; which<br>
&gt; &gt; &gt; &gt; &gt; &gt; are<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; allowed.(modsec=3D0) So then it is easy =
to show these transactions<br>
&gt; &gt; in<br>
&gt; &gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; reporting system.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; I&#39;d do a setenv then in the rules.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; ... &quot;setenv:modsec=3D1&quot;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Similar to the way I set th various env varia=
bles in phase 5. You<br>
&gt; &gt; can<br>
&gt; &gt; &gt; &gt; &gt; &gt; simply<br>
&gt; &gt; &gt; &gt; &gt; &gt; add this to every rule you have. Or you set u=
p a more complicated<br>
&gt; &gt; &gt; &gt; scheme<br>
&gt; &gt; &gt; &gt; &gt; &gt; and do it in the end in phase 5.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Best,<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Christian<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Kindly suggest.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Thanks,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Homesh<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; On Thu, 24 Mar, 2022, 12:04 am Christian=
 Folini, &lt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:christian.folini@netne=
a.com" target=3D"_blank">[email protected]</a>&gt; wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; HelloHomesh,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Unfortunately, this is not how this=
 works.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; A ModSecuriy variable is not automa=
tically an environment<br>
&gt; &gt; variable.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; And on top, the ModSec variable &qu=
ot;rule&quot; is only available<br>
&gt; &gt; during the<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; execution of the very rule (and the=
re might be many, many<br>
&gt; &gt; rules).<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; I suggest you read up on my free tu=
torials published at<br>
&gt; &gt; <a href=3D"http://netnea.com" rel=3D"noreferrer" target=3D"_blank=
">netnea.com</a><br>
&gt; &gt; &gt; &gt; .<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; The one on logging and the ones on =
the Core Rule Set are<br>
&gt; &gt; proposing<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; ways to achieve something along the=
se lines.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Best,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Christian<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; On Wed, Mar 23, 2022 at 11:12:58PM =
+0530, homesh joshi wrote:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Hi All,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Hope you all are well.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; I want to add the modsecurity =
variable e.g &quot;<a href=3D"http://rule.id" rel=3D"noreferrer" target=3D"=
_blank">rule.id</a>&quot;in the<br>
&gt; &gt; &gt; &gt; apache<br>
&gt; &gt; &gt; &gt; &gt; &gt; access<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; log via the extended format.<b=
r>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; I set the following line in /e=
tc/apache2/apache.conf<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; LogFormat &quot;%h %l %u %t \&=
quot;%r\&quot; %&gt;s %O \&quot;%{Referer}i\&quot;<br>
&gt; &gt; &gt; &gt; &gt; &gt; \&quot;%{User-Agent}i\&quot;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; %{ms}T %p %{Host}i %{UNIQUE_ID=
}e %{<a href=3D"http://rule.id" rel=3D"noreferrer" target=3D"_blank">rule.i=
d</a>}e&quot; extended<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; However I am not getting the <=
a href=3D"http://rule.id" rel=3D"noreferrer" target=3D"_blank">rule.id</a> =
value in the access log<br>
&gt; &gt; &gt; &gt; line.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Kindly suggest.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Thanks,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Homesh<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; ______________________________=
_________________<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; mod-security-users mailing lis=
t<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:mod-security=
[email protected]" target=3D"_blank">[email protected]=
urceforge.net</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mod-secur=
ity-users" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.n=
et/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Commercial ModSecurity Rules a=
nd Support from Trustwave&#39;s<br>
&gt; &gt; &gt; &gt; SpiderLabs:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecur=
ity.org/projects/commercial/rules/" rel=3D"noreferrer" target=3D"_blank">ht=
tp://www.modsecurity.org/projects/commercial/rules/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecur=
ity.org/projects/commercial/support/" rel=3D"noreferrer" target=3D"_blank">=
http://www.modsecurity.org/projects/commercial/support/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; ___________________________________=
____________<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; mod-security-users mailing list<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:mod-security-user=
[email protected]" target=3D"_blank">[email protected]=
orge.net</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mod-secur=
ity-users" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.n=
et/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Commercial ModSecurity Rules and Su=
pport from Trustwave&#39;s<br>
&gt; &gt; &gt; &gt; SpiderLabs:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.o=
rg/projects/commercial/rules/" rel=3D"noreferrer" target=3D"_blank">http://=
www.modsecurity.org/projects/commercial/rules/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.o=
rg/projects/commercial/support/" rel=3D"noreferrer" target=3D"_blank">http:=
//www.modsecurity.org/projects/commercial/support/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; ________________________________________=
_______<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; mod-security-users mailing list<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:mod-security-users@lis=
ts.sourceforge.net" target=3D"_blank">[email protected].=
net</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"https://lists.sourceforge.net=
/lists/listinfo/mod-security-users" rel=3D"noreferrer" target=3D"_blank">ht=
tps://lists.sourceforge.net/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Commercial ModSecurity Rules and Support=
 from Trustwave&#39;s<br>
&gt; &gt; SpiderLabs:<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/pr=
ojects/commercial/rules/" rel=3D"noreferrer" target=3D"_blank">http://www.m=
odsecurity.org/projects/commercial/rules/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/pr=
ojects/commercial/support/" rel=3D"noreferrer" target=3D"_blank">http://www=
.modsecurity.org/projects/commercial/support/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; _____________________________________________=
__<br>
&gt; &gt; &gt; &gt; &gt; &gt; mod-security-users mailing list<br>
&gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:[email protected]=
urceforge.net" target=3D"_blank">[email protected]</=
a><br>
&gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"https://lists.sourceforge.net/list=
s/listinfo/mod-security-users" rel=3D"noreferrer" target=3D"_blank">https:/=
/lists.sourceforge.net/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; Commercial ModSecurity Rules and Support from=
 Trustwave&#39;s<br>
&gt; &gt; SpiderLabs:<br>
&gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/project=
s/commercial/rules/" rel=3D"noreferrer" target=3D"_blank">http://www.modsec=
urity.org/projects/commercial/rules/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/project=
s/commercial/support/" rel=3D"noreferrer" target=3D"_blank">http://www.mods=
ecurity.org/projects/commercial/support/</a><br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; _______________________________________________<br=
>
&gt; &gt; &gt; &gt; &gt; mod-security-users mailing list<br>
&gt; &gt; &gt; &gt; &gt; <a href=3D"mailto:[email protected]=
orge.net" target=3D"_blank">[email protected]</a><br=
>
&gt; &gt; &gt; &gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/lis=
tinfo/mod-security-users" rel=3D"noreferrer" target=3D"_blank">https://list=
s.sourceforge.net/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; &gt; &gt; Commercial ModSecurity Rules and Support from Trus=
twave&#39;s SpiderLabs:<br>
&gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/projects/com=
mercial/rules/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity=
.org/projects/commercial/rules/</a><br>
&gt; &gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/projects/com=
mercial/support/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecuri=
ty.org/projects/commercial/support/</a><br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; &gt; mod-security-users mailing list<br>
&gt; &gt; &gt; &gt; <a href=3D"mailto:[email protected].=
net" target=3D"_blank">[email protected]</a><br>
&gt; &gt; &gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo=
/mod-security-users" rel=3D"noreferrer" target=3D"_blank">https://lists.sou=
rceforge.net/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; &gt; Commercial ModSecurity Rules and Support from Trustwave=
&#39;s SpiderLabs:<br>
&gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/projects/commerci=
al/rules/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/=
projects/commercial/rules/</a><br>
&gt; &gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/projects/commerci=
al/support/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity.or=
g/projects/commercial/support/</a><br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; mod-security-users mailing list<br>
&gt; &gt; &gt; <a href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a><br>
&gt; &gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mod-=
security-users" rel=3D"noreferrer" target=3D"_blank">https://lists.sourcefo=
rge.net/lists/listinfo/mod-security-users</a><br>
&gt; &gt; &gt; Commercial ModSecurity Rules and Support from Trustwave&#39;=
s SpiderLabs:<br>
&gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/projects/commercial/ru=
les/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/proje=
cts/commercial/rules/</a><br>
&gt; &gt; &gt; <a href=3D"http://www.modsecurity.org/projects/commercial/su=
pport/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/pro=
jects/commercial/support/</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; mod-security-users mailing list<br>
&gt; &gt; <a href=3D"mailto:[email protected]" targe=
t=3D"_blank">[email protected]</a><br>
&gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mod-secur=
ity-users" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.n=
et/lists/listinfo/mod-security-users</a><br>
&gt; &gt; Commercial ModSecurity Rules and Support from Trustwave&#39;s Spi=
derLabs:<br>
&gt; &gt; <a href=3D"http://www.modsecurity.org/projects/commercial/rules/"=
 rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/projects/c=
ommercial/rules/</a><br>
&gt; &gt; <a href=3D"http://www.modsecurity.org/projects/commercial/support=
/" rel=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/projects=
/commercial/support/</a><br>
&gt; &gt;<br>
<br>
<br>
&gt; _______________________________________________<br>
&gt; mod-security-users mailing list<br>
&gt; <a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a><br>
&gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/mod-security-u=
sers" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/li=
sts/listinfo/mod-security-users</a><br>
&gt; Commercial ModSecurity Rules and Support from Trustwave&#39;s SpiderLa=
bs:<br>
&gt; <a href=3D"http://www.modsecurity.org/projects/commercial/rules/" rel=
=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/projects/comme=
rcial/rules/</a><br>
&gt; <a href=3D"http://www.modsecurity.org/projects/commercial/support/" re=
l=3D"noreferrer" target=3D"_blank">http://www.modsecurity.org/projects/comm=
ercial/support/</a><br>
<br>
<br>
<br>
_______________________________________________<br>
mod-security-users mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blan=
k">[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/mod-security-users"=
 rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/l=
istinfo/mod-security-users</a><br>
Commercial ModSecurity Rules and Support from Trustwave&#39;s SpiderLabs:<b=
r>
<a href=3D"http://www.modsecurity.org/projects/commercial/rules/" rel=3D"no=
referrer" target=3D"_blank">http://www.modsecurity.org/projects/commercial/=
rules/</a><br>
<a href=3D"http://www.modsecurity.org/projects/commercial/support/" rel=3D"=
noreferrer" target=3D"_blank">http://www.modsecurity.org/projects/commercia=
l/support/</a><br>
</blockquote></div>

--000000000000b6264705fea2ba7c--


--===============8658854852609852356==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============8658854852609852356==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
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/

--===============8658854852609852356==--