Repository navigation
Closed
Labels
Description
Issue summary
Specifying more than one auth.TlsCertificate causes Envoy to dump the proto of the affected listener to the logs; if there is an inline private key, it is not redacted prior to logging.
Api Config Source for LDS = REST, not gRPC/file
Error produced by Envoy
newline separated to enhance readability
[9][warning][config] bazel-out/k8-opt/bin/source/common/config/_virtual_includes/http_subscription_lib/common/config/http_subscription_impl.h:87]
REST config update rejected: Proto constraint validation failed
(ListenerValidationError.FilterChains[i]: ["embedded message failed validation"] |
caused by FilterChainValidationError.TlsContext: ["embedded message failed validation"] |
caused by DownstreamTlsContextValidationError.CommonTlsContext: ["embedded message failed validation"] |
caused by CommonTlsContextValidationError.TlsCertificates: ["value must contain no more than " '\x01' " item(s)"]): name: "TestListener"
<insert proto dump here>
Example configuration
{
"@type": "type.googleapis.com/envoy.api.v2.Listener",
"name": "TestListener",
"address": {
"socket_address": {
"address": "0.0.0.0",
"port_value": 443,
"protocol": "TCP"
}
},
"filter_chains": [
{
"filters": [
{
"config": {
"access_log": [
{
"config": {
"path": "/var/log/envoy/access.log"
},
"name": "envoy.file_access_log"
}
],
"codec_type": "AUTO",
"http_filters": [
{
"name": "envoy.gzip"
},
{
"name": "envoy.router"
}
],
"rds": {
"config_source": {
"api_config_source": {
"api_type": "REST",
"cluster_names": [
"controlplane"
],
"refresh_delay": "5s"
}
},
"route_config_name": "service_instances_rds"
},
"stat_prefix": "backends"
},
"name": "envoy.http_connection_manager"
}
],
"tls_context": {
"common_tls_context": {
"tls_certificates": [
{
"certificate_chain": {
"inline_string": "-----BEGIN CERTIFICATE-----"
},
"private_key": {
"inline_string": "-----BEGIN PRIVATE KEY-----"
}
},
{
"certificate_chain": {
"inline_string": "-----BEGIN CERTIFICATE-----"
}
},
{
"certificate_chain": {
"inline_string": "-----BEGIN CERTIFICATE-----"
}
}
]
}
}
}
]
}
Reacted by Terin Stock
Activity
zuercher commentedon Oct 17, 2018
Seems like this would happen with gRPC or file as the LDS source as well. And also in CDS for tls_context data in Cluster.
PiotrSikora commentedon Jan 7, 2019
Private keys (and possibly other sensitive information) can be also leaked via
/config_dump(I could swear there was a bug for it, but I cannot find it now).I imagine there should be a way to sanitize sensitive data at the protobuf level. @htuch any ideas?
cetanu commentedon Jan 7, 2019
@PiotrSikora , I found this acceptable only because I thought it's the intention to only expose this interface to administrators, since it also has the /quitquitquit endpoint that literally kills the process... Although it would be nice to hide these things. I haven't kept up to date with SDS (Secret Discovery Service) how is it handled with that? Still exposed?
htuch commentedon Jan 7, 2019
@PiotrSikora I don't know if there is a standard way to do this in OSS protobuf today. It could be done as an annotation though, where we store encrypted data in-memory (and for the standard
DebugString()), only making it available to C++ via additional accessor methods that aprotocplugin generates.terinjokes commentedon Feb 14, 2019
I just got bitten by this.
I don't have the expectation that increasing the log level up one from the default would start exposing private key material. I don't see a reference to this behavior in the docs nor in the help text.
htuch commentedon Feb 14, 2019
I agree that we should scrub private keys from the config dump and log messages. Turning up logging though is still going to be a minefield for PII and other data leakage, this should be expected; if you switch to trace level, you will start seeing data plane traffic unencrypted. This is WAI, we want to be able to debug at trace level, trace level shouldn't be used in production outside of very controlled debug scenarios.
terinjokes commentedon Feb 14, 2019
@htuch I understand. I definitely expect things like this from trace. At debug we expected more logging around timings, memory pressures, and the like.
htuch commentedon Feb 14, 2019
@terinjokes PRs welcome. My comment in #4757 (comment) is aspirational, I think we can just do some manual redaction of protos in config dump and debug log statements for now.
stevesloka commentedon May 6, 2019
I'd like to help out here and see if I can send up a PR. Any notes or pointers to help get started? Should I start with just the config dump, then move from there with separate PR's?
htuch commentedon May 6, 2019
@stevesloka I would advocate for having a
sanitizeProtomethod that takes something like aListenerconfig that we're about to dump and redacts the keys. So, most call sites should have a single line change to wrap the dumped proto with this.stevesloka commentedon May 8, 2019
Do you have any other tips of where to integrate @htuch? I'm new to the code base and still digging through.
htuch commentedon May 9, 2019
@stevesloka a good start would be to look at the uses of
DebugString()for proto ingrpc_mux_impl.cc. The main challenge there is it's dealing with generic protobufMessage; you'll need to downcast to the relevant protos to do scrubbing.stevesloka commentedon May 22, 2019
Hey @htuch, I'm not following where DebugString is used for the specific use case that this issue is trying to solve. I can see usages of this coming from
util.cc, but I'm just not clear on the higher level approach to how we might fix this.6 remaining items
mattklein123 commentedon Aug 26, 2019
FWIW I think this is better suited to an annotation that we can then process and utilize in different ways including logging, tap, etc.
incfly commentedon Dec 11, 2019
Hi folks, we're considering to contribute a workaround fix by hardcode traversal the listener/cluster/secrets, before the desired approach (proto annotation && reflection) landed. Thus the admin config dump interface won't be subjected to leak private key.
Something like an utility function as
void RedactSecurityData(protobuf::Message& message).WDTY? @htuch @mergeconflict
mergeconflict commentedon Dec 11, 2019
@incfly Funny timing... I actually just picked this back up. I have an implementation that's probably about halfway done. Let's chat tomorrow?
incfly commentedon Dec 11, 2019
terinjokes commentedon Dec 11, 2019
@incfly @mergeconflict Awesome. We were just talking about this bug today, since it effects are ability to debug some issues.
mattklein123 commentedon Dec 11, 2019
FWIW I feel like we have enough code in the codebase now dealing with annotations, parsing, etc. that it shouldn't be that hard to do this "the right way."
mergeconflict commentedon Dec 11, 2019
I have a PR up: #9315. It still needs some work, and doesn't fix this issue yet (currently it only redacts SSL certs in the admin config_dump) but I intend to apply it to this as well.
incfly commentedon Dec 11, 2019
Thanks @mergeconflict ! Yeah, #9315 will satisfy our needs. I'll follow up on that PR.
mergeconflict commentedon Jan 15, 2020
I just took another look at this... I think this might be trickier than just inserting a call to
MessageUtil::redact()before logging, because the error message is actually coming from protoc-gen-validate. That looks like:I can't think of an obvious way to have pgv redact messages before serializing and populating the error... Any suggestions @mattklein123 @htuch?
mattklein123 commentedon Jan 15, 2020
The only way that I can think of is to have PGV become aware of the redaction annotation, which seems like a reasonable thing to work towards?
htuch commentedon Jan 16, 2020
It could be fixed in PGV. In the interim, we could redact before passing to PGV. Then we continue to use the original message. The main downside there is you then skip PGV of redacted fields.
mergeconflict commentedon Jan 17, 2020
@htuch I would guess the main downside to that approach is the runtime cost of preemptively redacting everything (making a copy and iterating over it). There could also be cases where a PGV annotation expresses some constraint that is violated by redaction.
htuch commentedon Jan 17, 2020
@mergeconflict yep, I think the long term solution is fixing in PGV.
cetanu commentedon Oct 15, 2023
I think this has been fixed??? I'm going to close this and if needed we can reopen.