Skip to content
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

Feature untrusted client certs #8248

Conversation

jimini-lumox
Copy link
Contributor

Description: Add the ability to pass through and route 'untrusted' certificates.

This is a resurrection of #6760

The original PR covered two requirements:
Allowing certs that fail validation.
Request peer certs when there is nothing to validate against.

By default the client validation rules are unchanged.

Additional validation context options:
// Specify the certificate validation to be performed: VERIFY_TRUST_CHAIN(default), ACCEPT_UNTRUSTED, NOT_VERIFIED.
TrustChainVerification verify_certificate_trust_chain;
// If ACCEPT_UNTRUSTED or NOT_VERIFIED selected, when a client certificate fails (or is not validated) an x-forwarded-untrusted-client-cert HTTP header hoisted.

Risk Level: Medium
Testing: Manual and unit tests
Docs Changes: API proto changes
Release Notes: N/A

@zuercher
Copy link
Member

@jimini-lumox Thanks for taking this up. In addition to the test failures and formatting, you'll need to rewrite those commits (including the merge) with DCO sign-offs (see the DCO section in CONTRIBUTING.md).

@zuercher zuercher self-assigned this Sep 16, 2019
@zuercher
Copy link
Member

/wait

@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #8248 was synchronize by jimini-lumox.

see: more, trace.

