Forum Discussion

Joe_Pipitone's avatar
Joe_Pipitone
Icon for Nimbostratus rankNimbostratus
Jan 30, 2020
Solved

Samesite cookies on 1600's

We have 1600's running 11.6.0 (End of life) and we are wondering if anyone happens to know if these support the new SameSite cookie policy settings as outlined in this article: https://devcentral.f5....
  • Simon_Blakely's avatar
    Feb 02, 2020

    You cannot fix SameSite cookie issues on 11.6.x with LTM policies - the required feature are not supported.

    You will need to use the irule suggested in that article.

    However, if your pool members have addressed the SameSite cookie attributes, then that irule may not be needed.

    If the BigIP is adding cookies to the response (persistence cookies, ASM cookies, APM portal cookies), then those cookies will not have the correct attributes set.

    In this case, you need to that irule, but the event needs to be HTTP_RESPONSE_RELEASE

    BigIP cookies are added after HTTP_RESPONSE (which is just the response from the pool member), so to modify the BigIP cookies, you need to change them just before the final response is released to the client.

    when HTTP_RESPONSE_RELEASE {
        # Set-Cookie header can occur multiple times, treat as list
        set num [HTTP::header count Set-Cookie]
        if {$num > 0} {
            foreach set_cookie [HTTP::header values Set-Cookie] {
                # only modify if header does not have SameSite attribute
                set foundSameSite [string match -nocase "*SameSite*" $set_cookie ]
                if {[expr {!$foundSameSite} ]} {
                    set set_cookie [concat $set_cookie "; SameSite"]
                }
                # collect modified and unmodified values in list newcookies
                lappend newcookies $set_cookie
            }
            if {$num == 1} {
                # overwrite existing
                HTTP::header replace Set-Cookie [lindex $newcookies 0]
            } else {
                # remove and replace
                HTTP::header remove Set-Cookie
                foreach set_cookie $newcookies {
                    HTTP::header insert Set-Cookie $set_cookie
                }
            }
        }
    }