ASM_REQUEST_BLOCKING not being triggered in iRule

Anyone here faced the issue that “ASM_REQUEST_BLOCKING” not being triggered in LTM iRule ?

The “Trigger ASM iRule Events Mode” is set to normal in ASM policy

Running v15.1.0.5

New setup, never tried this before ..

Thanks

to be sure you are creating violations right?

different types?

Yes

I mean I do get the access rejected page, but I get the default page, and I need to customize it.

like described here: myF5

and you have the irule associated with the virtual server that also has the ASM profile with the “Trigger ASM iRule Events Mode” enabled?

can you add some log statements to your iRule events to see if they get triggered at all?

does the ltm log show something related at the moment?

Yes It is the same VS.

And yes I tried to add log.local to the iRule but nothing detected at the section of “ASM_REQUEST_BLOCKING”..

Does anyone has any idea on how to solve this?

only thing i saw in previous questions is that it didn’t trigger for all types of violations, the example there was data guard which didnt trigger it. you might try a couple of different violation types to rule that out.

but if that is ok and if you got a the configuration setup correctly (which you seem to have) and it still doesnt work then it could be a bug, best to have F5 support have a look at your configuration and determine if it is a bug.

The thing with F5 technical support is tey do not support iRules.

Only in rare cases. or if you have some sort of support level contract …

they don’t support full debugging / writing of iRules, but they will in my experience assist in something like this or if something clearly fails. specially when you are just following F5 articles and do something relatively simple as this. i would certainly try them.

Have you tried using ASM_REQUEST_DONE instead of ASM_REQUEST_VIOLATION? ASM_REQUEST_VIOLATION was deprecated in v11.5 and replaced with ASM_REQUEST_DONE.

If I do that then my website will not be reached and I’ll get this browser error message:

This page isn’t working
my.domain.com didn’t send any data.
ERR_EMPTY_RESPONSE

I see the iRule triggered but with errors in /var/log/ltm :

Oct 12 07:30:07 My-F5 info tmm5[14584]: Rule /Common/ASM_custom_block_page_v3 <ASM_REQUEST_DONE>: hello world
Oct 12 07:30:08 My-F5 err tmm5[14584]: 011f0016:3: http_process_state_prepend - Invalid action:0x10a010 Server sends too much data. serverside (172.26.137.34:443 -> 172.26.137.46:6759) clientside (1.2.3.4:62170 -> 172.26.137.41:443) (Server side: vip=/Common/myserver_test profile=http pool=/Common/srv-myserver server_ip=172.26.137.34)

how is your full iRule looking now?

if you only test with the example from F5 Cloud Docs

what happens?

This is my current iRule

when HTTP_REQUEST {
   set requri "https://[HTTP::host][HTTP::uri]"
}
when ASM_REQUEST_DONE {
log local0. "hello world"
#log local0. "Request from [IP::client_addr] blocked: [HTTP::uri]"
     set asm_support_id [ASM::support_id]
     HTTP::header remove Content-Length
     HTTP::header insert header_1 value_1
     set client_ip [IP::client_addr]
     set response "<html>
                        <head>
                           <title>Request Rejected</title>
                        </head>
                        <body>
                            The requested URL was rejected. Please consult with your administrator.<br><br>
                            Your support ID is: $asm_support_id<br><br><a href='javascript:history.back();'>Go Back</a><br><br>
                            Your URL is: $requri
                            Your client IP is: $client_ip
 
                        </body>
                    </html>"
     ASM::payload replace 0 [ASM::payload length] ""
     ASM::payload replace 0 0 $response
 
}

so that was an interesting one, took me a few tries to get something working.

the cloud docs suggest that ASM::payload works in most of the ASM events, but for me it only seems to work in ASM_REQUEST_BLOCKING, well certainly the replace only works there.

there is also a known issue which shouldn’t be an issue for 14.1 but is for me: myF5

so if you set the irule events mode to normal then you use ASM_REQUEST_DONE (instead of the two other ones) but can only check for what happened.

the replacing still has to happen in ASM_REQUEST_BLOCKING.

can you try something like this and show the ltm log output?

when ASM_REQUEST_DONE {
 
  log local0. "req done"
  
  set x [ASM::violation_data]
 
  for {set i 0} { $i < 7 } {incr i} {
      switch $i {
      0         { log local0. "violation=[lindex $x $i]" }
      1         { log local0. "support_id=[lindex $x $i]" }
      2         { log local0. "web_application=[lindex $x $i]" }
      3         { log local0. "severity=[lindex $x $i]" }
      4         { log local0. "source_ip=[lindex $x $i]" }
      5         { log local0. "attack_type=[lindex $x $i]" }
      6         { log local0. "request_status=[lindex $x $i]" }
 
   }}
 
}
 
when ASM_REQUEST_BLOCKING {
 
  log local0. "req block"
  
  ASM::payload replace 0 [ASM::payload length] ""
  ASM::payload replace 0 0 "abcdefghi"
  HTTP::header replace Content-Length [ASM::payload length]
 
}

this is 14.1.2.3 (lab) btw, so things might have changed in 15.1 although i can’t find details on that.

Hi

I launched this iRule and tried to create violation, the ASM blocked me , but the ltm log doesn’t show anything related to “req block” log. Here is the output:

Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: req done
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: violation=
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: support_id=9864890563438358212
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: web_application=/Common/MyServer
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: severity=Informational
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: source_ip=1.2.3.4
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: attack_type=
Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: request_status=clear
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: req done
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: violation=
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: support_id=9864890563489517902
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: web_application=/Common/MyServer
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: severity=Informational
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: source_ip=1.2.3.4
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: attack_type=
Oct 26 08:04:49 My-F5 info tmm7[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: request_status=clear

because you didnt trigger a violation according to the output. violation is empty and it shouldn’t be

yours:

Oct 26 08:04:49 My-F5 info tmm2[14584]: Rule /Common/devcentral_irule <ASM_REQUEST_DONE>: violation=

test from me:

Oct 22 13:40:01 bigip-01 info tmm2[20840]: Rule /Common/irule-asm_blockpage <ASM_REQUEST_DONE>: violation=VIOLATION_REQ_LEN,VIOLATION_OBJ_LEN,VIOLATION_OBJ_TYPE

there is no violation information at yours and there should be.

so you have to check if everything is setup correctly, perhaps multiple ASM policies and not having the right one here or … it is difficult to determine what it could be from a distance.

reaching out to f5 support would be a good idea if you don’t see an issue, it might be a bug. im running 14.1 and don’t have 15.1 quickly available.

But I did trigger a violation

I received also a support id and ASM blocked my request

I will try to reach out the support soon

Thanks :slight_smile:

can you lookup that support id and share the output (redacted where needed)?

Sure

Attached

ah interesting, a redirect violation, that might be a reason, as it is in the response.

can you try with another kind of violation?