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

api: add 'redacted' option for protobuf messages, and redact SSL certs #9315

Merged
merged 36 commits into from
Jan 15, 2020
Merged

api: add 'redacted' option for protobuf messages, and redact SSL certs #9315

merged 36 commits into from
Jan 15, 2020

Conversation

mergeconflict
Copy link
Member

@mergeconflict mergeconflict commented Dec 11, 2019

Implement MessageUtil::redact() to redact proto fields with the udpa.annotations.sensitive option set. Apply this to SSL certs in the admin config_dump.

Risk Level: low
Testing: unit tests
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Dan Rosen mergeconflict@google.com

Signed-off-by: Dan Rosen <mergeconflict@google.com>
@repokitteh-read-only
Copy link

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

🐱

Caused by: #9315 was opened by mergeconflict.

see: more, trace.

@mergeconflict
Copy link
Member Author

/review @htuch

Signed-off-by: Dan Rosen <mergeconflict@google.com>
@jmarantz jmarantz self-assigned this Dec 11, 2019
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

WDYT of simply populating the cert with a hashed version of the cert? It might be a lot less code. What're the pros & cons?

Copy link
Contributor

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

Please take a look at the discussion for when we redacted SDS values in /config_dump:
#7365

api/envoy/api/v2/auth/cert.proto Outdated Show resolved Hide resolved
@mergeconflict
Copy link
Member Author

WDYT of simply populating the cert with a hashed version of the cert? It might be a lot less code. What're the pros & cons?

@jmarantz: I think my current approach isn't a tremendous amount of code, and it's general purpose: anything else in the config dump that needs to be redacted can use this mechanism. See e.g. https://github.com/envoyproxy/envoy/blob/master/source/common/secret/secret_manager_impl.cc#L118.

@mattklein123
Copy link
Member

Big +1 for implementing this. We need this for tapping and other general data exfiltration issues.

@incfly
Copy link
Contributor

incfly commented Dec 11, 2019

/cc @incfly

@incfly
Copy link
Contributor

incfly commented Dec 11, 2019

WDYT of simply populating the cert with a hashed version of the cert? It might be a lot less code. What're the pros & cons?

Istio builds some tooling to actually get the cert and parse out the expiration time for troubleshooting.

Only clearing the private key and password is good enough and above tooling would still work.

Signed-off-by: Dan Rosen <mergeconflict@google.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Nice, this is a very clean approach to the problem, happy to see it landing.
/wait

// This option indicates that a field contains personally-identifying or otherwise sensitive data,
// such as a private key or a password. It is used by `MessageUtil::redact` to determine which
// fields need to be sanitized. Please note that this has no effect on standard Protobuf functions
// such as `TextFormat::PrintToString`; you must explicitly call `MessageUtil::redact` wherever
Copy link
Member

Choose a reason for hiding this comment

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

Can we add check_format support to ban all the likely candidates (e.g. DebugString, PrintToString) and force safe uses?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's chat about that tomorrow; I'm not sure how big a hammer we want to use, if any.


response_headers.setReferenceContentType(Http::Headers::get().ContentTypeValues.Json);
response.add(MessageUtil::getJsonStringFromMessage(dump, true)); // pretty-print
response.add(MessageUtil::getJsonStringFromMessage(*redacted, true)); // pretty-print
Copy link
Member

Choose a reason for hiding this comment

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

I feel we also want this in various logs, e.g. trace level xDS logs, where this has come up previously as an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, definitely. I'm thinking to just target this one spot in this PR, as a proof of concept, and then track down others (e.g. #4757) as a follow-up.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, I'm good with keeping the issue open for follow-up.

source/server/http/admin.cc Outdated Show resolved Hide resolved
source/common/protobuf/utility.cc Outdated Show resolved Hide resolved
source/common/protobuf/utility.cc Outdated Show resolved Hide resolved
source/common/protobuf/utility.cc Outdated Show resolved Hide resolved
source/common/protobuf/utility.cc Outdated Show resolved Hide resolved
@htuch htuch self-assigned this Dec 11, 2019
Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
@mergeconflict
Copy link
Member Author

@htuch thanks for your help; I think this is ready for a second look.

@mergeconflict
Copy link
Member Author

/retest

@repokitteh-read-only
Copy link

🙀 Error while processing event:

evaluation error
error: function error error: user: combined status is failure, but no failed builds.
🐱

Caused by: a #9315 (comment) was created by @mergeconflict.

see: more, trace.

Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo two minor comments.
/wait

source/common/protobuf/utility.cc Outdated Show resolved Hide resolved
source/common/protobuf/utility.cc Outdated Show resolved Hide resolved
Signed-off-by: Dan Rosen <mergeconflict@google.com>
htuch
htuch previously approved these changes Jan 14, 2020
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, needs master merge. Epic work, thanks for this contribution.

Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
Signed-off-by: Dan Rosen <mergeconflict@google.com>
htuch
htuch previously approved these changes Jan 14, 2020
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

Signed-off-by: Dan Rosen <mergeconflict@google.com>
@mergeconflict
Copy link
Member Author

@htuch merged master

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.

8 participants