micheal.hargreaves and others added 4 commits September 17, 2019 05:24
Signed-off-by: Michael Hargreaves <[email protected]>
Signed-off-by: Michael Hargreaves <[email protected]>
Signed-off-by: Michael Hargreaves <[email protected]>
@zuercher zuercher assigned lizan and PiotrSikora and unassigned lizan Sep 17, 2019
Signed-off-by: Michael Hargreaves <[email protected]>
Signed-off-by: Michael Hargreaves <[email protected]>
@@ -310,6 +310,7 @@ class HeaderEntry {
HEADER_FUNC(Etag) \
HEADER_FUNC(Expect) \
HEADER_FUNC(ForwardedClientCert) \
HEADER_FUNC(ForwardedUntrustedClientCert) \
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want a new header field for untrusted client certificates? Can we just add Trusted=False in XFCC header to indicate that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had initially implemented this way, however had concerns over the potential for existing code to treat ForwardedClientCert as having passed validation.
An example of the routing we perform is as follows: - route to the intended service, iff have x-forwarded-client-cert header. (I guess a 'safe-regex_match' could alternatively be used to route based on 'Trusted=False/True'

"routes": [
{
"match": { "prefix": "/", "headers": [
{ "name": "x-forwarded-untrusted-client-cert", "present_match": true }
] },
"route": {
"cluster": "venue-edge-access-control",
"prefix_rewrite": "/api/cert/untrusted",
"host_rewrite": "venue-edge-access-control"
}
},
{
"match": { "prefix": "/", "headers": [
{ "name": "x-forwarded-client-cert", "present_match": true, "invert_match" : true }
] },
"route": {
"cluster": "venue-edge-access-control",
"prefix_rewrite": "/api/cert/untrusted",
"host_rewrite": "venue-edge-access-control"
}
},
{
"match": { "prefix": "/", "headers": [
{ "name": "x-forwarded-client-cert", "present_match": true },
{ "name": ":authority", "prefix_match": "service-actual-target-service" }
] },
"route": {
"cluster": "service-actual-target-service"
}
},
....

Copy link
Member

Choose a reason for hiding this comment

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

@PiotrSikora thoughts on these headers and what other proxies might do.

Copy link
Member

Choose a reason for hiding this comment

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

@jimini-lumox I see what your example try to address. Does it make more sense to have a route matcher based on presented client cert semantically rather than relying on XFCC/XFUCC header? Adding header and route matching can be orthogonal.

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'm not sure I understand exactly, or how to achieve it using the route matcher. Below is a comment on our usage from the first cut of the PR (#5207). Do you know how we would use route matching to handle the scenarios (maybe it's easy, I'm not sure)

We use Envoy as an Edge Proxy to host services, with thousands of devices in venues on a private network.
We're using the Hash List as validation of clients, which will initially be empty ie - nothing to validate against.
Client Certs are currently self-signed (no PKI infrastructure available) - so there is nothing within the certificate to validate against.
If a client connects and its Cert Hash is in the list, it will be routed to its intended target service.
(eg: x-forwarded-client-cert header present & :authority header match)
If a client connects and its Cert Hash is not in the list (or there is no validation context yet), then it may be routed to an access-control-service.
(eg: x-forwarded-untrusted-client-cert header present & :authority header match)
Then the access-control-service controls whether a client is to be permitted, in which case the client hash will be added to the verify_certificate_hash list (using dynamic_resources from the Edge Proxy, so subsequent request is routed to the intended service).
Additionally we may not care if a client needs to be validated to reach certain other host services.

Copy link
Contributor Author

@jimini-lumox jimini-lumox Sep 25, 2019

Choose a reason for hiding this comment

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

RouteMatch only uses http headers, so if I'm following you correctly:

  • always hoist headers into x-forwarded-client-cert (instead of using x-forwarded-untrusted-client-cert for either failed or unvalidated)
  • and,
    either add a field to the x-forwarded-client-cert to indicated that it passed/failed validation (eg Trusted=false)
    or add another http header that simply indicates whether the client was validated, so we can route based on this.
  • and then add a new RouteMatch field that can simplify the route matching rules for validation, eg something like:
  message RouteMatch {
    message CredentialMatchOptions {
        google.protobuf.BoolValue validated = 1;
        // can add further matches here - eg Issuer,Hash etc.
    }
    ...
    CredentialMatchOptions credentials = 11;
  }

then the matching would simplify to:

"routes": [
  {
    "match": { "prefix": "/", "credentials": { "validated": false } },
    "route": {
      "cluster": "venue-edge-access-control",
      ...
    }
  },
  {
    "match": { "prefix": "/", "credentials": { "validated": true },
               "headers": [ { "name": ":authority", "prefix_match": "service-actual-target-service" }
               ]
    },
    "route": {
      "cluster": "service-actual-target-service"
    }
  }
...

Copy link
Member

Choose a reason for hiding this comment

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

The config example looks right, I think we should open another issue for this API proposal.

RouteMatch only uses http headers

This is how current implementation does but not a hard limitation. You can use the cert information directly from downstream connection and plumb it into RouteMatcher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so should I create a new PR that has this API proposal including the changes to route the required connection info through to the Route matching.
I was thinking that we could provide the StreamInfo through the route matching from which we can get the downstreamSslConnection info etc.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking that we could provide the StreamInfo through the route matching from which we can get the downstreamSslConnection info etc.

Exactly.

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've raised PR #8453 with an initial cut of passing the connection stream_info through to the route matching.

api/envoy/api/v2/auth/cert.proto Outdated Show resolved Hide resolved
api/envoy/api/v2/auth/cert.proto Outdated Show resolved Hide resolved
api/envoy/api/v2/auth/cert.proto Outdated Show resolved Hide resolved
api/envoy/api/v2/auth/cert.proto Show resolved Hide resolved
api/envoy/api/v2/auth/cert.proto Outdated Show resolved Hide resolved
@@ -310,6 +310,7 @@ class HeaderEntry {
HEADER_FUNC(Etag) \
HEADER_FUNC(Expect) \
HEADER_FUNC(ForwardedClientCert) \
HEADER_FUNC(ForwardedUntrustedClientCert) \
Copy link
Member

Choose a reason for hiding this comment

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

@PiotrSikora thoughts on these headers and what other proxies might do.

@zuercher zuercher assigned PiotrSikora and lizan and unassigned zuercher and PiotrSikora Sep 18, 2019
@stale
Copy link

stale bot commented Oct 11, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Oct 11, 2019
@jimini-lumox
Copy link
Contributor Author

jimini-lumox commented Oct 13, 2019

PR #8453 still in progress which will impact the implementation of this PR
PR #8453 now accepted, so will merge into this PR, updating configuration, tests etc. WIP

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Oct 13, 2019
htuch pushed a commit that referenced this pull request Oct 18, 2019
Add the ability to route match based on client credentials.

This is an output of the changes requested for PR #8248 (#8248 (comment))
To more cleanly support #8248 , it would be better to be able to route based on downstream connection details, instead of hoisting more information into headers.

As an API example, route matching based on presented and/or expired client certificate is supported.
The end goal for #8248 is to route based on 'validated'.

By default the routing rules are unchanged.

Risk Level: Medium
Testing: Currently Manual tests
Docs Changes: API proto changes
Release Notes: N/A

Signed-off-by: Michael Hargreaves <[email protected]>
…eature-untrusted-client-certs

Signed-off-by: Michael Hargreaves <[email protected]>
…eature-untrusted-client-certs

Signed-off-by: Michael Hargreaves <[email protected]>
@stale
Copy link

stale bot commented Oct 20, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added stale stalebot believes this issue/PR has not been touched recently and removed stale stalebot believes this issue/PR has not been touched recently labels Oct 20, 2019
…textMatchOptions instead of additional header (x-forwarded-untrusted-client-cert)

Signed-off-by: Michael Hargreaves <[email protected]>
Signed-off-by: Michael Hargreaves <[email protected]>
Signed-off-by: Michael Hargreaves <[email protected]>
Signed-off-by: Michael Hargreaves <[email protected]>
@stale
Copy link

stale bot commented Nov 12, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Nov 12, 2019
@stale
Copy link

stale bot commented Nov 19, 2019

This pull request has been automatically closed because it has not had activity in the last 14 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot closed this Nov 19, 2019
@jimini-lumox
Copy link
Contributor Author

jimini-lumox commented Nov 25, 2019

I think this is ready for a review with PR #8453 merged and appropriate unit tests.
@lizan How do I re-open this PR? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants