12-Aug-2021 07:37
Is it possible to prevent ASM from blocking responses when there's a specific HTTP header present in the HTTP response? Let's say we block responses with HTTP status code 500 by default in our security policies, but is it possible to circumvent the ASM from blocking when the status code is 500 AND Content-Type = "application/problem-handled-return-to-client"? If possible, I'd like this to be generic so I can reuse the same solution in different VS's without changing code.
Solved! Go to Solution.
13-Aug-2021
01:07
- last edited on
04-Jun-2023
19:20
by
JimmyPackets
Try with an iRule. use appropriate asm policy name.
Use logging to see if condition is getting triggered and then it can be disabled.
when HTTP_RESPONSE {
ASM::enable "/common/asm_policy"
if { ([HTTP::status] == 500) and ([HTTP::header value Content-Type] eq "application/problem-handled-return-to-client") }{
log local0.info "disable asm"
ASM::disable
return
}
}
13-Aug-2021
01:07
- last edited on
04-Jun-2023
19:20
by
JimmyPackets
Try with an iRule. use appropriate asm policy name.
Use logging to see if condition is getting triggered and then it can be disabled.
when HTTP_RESPONSE {
ASM::enable "/common/asm_policy"
if { ([HTTP::status] == 500) and ([HTTP::header value Content-Type] eq "application/problem-handled-return-to-client") }{
log local0.info "disable asm"
ASM::disable
return
}
}
17-Aug-2021
03:03
- last edited on
24-Mar-2022
01:06
by
li-migration
Thanks for your answer, .
I read about the HTTP_RESPONSE event in the F5 docs, https://clouddocs.f5.com/api/irules/HTTP_RESPONSE.html, but ASM::disable isn't mentioned as an available command. Is this command list complete?
I also wonder, is it possible to extract ASM policy name from the HTTP_REQUEST? It makes it easier to make a generic iRule.
27-Aug-2021 06:50
The solution for my last question above can be found here; https://devcentral.f5.com/s/question/0D51T00008nsiZGSAY/irule-to-extract-asm-policy-name
18-Aug-2021 12:41
ASM::disable is valid command in HTTP_RESPONSE event.
If you want to use generic one, you can remove ASM::enable command at the start of the iRule and test it ASM gets enabled in the response for every and all subsequent events after a match. But F5 recommends to enable it before disabling for specific traffic.
19-Aug-2021
12:52
- last edited on
21-Nov-2022
16:06
by
JimmyPackets
Something isn't working as expected. I use this simple code which I cut and pasted from https://clouddocs.f5.com/api/irules/HTTP_RESPONSE.html and made only a small change inside the IF-statement :
when HTTP_RESPONSE {
if { [HTTP::status] contains "500"} {
log local0.debug "HTTP_RESPONSE - err: 500"
}
}
But when I make a request that triggers a 500 status code then I get this message in the LTM log:
<date removed> <host removed> err tmm[14816]: 01220001:3: TCL error: /Common/asm-override <HTTP_RESPONSE> - Can't call after responding - ERR_NOT_SUPPORTED (line 1) invoked from within "HTTP::status"
We are using v15.1.2.1 with an Eng Hotfix.
22-Aug-2021 03:26
Can't call after responding means most probably an event overlap is occurring. Checkout if there is another rule or policy attached to VS with HTTP_RESPONSE event.
If so, combine both HTTP_RESPONSE event content in one iRule.
Hope this helps
23-Aug-2021
03:39
- last edited on
24-Mar-2022
01:06
by
li-migration
Thank you! When I browsed through the other iRules, then I found an iRule that was executed before this one. Thanks a lot! 🙂