unblock
19 TopicsASM issue, need to return HTTP 500 to client in certain cases
I've written a script that captures the "Content-Type" header from requests. In the event that ASM blocks the request, I need to respond to the client with one of three types of responses (I'm using the ASM_REQUEST_BLOCKING event): If Content-Type = text/xml then send back a SOAP error with HTTP 200 If Content-Type = application/json then return HTTP 500 All others return the default ASM response with HTTP 200. Cases 1 & 3 are handled, but I can't figure out how to force an HTTP 500 status to be returned to the client. HTTP_RESPONSE doesn't fire when ASM blocks. Thanks for your advice.Solved4KViews0likes6CommentsASM: "Illegal Request"
I have come across a weird problem. A user access was blocked, with a support ID displayed. After searching the event log withe the support ID, I found that there was no learning suggestion for the access request, and I could not "accept" the request: the text shown when having the mouse over the grayed-out button of "Accept" was "there was no violation". I had to configure "never block this IP address" to allow the request through. And the log entry showed that this was an "illegal" request. Is there a way to allow an "illegal" request through in this situation? The IP address based solution is only temporary as the user was on a dynamic address.1.8KViews0likes3CommentsTurn off File type check for a specific URL
Hi, we have some dynamic urls that from time to time will include a fullstop. Is is possible to disable only the illegal file type check for uris that start with "/foo/foo1/"? I would not want to disable ASM entirely, just the illegal file type check. Or if there is another way to deal with this scenario to prevent client selections with fullstop in it from being interpreted as an illegal file type, it would be great to hear how others are working with this type of scenario. Thank you.Solved1.4KViews0likes6CommentsGenerating irule logs, emails and reports for Shadow API Endpoints on the F5 BIG-IP AWAF/ASM device
Nowadays the F5 XC Distributed Cloud is all the rage for shadow API discovery and schema learning as seen in https://docs.cloud.f5.com/docs/how-to/app-security/apiep-discovery-control and for a good reason! The F5 BIG-IP does not have this option but with a little bit of irule code the shadow API endpoints can be discovered by creating an API security policy with irules enabled. As by default new URL will not be learned, you can enable this as to not only see the logs but also the learning suggestions. In the future there could be integration between F5 XC API protection and F5 AWAF/ASM to generate the OpenAPI/Swagger file by sending the API data from the F5 BIG-IP to the F5 XC Distributed Cloud WAAP API Protection service that will generate the OpenAPI/Swagger file, using the XC receiver features. You can review the discussion below: https://community.f5.com/t5/technical-forum/export-big-ip-awaf-urls-to-swagger-file/td-p/319845 Edit: Now there is an official article about sending the API traffic from F5 BIG-IP to XC for Swagger/OpenAPI file generation: https://community.f5.com/t5/technical-articles/apis-everywhere/ta-p/320688 This is limited to what F5 XC can do and there is no way to generate a new Swagger/OpenAPI files based on accepted new endpoints but it is still a good option for on-prem implementations. The below code is a modification of the code at https://clouddocs.f5.com/api/irules/ASM__unblock.html and https://clouddocs.f5.com/api/irules/ASM_REQUEST_DONE.html CODE: when ASM_REQUEST_DONE { log local0. "[ASM::violation_data] uri=[HTTP::uri]" set x [ASM::violation_data] for {set i 0} { $i < 7 } {incr i} { switch $i { 0 { } 1 { } 2 { } 3 { } 4 { } 5 { } 6 { } }} if {([lindex $x 5] contains "ATTACK_TYPE_FORCEFUL_BROWSING")} { log local0. "Illegal API endpoint detected for uri=[HTTP::uri]" ASM::unblock } } The ASM::unblock is added as if we want to just monitor and discover undocumented or shadow API but to have the ASM policy in blocking mode for anything else. Also just the Illegal URL violation still can be stopped under Traffic Learning but Alarm and Learn can be left enabled. Also custom SNMP and email notifications can be configured based on this message and for more info you can see https://my.f5.com/manage/s/article/K3727 and https://my.f5.com/manage/s/article/K3667 . Even ASM reports can be generated for this data. The same can be done for parameters and Methods !1.1KViews0likes0CommentsException for GeoBlocked Country. Without Allow-Listing a specific IP
We are geo-blocking users from China, but some users are trying to ship goods and needs to see access certain guidelines regarding the types of goods that are allowed. The security policy that governs access to this application also applies to several other applications. I am concerned that allow-listing the specific IP addresses of those users could potentially open up a security loophole. We are in a bit of pickle and exploring the best way to address this issue without compromising security protocols. Any suggestions would be appriciated. I tinkered and composed this iRule. I am uncertain about the last part... (ignore private.url as I don't want to post it publcily here) when CLIENT_ACCEPTED { # Initialize a variable to hold the block status set blocked_ip 1 } when HTTP_REQUEST { # Check if the request is for the specific full URL and the client is from China if { ([HTTP::host] equals "private.url") and ([HTTP::uri] equals "/substances-search/Substance?lang=en") and ([whereis [IP::client_addr] country] equals "CN") } { # Tentatively allow access, pending the ASM check set blocked_ip 0 } } when ASM_REQUEST_DONE { # Check if the request is blocked by ASM if { [ASM::status] eq "blocked" } { # If it's due to geolocation and the specified conditions are met, unblock if { [ASM::violation names] contains "VIOLATION_ILLEGAL_GEOLOCATION" and $blocked_ip == 0 } { ASM::unblock log local0. "[ASM::violation_data] unblocked for [IP::client_addr]" } else { # For other violations, ensure the request remains blocked set blocked_ip 1 } } } when HTTP_RESPONSE { # If the block status is true, respond with a 403 Forbidden if { $blocked_ip == 1 and [ASM::status] eq "blocked" and ![ASM::violation names] contains "VIOLATION_SQL_INJECTION" } { HTTP::respond 403 content "Access denied" "Content-Type" "text/plain" "Connection" "close" } }Solved985Views0likes2CommentsHow could I exclude Vulnerability scanners from Session Tracking?
I have enabled session tracking on an application and it has quickly blocked my vulnerability scanner. Of course this is "scan interference" and makes the results invalid. The options on the IP Address Exceptions page allow me to "Never Block" the IP , but then I get false results and ASM is not providing any protection. Because I've seen that when blocked by Session Tracking the other violations were still recorded in the logs I thought this may work as an iRule when ASM_REQUEST_DONE { if { ([ASM::violation count] equals 1) && ([ASM::violation names] eq "VIOL_SESSION_AWARENESS") && ([IP::addr [IP::client_addr] equals n.n.n.n]) } { ASM::unblock } } But it didn't, the connections were still blocked when the session tracking count was reached. Can anyone suggest something to try next?Solved922Views0likes6CommentsASM::unblock not working for specific violation
Hello there, I set an iRule for ASM that should unblock a specific violation: when ASM_REQUEST_DONE { set asm_support_id [ASM::support_id] if { $uri starts_with "/my/uri" and [ASM::violation names] contains "VIOL_ENCODING" } then { ASM::unblock } } This rule is not triggered for that specific violation. What am I missing? I would also like to point out that if I remove the second part of the IF and leave just the uri match, the rule triggers just fine. I am 100% sure the violation I am targeting is correct. Any clues on what is wrong with it? Thank you!879Views1like6CommentsCMS causing False Positives
Hello, I am recently seeing many false positives relating to CMS (Kentico EMS) on one of my F5 ASM policies. As it is CMS and marketing department would be editing web sites etc. we are seeing many requests being blocked due to various injection attack signatures. The users, and app developers, are getting frustrated with the amount of false positives. Is there any recommended set up such as which attack signatures to include in the learning and blocking settings for CMS? Trawling through the traffic learning it's hard to determine which attack signature suggestions to disable as difficult to ascertain which as true false positives and which are actual injection attempts. We are running a manual policy.Solved806Views0likes1CommentiRule to allow HTTP Error code through ASM policy
Hello, I have an ASM policy applied to a virtual server. The ASM policy is configured to block HTTP 500 response codes. I would like to write an irule that would allow HTTP 500 to be returned to clients that are in a pre-defined Data group list. when HTTP_RESPONSE { if { [HTTP::status] eq "500" } { if { [class match [IP::client_addr] equals DATA_GROUP_LIST] } { commands to allow HTTP 500 response } } I'm actually trying to figure out if this is even possible. or are response codes all-or-nothing when enforced via an ASM policy? Any help would be greatly appreciated. Thank you. ChrisSolved737Views0likes2Comments