Forum Discussion
Decrypt AES Cookie outside of the load balancer
Whenever we see issues with a particular application server, our QA team decodes the F5 cookie to isolate the problematic server. However, after we implemented the encryption of the F5 cookies, they are no longer able to do so.
The obvious solution is to create an iRule that isolates our corporate IP segment on the LTM and decrypt the cookies. However, we would prefer to leave all cookies encrypted in our corporate environment and provide our QA folks with a utility they can use to decrypt the cookies.
Provided that I know the cookie secret, how can I mimic the 'decrypt' command outside of the load balancer? I have looked at various AES decryption tools but am unable to decrypt the cookies manually. If there's a resource that points to the exact specs the LTM uses to encrypt or covers API calls for this purpose, please let me know.
Any help would be appreciated, thanks!
-MZ
- hooleylistCirrostratusHi MZ,
- mzahir_65368AltostratusThanks Aaron
- spark_86682Historic F5 AccountWe're working on getting this documentation up, but it's quite a big task. We also hope to have code to encrypt and decrypt, but I can't 100% promise that. At any rate, it will be several weeks at the least before this is released. I know I've said that "we're working on it" before, but a lot progress has been made: the technical bits have been written up, and we're just working on getting them all digested into a single, approachable document.
- mzahir_65368AltostratusThanks. Even if there isn't a service or an exposed interface to do the decryption on the F5 itself, are the parameters of the current 'encrypt' function public? I could try writing a homegrown script to simulate it but wasn't sure if there was a private cert that cannot be extracted from the LTM.
- spark_86682Historic F5 AccountThere's no private cert or other similar information, no. The algorithms could be described sufficiently for you to independently write a decryption program, but they are complicated and non-standard. As I said, those details will eventually be forthcoming. If you absolutely need them now, then you can open a support case and they can be provided to you.
- mzahir_65368AltostratusThat was the initial plan but according to my network admins, the BIG-IP kept assigning a new cookie to the connection instead of decrypting the existing cookie and re-using it. It seemed that the logic to first search for and decrypt the existing cookies was missing. We weren't able to get it working with the iRule but all seems well with the http profile. If you're familiar with this issue or if there's something we missed in our documentation, please let me know.
- spark_86682Historic F5 AccountCould you elaborate on what didn't work for you? The following works for me using iRule encryption:
Here's some sample output:profile persist my_cookie { defaults from cookie cookie mode insert cookie name "pcookie" } rule my_rule { when HTTP_REQUEST { HTTP::cookie decrypt pcookie "mypassphrase" if { [HTTP::uri] == "/cookiedecrypter" } { HTTP::respond 200 content "Your cookie decrypted to: [HTTP::cookie value pcookie]" return } } when HTTP_RESPONSE { HTTP::cookie encrypt pcookie "mypassphrase" } } virtual http_vip { pool http_pool destination 10.3.3.127:http ip protocol tcp persist my_cookie rules my_rule profiles { http {} tcp {} } }
[root@v9dev1 root] telnet 10.3.3.127 80 Trying 10.3.3.127... Connected to 10.3.3.127 (10.3.3.127). Escape character is '^]'. GET /cookiedecrypter HTTP/1.1 Host: foobarbaz Cookie: pcookie=VjGAtYnPEtZUVxw/wVjg5d+fhs8e3MdS5FeP0Z7BOsQEWOSVH4C2fInFFaQB4T62plOUIBp3H1vEytw= HTTP/1.0 200 OK Server: BigIP Connection: Keep-Alive Content-Length: 47 Your cookie decrypted to: 3355509002.13173.0000
- hooleylistCirrostratusThanks for the example Spark. But telnet, really? How about netcat? :D
- spark_86682Historic F5 AccountMy lawn, get off of it. :D
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com