Forum Discussion

Jinshu's avatar
Jinshu
Icon for Cirrus rankCirrus
Jul 27, 2016

Custom ASM block for HTTP methods

Hi,

I want to block all HTTP methods except GET using ASM. I amk using below irule for blocking and raise ASM violation but somehow irule execution is getting failed while testing with HTTP method POST. I'm unable to find the reason for this failure. Can somebody help please?

when HTTP_REQUEST {
    set reqBlock 0
    if { ( [HTTP::method] equals "GET" ) } {
        return
    } else {
        set reqBlock 1
    }
}   
when ASM_REQUEST_DONE {

  if { $reqBlock == 1} {
    ASM::raise VIOLATION_FORBIDDEN_GET_PATH
  }
}

7 Replies

  • how does it fail? what error do you get? there is an ASM policy on the virtual server right?

     

  • Looks like a mashup of my custom violation iRule. Tehcnically, it should work - maybe you have cache of previous results (webacceleration profile)?

    This should do the trick in v11.x

    when HTTP_REQUEST {
      set reqBlock 0
      if { not ( [HTTP::method] eq "GET" ) } {
        set reqBlock 1
      }
    }   
    when ASM_REQUEST_DONE {
      if { $reqBlock == 1} {
        ASM::raise VIOLATION_FORBIDDEN_METHOD
      }
    }
    

    Also note that if you can upgrade to v12.1, you will get a better built-in control over allowed http methods per URL (also works with wildcard URLs):

    https://support.f5.com/kb/en-us/products/big-ip_asm/releasenotes/product/relnote-asm-12-1-0.html

    Enforcing a method on a URL

     

    You can define a list of allowed and disallowed methods, for each URL, that will override the list defined on the security policy level.
  • Hi,

     

    I have found the issue. It was the custom violation causing the issue. I have modified it and it worked like a champ.

     

    btw, I'm using 11.5 version.

     

    Thanks guys for your help.

     

    -Jinshu

     

  • Hi

     

    You should not need an iRule for this one...

     

    Check out Security > Application Security > Headers > Methods

     

    Sincerely

     

  • Hi Yoann, We cant modify the default GET and POST from there...

     

  • Hi

     

    When I see the irule I am not sure why the policy setting is not enough... But anyhow, have you also checked the box "Trigger ASM iRule Events" in the policy settings ?

     

    Yoann

     

  • Yes. I have solved the issue. It was the custom violation causing the issue. I have modified it and it worked.

     

    Thank you.