-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Add a util function to check if a transport is secure enough to transfer CallCredentials #6616
base: master
Are you sure you want to change the base?
Conversation
@@ -90,6 +91,12 @@ private static DataSource buildDataSourceFromConfigStruct(Struct secretValueStru | |||
@Override | |||
public void applyRequestMetadata( | |||
@Nullable RequestInfo requestInfo, Executor appExecutor, final MetadataApplier applier) { | |||
if (!checkSecurityLevel(requestInfo, SecurityLevel.PRIVACY_AND_INTEGRITY)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is currently used for SDS which is over an UDS channel. Will this check now break the SDS communication or is UDS considered at SecurityLevel.PRIVACY_AND_INTEGRITY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UDS should be considered secure (i.e., SecurityLevel.PRIVACY_AND_INTEGRITY
). Do you know if the security level is correctly set for the UDS channel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know. If not, we will have to do that before merging this change to ensure this feature doesn't break. Let me know if you want to discuss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. If I read the code correctly, it seems UDS channel is implemented as a Netty plaintext channel whose security level is NONE
and I believe it is the cause of test failure. Is it possible to associate the security level PRIVACY_AND_INTEGRITY
to the plaintext channel when used for UDS? Let me schedule a meeting to discuss about it if it is not trivial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, is it appropriate to associate PRIVACY_AND_INTEGRITY
to FileBasedPluginCredential
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that's the only way to use UDS in grpc-java/Netty. Not sure about your question "Is it possible to associate the security level PRIVACY_AND_INTEGRITY to the plaintext channel when used for UDS?" but I suppose it should be possible. CC @ejona86
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, is it appropriate to associate
PRIVACY_AND_INTEGRITY
toFileBasedPluginCredential
?
Good question. This FileBasedPluginCredential
mimics Envoy's similar credential https://github.com/envoyproxy/envoy/blob/master/source/extensions/grpc_credentials/file_based_metadata/config.cc which is received by Istio Node Agent (https://github.com/istio/istio/blob/master/security/pkg/nodeagent/sds/sdsservice.go#L509:6) . I think this is loaded from a secure and privileged file location so it is fair to assume it needs a secure channel (but we need to think about it).
One test failed:
This indicates the code change will also break prod behavior. Did the test pass in your testing? |
* @param requestInfo request-related information | ||
* @param minSecurity minimum security level required by {@link CallCredentials} | ||
*/ | ||
public final boolean checkSecurityLevel(RequestInfo requestInfo, SecurityLevel minSecurity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check
makes it seem like this will throw. Maybe name it allowedSecurityLevel
or fulfullsSecurityLevel
or similar that makes it more obvious it returns a boolean?
* @param requestInfo request-related information | ||
* @param minSecurity minimum security level required by {@link CallCredentials} | ||
*/ | ||
public final boolean checkSecurityLevel(RequestInfo requestInfo, SecurityLevel minSecurity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static
?
cb5daa4
to
1a27000
Compare
Is it POR for using a plaintext channel for UDS? If that's the case, I have a following plan to associate the security level
|
This is dictated by the other end - the SDS server (Citadel agent) only supports UDS based plaintext channel. See https://istio.io/docs/tasks/security/citadel-config/auth-sds/#securing-sds-with-pod-security-policies (instead of Envoy sidecar, read it as proxyless gRPC client).
Comments below:
What if user called
Looking at this attribute code it might be better to use the |
No, I don't think we want to do that. It would be strictly better to check for DomainSocketAddress at NettyChannelBuilder.createProtocolNegotiatorByType(). We can either pass in the SocketAddress to the function or make it non-static. That said, I'd really prefer a solution that works with a future UnixNameResolver. We can move the DomainSocketAddress check to PlaintextProtocolNegotiator. Unfortunately, it wouldn't be guaranteed to be authenticated in that case, since maybe a MyCustomNameResolver returns unauthenticated DomainSocketAddresses. We could require the filename also matches the authority (and use INSECURE if it is not). |
xds/src/main/java/io/grpc/xds/sds/FileBasedPluginCredential.java
Outdated
Show resolved
Hide resolved
@yihuazhang Could you please resolve the conflict |
1a27000
to
2db80cd
Compare
@ejona86 @sanjaypujare PTALA |
* @param requestInfo request-related information | ||
* @param minSecurity minimum security level required by {@link CallCredentials} | ||
*/ | ||
public static final boolean allowedSecurityLevel( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it more, let's make this protected. Only extending classes will need to call this. It wouldn't really hurt anything by having it public, but pollutes what consumers of CallCredentials would see.
@yihuazhang Would you please sign the EasyCLA so that this can be merged? |
This PR adds a util function that checks if the security level of transport is higher than or equal to that of CallCredentials. The util function is called
GoogleAuthLibraryCallCredentials
andFileBasedPluginCredential
for which I believe privacy+integrity should be required for the transport. After this PR gets merged, I will update the internal CallCredentials implementation to call the util function (for the auditing purpose).gRFC for security level negotiation: grpc/proposal#167