22-Nov-2022 22:50
We use APM for Horizon PCoIP gateway. We send login credential by POST to login webtop for Horizon VDI.
1st access is always OK. But if it is access 2nd or later times without closing MS edge browser, it failed. When IE was used, there was same issue, but we can launch IE with "noframemerging" option. So it was possible to start session without previous session cookie. With useing "noframemerging" option, the 2nd time access issue was avoided.
With MS Edge, there is no "noframemerging" , if webtop was accessed without closing all Edge, authenticaiotn with POSTed credential fails at 2nd time.
In order to avoid the problem, I made a jsp to access to https://[webtop URL]/my.logout.php3 first and redirect to webtop because I found that the my.logout.php3 delete MRHSession cookie. If MRHSession does not exist, Webtop login with Posted credential works all the time.
This works, however, we uses client side inspection by APM and client side inspection run times with this way. This is not nice because it takes time to run client side inspection.
Is there anyway to delete MRHSession cookie before accessing virtual server?
23-Nov-2022 10:09
Hi @Sakiy ,
You want to remove BIG-IP cookies from server-side connections and prevent the cookies from being sent to the origin web servers (OWS).
BIG-IP system cookies are unlikely to be relevant or problematic to an OWS that receives connections from the BIG-IP system.
==================================================================
You can create an iRule to remove an offending BIG-IP cookie from client-side connections.
To do so, you can use an iRules similar to the following examples:
iRule to remove AVR cookies
when HTTP_RESPONSE_RELEASE { set cookies [HTTP::cookie names] foreach aCookie $cookies { if {$cookiename starts_with "avr_"} { # Remove AVR Cookies HTTP::cookie remove $aCookie } } }
iRule to remove BIG-IP ASM cookies
when HTTP_RESPONSE_RELEASE { set cookies [HTTP::cookie names] foreach aCookie $cookies { if {$aCookie matches_regex {^TS(?:[0-9a-fA-F]{6,8})(?:$|_[0-9]+$)}} { # Remove ASM Cookies HTTP::cookie remove $aCookie } } }
Recommended Actions
Configure an iRule to remove a BIG-IP cookie from client-side connections
==================================================================
However, if your specific environment requires it, you can create an iRule to remove an offending BIG-IP cookie from server-side connections.
To do so, you can use iRules similar to the following examples:
iRule to remove AVR cookies
when HTTP_REQUEST_RELEASE {iRule to remove BIG-IP ASM cookies
when HTTP_REQUEST_RELEASE {MRHSession | BIG-IP APM Session ID 32 random hex digits. |
Session cookie design
The MRHSession cookie uses 32 randomly generated hex digits to generate the session ID. The MRHSession cookie is designed to ensure that only the BIG-IP APM controller and client can view the full session ID. The following safeguards ensure that a third party will not have access to any of the session IDs in use.
Set-Cookie: MRHSession=d896020385383db9ece7ac6d41f45923; path=/; secure
Note: Vulnerability scanners may detect that the secure flag is not set on all of our cookies. When the cookie is deleted, the secure flag is not set. The value of the cookie is set to deleted, and the expiration date is set to 01/01/1970 so the browser will discard the cookie.
For example:
Set-Cookie: MRHSession=deleted;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/
Each login to the BIG-IP APM system triggers new session cookies and a session ID to be generated.
You can configure the following options for BIG-IP APM cookies in the Configuration utility:
Note: Some vulnerability scanners may trigger a false positive based solely on session cookies not set with the Http Only attribute.
You can refer
Using an iRule to remove a BIG-IP cookie from server-side connections
Impact of procedure: Adding an iRule increases the resources used by the associated virtual server. Depending on the type and volume of the connections, this processing may introduce noticeable latency. F5 recommends testing any such changes in an appropriate environment.
For example, to remove AVR cookies, enter the following iRule:
when HTTP_REQUEST_RELEASE {
set cookies [HTTP::cookie names]
foreach aCookie $cookies {
if {$cookiename starts_with "avr_"} {
# Remove AVR Cookies
HTTP::cookie remove $aCookie
}
}
}
Note: For BIG-IP 12.x and earlier, on the Virtual Server List page, click Edit in the Resources column for the virtual server you want to use..
24-Nov-2022 09:16
Hi Sakiy,
I always use an iRule to fix APMs rather broken errorhandling if MRHSession cookies from previous APM sessions remain in browser. I believe you could use the very same iRule to fix your problems...
when HTTP_REQUEST {
# Fixing APMs complains when restart of APM sessions occur....
if { [HTTP::cookie value "MRHSession"] eq "" } then {
# APM cookie not present so we do nothing...
} elseif { [ACCESS::session exists -state_allow [HTTP::cookie value "MRHSession"]] } then {
# APM cookie present and already authenticated. Pass the cookie to APM...
} elseif { ( [HTTP::path] starts_with "/public/images/customization/" )
or ( [HTTP::path] starts_with "/saml/sp/profile/post/acs" ) } then {
# APM cookie present but not authenticated and requesting APM resources which are not hidden by APMs HUD filter. Do nothing...
} else {
# APM Cookie present but not authenticated. Killing existing APM session (if exists) and remove MRHSession cookie from the ongoing request...
ACCESS::session remove
HTTP::cookie remove "MRHSession"
}
}
The iRule simply removes inactive MRHSession cookies from those requests which are not hidden by APMs HUD Filter (aka. Request to APM itself).
Give it a try...
Cheers, Kai