Skip to content

haproxy Cookie id leaks information about software #8615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2016

Conversation

pecameron
Copy link
Contributor

@pecameron pecameron commented Apr 22, 2016

Resolves: bz1318796
haproxy now md5 hashes the project_routename to generate the Cookie ID.

Signed-off-by: Phil Cameron [email protected]

@pecameron
Copy link
Contributor Author

@openshift/networking PTAL
This is the same as the previous PR(8611) without the unwanted merge commit at the head.

@pecameron
Copy link
Contributor Author

pecameron commented Apr 22, 2016

@openshift/networking The previous PR (8611) comments by @marun (and ramr) concerned whether or not we need the PREFIX/SUFFIX at all. This is part of an on-going email chain. Also, there needs to be a test case and doc changes.

@marun
Copy link
Contributor

marun commented Apr 22, 2016

@pecameron It would have been preferable to edit the previous branch/PR rather that creating a new one. I recommend reading up on git's 'interactive rebase' and 'cherry picking' capabilities the next time you run into this kind of problem.

}

// Possibly hash the name for later use in obsuring cookie ID
if os.Getenv("COOKIE_PREFIX_MAIN") + os.Getenv("COOKIE_PREFIX_EDGE") + os.Getenv("COOKIE_PREFIX_REENCRYPT") != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code used from inside the router needs to be parameterized from the router cmd and passed as members. Only values that are solely used within the template should be environment variables (basically, no os.Getenv except in templates or in top level CLI).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do it with a flag (in lieu of 3 env vars) that does this equivalent of "obfuscating" the cookie name. Or maybe even just do it by default?
Maybe hash it based on the tls.Termination + backendKey as it would have the type of route as well. Something like:

    Hash:  fmt.Sprintf("%s_%s", tls.Termination, backendKey),  
  }  
// ...  
if  r.TheObsfucatorFlagName { // replace flag name w/ the real one.  
   config.Hash = fmt.Sprintf("%x", md5.Sum([]byte(config.Hash)))  
}  

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 04/22/2016 06:21 PM, Clayton Coleman wrote:

In pkg/router/template/router.go
#8615 (comment):

@@ -398,6 +399,12 @@ func (r *templateRouter) AddRoute(id string, route *routeapi.Route, host string)
config := ServiceAliasConfig{
Host: host,
Path: route.Spec.Path,

  •   Hash: backendKey,
    
  • }
  • // Possibly hash the name for later use in obsuring cookie ID
  • if os.Getenv("COOKIE_PREFIX_MAIN") + os.Getenv("COOKIE_PREFIX_EDGE") + os.Getenv("COOKIE_PREFIX_REENCRYPT") != "" {

Code used from inside the router needs to be parameterized from the
router cmd and passed as members. Only values that are solely used
within the template should be environment variables (basically, no
os.Getenv except in templates or in top level CLI).


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/8615/files/efbfa149db72f9378c1378793e9db0263996d6f0#r60810832

Thanks for taking a look. Is it OK to pass the environment variables
through the dc?I will make the changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pecameron as the @eparis commented and based on the later comments, just set the hash to something like:
config.Hash = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s_%s", tls.Termination, backendKey)))) unconditionally and then use it `{{cfg.Hash}}`` as the cookie name in the template.
That way you don't need any environment variables.
And maybe use

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 04/25/2016 02:20 PM, Ram Ranganathan wrote:

In pkg/router/template/router.go
#8615 (comment):

@@ -398,6 +399,12 @@ func (r *templateRouter) AddRoute(id string, route *routeapi.Route, host string)
config := ServiceAliasConfig{
Host: host,
Path: route.Spec.Path,

  •   Hash: backendKey,
    
  • }
  • // Possibly hash the name for later use in obsuring cookie ID
  • if os.Getenv("COOKIE_PREFIX_MAIN") + os.Getenv("COOKIE_PREFIX_EDGE") + os.Getenv("COOKIE_PREFIX_REENCRYPT") != "" {

@pecameron https://github.com/pecameron as the @eparis
https://github.com/eparis commented and based on the later comments,
just set the hash to something like:
|config.Hash = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s_%s",
tls.Termination, backendKey))))| unconditionally and then use it
|{{cfg.Hash}}|` as the cookie name in the template.

That way you don't need any environment variables.
And maybe use


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/8615/files/efbfa149db72f9378c1378793e9db0263996d6f0#r60961740

Hi Ram,
Thanks! How do I test this new feature in
pkg/router/template/router_test.go?
Thanks,
phil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the integration tests in test/integration/router_test.go - what you need to do is probably similar to TestRouterPathSpecificity - check that the response back from the client has a cookie + its name is "mangled".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to add - you have to check that the HTTP response has a cookie by looking at the HTTP headers, so you will also need some change to the getRouter helper function used in the test - as that currently returns only the content (not the headers).

@eparis
Copy link
Member

eparis commented Apr 23, 2016

I argue that we don't need any of this stuff. Just make the entire thing be an opaque hash. I do not believe there is any point to having any human readable words in here.

@smarterclayton
Copy link
Contributor

smarterclayton commented Apr 23, 2016 via email

@pecameron
Copy link
Contributor Author

On 04/22/2016 05:19 PM, Maru Newby wrote:

@pecameron https://github.com/pecameron It would have been
preferable to edit the previous branch/PR rather that creating a new
one. I recommend reading up on git's 'interactive rebase' and 'cherry
picking' capabilities the next time you run into this kind of problem.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8615 (comment)

I asked for help on how to do this, none was forthcoming so I figured
something out. Sorry I got it wrong.

@pecameron
Copy link
Contributor Author

I mad the discussed changes, PTAL
@openshift/networking

@@ -450,6 +451,8 @@ func (r *templateRouter) AddRoute(id string, route *routeapi.Route, host string)
}
}

config.RoutingKeyName = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%s %s", config.TLSTermination, backendKey))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 function calls and a cast on one line? seems a bit much.
I'll leave it to @ramr or @marun to tell me if just config.TLSTermination and backendKey are unique/adequate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of tlsterm and route key (namespace + route name) maintains the current semantics such that if the type or name of a route changes, it's cookie id will differ accordingly. Without a salt brute force recovery would be possible, but I'm not sure that's a problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think I care about the 'brute force ability'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so its just for uniqueness and it would probably become more readable if we just used a temp
variable to store the key and then hash it and set config.RoutingKey ala:

key := fmt.Sprintf("%s %s", config.TLSTermination, backendKey)  
config.RoutingKeyName = fmt.Sprintf("%x", md5.Sum([]byte(key)))  

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make the change.

Resolves: bz1328030
This obfuscates the cookie name my hashing the original name.

Signed-off-by: Phil Cameron <[email protected]>
@pecameron
Copy link
Contributor Author

I made the discussed changes, PTAL
@openshift/networking

@eparis eparis closed this May 9, 2016
@eparis eparis reopened this May 9, 2016
@eparis
Copy link
Member

eparis commented May 9, 2016

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented May 9, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/5848/) (Image: devenv-rhel7_4140)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 28ab17d

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 28ab17d

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3678/)

@openshift-bot openshift-bot merged commit 71f310b into openshift:master May 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants