You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change internal-encryption to use no verification of the certificate #13764
Change the Activator upstream to use no verification when internal-encryption is used.
This will allow us to adopt SAN names specific for namespaces and support internal-trust as we move onwards
What's the background context here? Even though internal encryption is alpha I don't think we should regress and set InsecureSkipVerify: true The linked issues are super sparse in details.
Shouldn't we accept both SANs during the transition, rather than disabling certificate validation?
I know that today we're generating certs with the SAN data-plane.knative.dev for all namespaces, but it doesn't seem like accepting certs for random.anywhere would be a step forward. Am I missing something about how the activator does validation that would prevent us from accepting "A or B" but no other values?
In our universe, we issue ID cards to all entities. Our ID cards are nameless and faceless. All ID cards are the same. When you meet someone, and it presents such ID card, you have the option to verify that the ID is from our CA and has a valid date. You don't know it is his ID (and not a stolen ID).
Can we please identify a security threat that such IDs can help protect against?
This will help us examine better the right course of action.
If we can't, then using such IDs just produces a false sense of security, which is bad all around.
Here it gets more interesting, assuming we do identify a threat that we can protect against,
In our universe when A approaches B. A "knows" B. I.e. He knows which URL was used to reach B and if he trusts the DNS to work ok and the network routing to be intact, then he knows that the entity responding on the other side is B.
At the same time, B is being approached by an anonymous entity and knows nothing about who approached it.
But in our universe, we have a strange rule currently - when A approaches B (which A thinks he knows), he also verifies that B has a valid (nameless and faceless) ID card. While B when it is being approached by an anonymous entity, do not ask to see the nameless and faceless ID card of A.
So even if we do identify a threat we wish to cover with our present ID scheme, we need to fix it before we can use it.
Right now, our IDs and rules of how they are used seem completely useless. It makes people think we are giving some protection that we obviously do not.
I am ok to go either way:
We acknowledge that we offer traffic concealment only (and no trust) between the entities using internal encryption and therefore it is not the task of A when it approaches B to verify the validity of its certificate - i.e. use InsecureSkipVerify: true.
We identify some threats we protect against with our IDs and make sure B also verifies A - i.e. create some minimal level of mutual trust.
We move directly to enabling full trust - not a huge change from where we are in my view
I'd revisit the feature track and the author(s) to capture whatrequirements were set out.
We acknowledge that we offer traffic concealment only (and no trust) between the entities using internal encryption and therefore it is not the task of A when it approaches B to verify the validity of its certificate - i.e. use InsecureSkipVerify: true.
This isn't traffic concealment though because it's still susceptible to a MITM attack
We identify some threats we protect against with our IDs and make sure B also verifies A - i.e. create some minimal level of mutual trust.
I would say what's easier to start with is A validates B's certificate - where a common CA provides the mutual trust.
As @dprotaso points out, verifying that the activator or queue-proxy has a certificate signed by the Knative-internal CA with a well-known SAN does actually establish a bar for an attacker with (for example) network switch control. Since the certificates are distributed by the apiserver, an active network attacker cannot observe the certificate being read by the controllers or other components, and cannot generate a valid certificate.
I believe @davidhadas 's objection here is that the Knative-internal certificates are shared too widely across the cluster, such that an attacker with access to read secrets from their own namespace and the ability to create a Knative service can obtain a copy of a valid certificate which could be used alongside active network control to implement an MITM attack. Note that this requires both network-level access and Kubernetes namespace access, which I would maintain is a higher bar than simply network-level access.
Ok, so now we defined a target - encrypt the data and protect against MITM (and nothing else) I.e. the sender of a request can be sure that no one can read his request or the response not even if the attacker has the ability to stage an MITM attack. (but we can't be sure who sends requests etc. so requests may be coming from undefined sources). This of course is a valid guarantee we can provide on day 1.
Obtaining any certificate from any namespace is a very low bar.
In some systems, it may be as simple as registering to the system for a trial.
If we aim to protect against MITM, as a minimum we need to maintain a certificate per namespace with an appropriate SAN. I.e. fix the current implementation and have a SAN per namespace.
I don't think we should offer "MITM protection" with certificates that anyone with access to any namespace on that cluster can obtain. This is what I consider a false sense of security. We are not really protecting against MITM, we just say we do.
"Switch configured with default password" or "zero day attack on router firmware" are both valid attacks which don't necessarily involve compromise of a Kubernetes cluster. With that said, I agree that we should migrate to per-namespace SANs expeditiously.
Unfortunately, I have limited coding hours in the next few weeks, but I'm happy to either review PRs or be assigned a part in the upgrade plan, including "define flags and update clients to support both SANs as an intermediate state".
Since we only claim single-patch upgrades are tested / hitless, I think we can use a short-duration flag, like so:
Knative 1.9
(no flag)
served SAN = data-plane shared SAN
expected SAN = data-plane shared SAN
Knative 1.10 (04-25, during Kubecon)
flag: internal-encryption-unique-namespace: permissive or unset
served SAN = data-plane shared SAN
client SAN = data-plane or per-namespace SAN
flag: internal-encryption-unique-namespace: upgrade
served SAN = per-namespace SAN
client SAN = data-plane or per-namespace SAN
flag: internal-encryption-unique-namespace: strict
served SAN = per-namespace SAN
client SAN = per-namespace SAN (data-plane rejected)
We can use the post-upgrade job to change the value of internal-encryption-unique-namespace to upgrade in the 1.10 release
Knative 1.11
Force the value of internal-encryption-unique-namespace to upgrade, remove the ConfigMap flag. This should be hitless for people with internal-encryption: true assuming people run the post-upgrade job for 1.10.
@davidhadas brought up that we can produce certs with both the old and new SAN, which can move this to a single release.
Knative 1.9
(no flag)
served SAN = data-plane shared SAN
expected SAN = data-plane shared SAN
Knative 1.10 (04-24, during Kubecon)
flag: internal-encryption-expect-unique-cert unset
server SANs = data-plane SAN AND per-namespace SAN
client ServerName = data-plane SAN
flag: internal-encryption-expect-unique-cert: upgrade
server SANs = data-plane SAN AND per-namespace SAN
client ServerName = per-namespace SAN
In order to avoid client ServerNames getting ahead of server SANs, we'll need to have the post-upgrade jobs wait (sleep) for a reasonable amount of time (10m?) before setting the internal-encryption-expect-unique-cert value. Alternatively, since this is still an alpha feature, we could simply document that users setting the internal encryption field should also set the new field to upgrade after the install completes.
Knative 1.11 - 1.13
We should continue with the upgrade value for a few releases, so that users jumping from e.g. 1.9 to 1.11 don't get an error. At the same time, skip-upgades is technically unsupported (but probably popular), so I don't think we need to make a strong commitment there.
@evankanderson
I need this a bit slower... I may be misreading the above
Do you mean we are adding another flag named internal-encryption-expect-unique-cert in network pkg? Or is this some internal hardcoded per-version flag?
What is the meaning of "upgrade" as a value? It is not a natural choice to make as an admin aiming to activate a feature, if this is exposed to an admin, can we use a more traditional value?
How will the mTLS option play with the above? For mTLS, hopefully, we can use the same certificates (I aim for a first PoC showing at least Activator to Queue with mTLS). But the server side and client side tls.config will need to be extended to support mTLS and we will need to add a server-side verifier of the client SAN (a feature that seems to be missing from the standard golang tls lib if my reading is correct). So we need another flag for this (and maybe we can merge the two flags creating a flag with 3 values ???)
Yes, I'm proposing a short-term (e.g. 2-3 releases) flag in config-network. I'm fine with a better name for the flag, I was putting something down so I could use the name later.
Question 2
I chose a string value to allow for future values. This would be exposed to a cluster admin, though they might not bother to set it.
I've gotten into the case far too often when I've defined a boolean flag and then discovered that I needed an additional value (see internal-encryption and validate-client-cert for such an example). I'm open to names for "upgrade"; at some point in the future we might provide a "namespace-only" or "strict" that turns off the data-plane certs from being included.
Question 3
We could certainly roll the mTLS support option into the above string flag. This has the benefit of making the set of allowed states explicit, rather than a 2^N matrix of boolean flags, some of which are nonsensical (internal-encryption: true, expect-unique-cert: false, client-cert: true).
It looks like there are at least 2 ways to implement mTLS:
Implement tls.Config.VerifyPeerCertificate and parse the raw certificates. Ick
Implement tls.Config.VerifyConnection (which is called after TLS key exchange and before the handshake completes) and check ConnectionState.PeerCertificates[0]
In either case, returning a non-nil error will abort the handshake.
Thanks for the clarification.
I am holding knative/networking#778 till we change this flag to a multivalue string-based flag that will cover the above + mTLS.
What you described as a server-side Verifier is what I saw as well. This means we need to extend the default golang tls lib verifier with our own that will specifically verify the client SAN (I was a bit disappointed to find out that this is not included in the default lib).
// ServerName is used to verify the hostname on the returned// certificates unless InsecureSkipVerify is given. It is also included// in the client's handshake to support virtual hosting unless it is// an IP address.ServerNamestring
I'm assuming that the higher-level net/http libraries set ServerName if the Transport.TLSClientConfig is nil, but it should be possible to set it explicitly in code when constructing the client.
Activity
dprotaso commentedon Mar 6, 2023
cc @nak3 @KauzClay
What's the background context here? Even though internal encryption is alpha I don't think we should regress and set
InsecureSkipVerify: trueThe linked issues are super sparse in details.evankanderson commentedon Mar 6, 2023
Shouldn't we accept both SANs during the transition, rather than disabling certificate validation?
I know that today we're generating certs with the SAN
data-plane.knative.devfor all namespaces, but it doesn't seem like accepting certs forrandom.anywherewould be a step forward. Am I missing something about how the activator does validation that would prevent us from accepting "A or B" but no other values?ReToCode commentedon Mar 7, 2023
+1 on both comments above.
davidhadas commentedon Mar 8, 2023
In our universe, we issue ID cards to all entities. Our ID cards are nameless and faceless. All ID cards are the same. When you meet someone, and it presents such ID card, you have the option to verify that the ID is from our CA and has a valid date. You don't know it is his ID (and not a stolen ID).
Can we please identify a security threat that such IDs can help protect against?
This will help us examine better the right course of action.
If we can't, then using such IDs just produces a false sense of security, which is bad all around.
Here it gets more interesting, assuming we do identify a threat that we can protect against,
In our universe when A approaches B. A "knows" B. I.e. He knows which URL was used to reach B and if he trusts the DNS to work ok and the network routing to be intact, then he knows that the entity responding on the other side is B.
At the same time, B is being approached by an anonymous entity and knows nothing about who approached it.
But in our universe, we have a strange rule currently - when A approaches B (which A thinks he knows), he also verifies that B has a valid (nameless and faceless) ID card. While B when it is being approached by an anonymous entity, do not ask to see the nameless and faceless ID card of A.
So even if we do identify a threat we wish to cover with our present ID scheme, we need to fix it before we can use it.
Right now, our IDs and rules of how they are used seem completely useless. It makes people think we are giving some protection that we obviously do not.
I am ok to go either way:
InsecureSkipVerify: true.dprotaso commentedon Mar 14, 2023
I'd revisit the feature track and the author(s) to capture whatrequirements were set out.
This isn't traffic concealment though because it's still susceptible to a MITM attack
I would say what's easier to start with is A validates B's certificate - where a common CA provides the mutual trust.
evankanderson commentedon Mar 16, 2023
As @dprotaso points out, verifying that the
activatororqueue-proxyhas a certificate signed by the Knative-internal CA with a well-known SAN does actually establish a bar for an attacker with (for example) network switch control. Since the certificates are distributed by theapiserver, an active network attacker cannot observe the certificate being read by the controllers or other components, and cannot generate a valid certificate.I believe @davidhadas 's objection here is that the Knative-internal certificates are shared too widely across the cluster, such that an attacker with access to read secrets from their own namespace and the ability to create a Knative service can obtain a copy of a valid certificate which could be used alongside active network control to implement an MITM attack. Note that this requires both network-level access and Kubernetes namespace access, which I would maintain is a higher bar than simply network-level access.
davidhadas commentedon Mar 16, 2023
Ok, so now we defined a target - encrypt the data and protect against MITM (and nothing else) I.e. the sender of a request can be sure that no one can read his request or the response not even if the attacker has the ability to stage an MITM attack. (but we can't be sure who sends requests etc. so requests may be coming from undefined sources). This of course is a valid guarantee we can provide on day 1.
Obtaining any certificate from any namespace is a very low bar.
In some systems, it may be as simple as registering to the system for a trial.
If we aim to protect against MITM, as a minimum we need to maintain a certificate per namespace with an appropriate SAN. I.e. fix the current implementation and have a SAN per namespace.
I don't think we should offer "MITM protection" with certificates that anyone with access to any namespace on that cluster can obtain. This is what I consider a false sense of security. We are not really protecting against MITM, we just say we do.
evankanderson commentedon Mar 16, 2023
"Switch configured with default password" or "zero day attack on router firmware" are both valid attacks which don't necessarily involve compromise of a Kubernetes cluster. With that said, I agree that we should migrate to per-namespace SANs expeditiously.
Unfortunately, I have limited coding hours in the next few weeks, but I'm happy to either review PRs or be assigned a part in the upgrade plan, including "define flags and update clients to support both SANs as an intermediate state".
Since we only claim single-patch upgrades are tested / hitless, I think we can use a short-duration flag, like so:
Knative 1.9
(no flag)
served SAN =
data-planeshared SANexpected SAN =
data-planeshared SANKnative 1.10 (04-25, during Kubecon)
flag:
internal-encryption-unique-namespace: permissiveor unsetserved SAN =
data-planeshared SANclient SAN =
data-planeor per-namespace SANflag:
internal-encryption-unique-namespace: upgradeserved SAN = per-namespace SAN
client SAN =
data-planeor per-namespace SANflag:
internal-encryption-unique-namespace: strictserved SAN = per-namespace SAN
client SAN = per-namespace SAN (
data-planerejected)We can use the post-upgrade job to change the value of
internal-encryption-unique-namespacetoupgradein the 1.10 releaseKnative 1.11
Force the value of
internal-encryption-unique-namespacetoupgrade, remove the ConfigMap flag. This should be hitless for people withinternal-encryption: trueassuming people run the post-upgrade job for 1.10.evankanderson commentedon Mar 24, 2023
@davidhadas brought up that we can produce certs with both the old and new SAN, which can move this to a single release.
Knative 1.9
(no flag)
served SAN =
data-planeshared SANexpected SAN =
data-planeshared SANKnative 1.10 (04-24, during Kubecon)
flag:
internal-encryption-expect-unique-certunsetserver SANs =
data-planeSAN AND per-namespace SANclient ServerName =
data-planeSANflag:
internal-encryption-expect-unique-cert: upgradeserver SANs =
data-planeSAN AND per-namespace SANclient ServerName = per-namespace SAN
In order to avoid client ServerNames getting ahead of server SANs, we'll need to have the post-upgrade jobs wait (sleep) for a reasonable amount of time (10m?) before setting the
internal-encryption-expect-unique-certvalue. Alternatively, since this is still an alpha feature, we could simply document that users setting the internal encryption field should also set the new field toupgradeafter the install completes.Knative 1.11 - 1.13
We should continue with the
upgradevalue for a few releases, so that users jumping from e.g. 1.9 to 1.11 don't get an error. At the same time, skip-upgades is technically unsupported (but probably popular), so I don't think we need to make a strong commitment there.davidhadas commentedon Mar 24, 2023
@evankanderson
I need this a bit slower... I may be misreading the above
internal-encryption-expect-unique-certin network pkg? Or is this some internal hardcoded per-version flag?evankanderson commentedon Mar 24, 2023
Question 1
Yes, I'm proposing a short-term (e.g. 2-3 releases) flag in
config-network. I'm fine with a better name for the flag, I was putting something down so I could use the name later.Question 2
I chose a string value to allow for future values. This would be exposed to a cluster admin, though they might not bother to set it.
I've gotten into the case far too often when I've defined a boolean flag and then discovered that I needed an additional value (see
internal-encryptionandvalidate-client-certfor such an example). I'm open to names for"upgrade"; at some point in the future we might provide a"namespace-only"or"strict"that turns off thedata-planecerts from being included.Question 3
We could certainly roll the mTLS support option into the above string flag. This has the benefit of making the set of allowed states explicit, rather than a 2^N matrix of boolean flags, some of which are nonsensical (
internal-encryption: true,expect-unique-cert: false,client-cert: true).It looks like there are at least 2 ways to implement mTLS:
tls.Config.VerifyPeerCertificateand parse the raw certificates. Icktls.Config.VerifyConnection(which is called after TLS key exchange and before the handshake completes) and checkConnectionState.PeerCertificates[0]In either case, returning a non-nil
errorwill abort the handshake.davidhadas commentedon Mar 24, 2023
Thanks for the clarification.
I am holding knative/networking#778 till we change this flag to a multivalue string-based flag that will cover the above + mTLS.
What you described as a server-side Verifier is what I saw as well. This means we need to extend the default golang tls lib verifier with our own that will specifically verify the client SAN (I was a bit disappointed to find out that this is not included in the default lib).
ReToCode commentedon Mar 27, 2023
/triage accepted
evankanderson commentedon Mar 27, 2023
It looks like the
tls.Config'sServerNamefield can be used to verify the hostname on the returned certificates:I'm assuming that the higher-level
net/httplibraries setServerNameif theTransport.TLSClientConfigisnil, but it should be possible to set it explicitly in code when constructing the client.davidhadas commentedon May 9, 2023
I think this issue is no longer needed and can be closed as we took an alternative route.
We support a variety of TLS+certificate options including: