Bug 1412591 - HAproxy router template is not setting cookies as secure if InsecureEdgeTerminationPolicy is empty or Redirect
Summary: HAproxy router template is not setting cookies as secure if InsecureEdgeTermi...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Networking
Version: 3.5.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Jacob Tanenbaum
QA Contact: zhaozhanqi
URL:
Whiteboard:
Depends On:
Blocks: 1429277 1429278
TreeView+ depends on / blocked
 
Reported: 2017-01-12 11:33 UTC by Javier Ramirez
Modified: 2022-08-04 22:20 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
: 1429277 1429278 (view as bug list)
Environment:
Last Closed: 2017-04-12 19:09:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Origin (Github) 12802 0 None None None 2017-02-06 18:42:11 UTC
Red Hat Product Errata RHBA-2017:0884 0 normal SHIPPED_LIVE Red Hat OpenShift Container Platform 3.5 RPM Release Advisory 2017-04-12 22:50:07 UTC

Description Javier Ramirez 2017-01-12 11:33:30 UTC
One customer discovered the following:

The cookie IS NOT flagged as secure (and it should) if:
- Route is edge and its insecureEdgeTerminationPolicy is empty. In this situation, it must be flagged as secure as it should be 100% equivalent to setting insecureEdgeTerminationPolicy explicitly to "None".
- Route is edge and its insecureEdgeTerminationPolicy is "Redirect". Cookies in this situation must be flagged as secure because, although an HTTP connection is admitted, a redirect is immediately issued. So the cookie is never set by HTTP and it does not make any sense to send the cookie via HTTP if you are going to receive a redirect and you are not going to attack any application instance via HTTP (thus, there is nothing to stick to).

While investigating the topic, we found out that the following part of the HAProxy router template was the responsible of this behaviour:

{{ if and (eq $cfg.TLSTermination "edge") (eq $cfg.InsecureEdgeTerminationPolicy "None") }}
cookie {{$cfg.RoutingKeyName}} insert indirect nocache httponly secure
{{ else }}
cookie {{$cfg.RoutingKeyName}} insert indirect nocache httponly
{{ end }}

As we can see, a "Redirect" InsecureEdgeTerminationPolicy is not considered at all and if it is empty, it does not equal to "None" (because it is empty) and falls back to the "else" clause without secure flag.

We have custom templates for other reasons, so we replaced that code fragment with:

{{ if and (eq $cfg.TLSTermination "edge") (ne $cfg.InsecureEdgeTerminationPolicy "Allow") }}
cookie {{$cfg.RoutingKeyName}} insert indirect nocache httponly secure
{{ else }}
cookie {{$cfg.RoutingKeyName}} insert indirect nocache httponly
{{ end }}

As you can see, now we flag as secure edge routes that do not have a InsecureEdgeTerminationPolicy "Allow" (i.e. They are "Redirect" or "None"/empty) and we do not flag them as secure for routes without TLS and edge routes with InsecureEdgeTerminationPolicy "Allow" (i.e. those expected to forward HTTP traffic to application instances). Note that cookies for "Reencrypt" routes are handled elsewhere in the template.


What the customer would like is to confirm that their fixes/improvements in the custom templates are valid and canb be incorporated to the official HAProxy router template.

Comment 1 Troy Dawson 2017-02-08 22:36:01 UTC
This has been merged into ocp and is in OCP v3.5.0.18 or newer.

Comment 3 zhaozhanqi 2017-02-09 07:03:43 UTC
Verified this bug on OCP v3.5.0.18

When creating edge route with --insecure-policy='Redirect' or --insecure-policy='None',the cookie will be added `secure`

and if --insecure-policy='Allow' , will no secure.

Comment 5 errata-xmlrpc 2017-04-12 19:09:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:0884


Note You need to log in before you can comment on or make changes to this bug.