Skip to content

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

Merged
htuch merged 36 commits into
envoyproxy:masterfrom
mergeconflict:redacted_protobuf
Jan 15, 2020
Merged

htuch merged 36 commits into
envoyproxy:masterfrom
mergeconflict:redacted_protobuf

Conversation

@mergeconflict

@mergeconflict mergeconflict commented Dec 11, 2019 •

Copy link
Copy Markdown

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 [email protected]

@repokitteh-read-only

Copy link
Copy Markdown

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
Copy Markdown
Author

/review @htuch

Comment thread api/envoy/protobuf/BUILD Resolved
@jmarantz jmarantz self-assigned this Dec 11, 2019
Comment thread source/common/protobuf/utility.cc Resolved
Comment thread api/envoy/protobuf/descriptor.proto Resolved

@jmarantz jmarantz left a comment

Copy link
Copy Markdown
Contributor

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?

@PiotrSikora PiotrSikora left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread api/envoy/api/v2/auth/cert.proto Resolved
@mergeconflict

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@incfly

incfly commented Dec 11, 2019

Copy link
Copy Markdown
Contributor

/cc @incfly

@incfly

incfly commented Dec 11, 2019

Copy link
Copy Markdown
Contributor

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.

@htuch htuch left a comment

Copy link
Copy Markdown
Member

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

Comment thread api/envoy/protobuf/descriptor.proto Outdated
// 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
Copy Markdown
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
Copy Markdown
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.

Comment thread source/server/http/admin.cc Outdated

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread source/server/http/admin.cc Resolved
Comment thread source/common/protobuf/utility.cc Resolved
Comment thread source/common/protobuf/utility.cc Resolved
Comment thread source/common/protobuf/utility.cc Resolved
Comment thread source/common/protobuf/utility.cc Resolved
@htuch htuch self-assigned this Dec 11, 2019
Dan Rosen added 4 commits December 12, 2019 21:32
Signed-off-by: Dan Rosen <[email protected]>
Signed-off-by: Dan Rosen <[email protected]>
Signed-off-by: Dan Rosen <[email protected]>
@mergeconflict

Copy link
Copy Markdown
Author

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

@mergeconflict

Copy link
Copy Markdown
Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

🙀 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.

@htuch htuch left a comment

Copy link
Copy Markdown
Member

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

Comment thread source/common/protobuf/utility.cc Resolved
Comment thread source/common/protobuf/utility.cc Resolved
Signed-off-by: Dan Rosen <[email protected]>
htuch
htuch previously approved these changes Jan 14, 2020

@htuch htuch left a comment

Copy link
Copy Markdown
Member

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.

Dan Rosen added 2 commits January 14, 2020 10:49
Signed-off-by: Dan Rosen <[email protected]>
htuch
htuch previously approved these changes Jan 14, 2020

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@mergeconflict

Copy link
Copy Markdown
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