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

Implementing TLS for ClientService #229

Closed
4 tasks done
Tracked by #228
tegefaulkes opened this issue Aug 18, 2021 · 14 comments
Closed
4 tasks done
Tracked by #228

Implementing TLS for ClientService #229

tegefaulkes opened this issue Aug 18, 2021 · 14 comments
Assignees
Labels
development Standard development r&d:polykey:core activity 1 Secret Vault Sharing and Secret History Management security Security risk

Comments

@tegefaulkes
Copy link
Contributor

tegefaulkes commented Aug 18, 2021

Specification

CLI GRPC Client should be using direct TLS to the GRPC Client Service.

Additional context

reference this comment: https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/207/diffs#note_651473935.

An MR has been created for this issue.
https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/210

Tasks

  1. enable TLS connection as default for the PolykeyClient.
  2. split the PolykeyAgent GRPCServer into two servers, enable TLS for the server serving the client service. unsecured for server serving the AgentService.
  3. write a test and confirm that the client traffic is over TLS now.
  4. confirm that the agent-agent traffic still functions.
@tegefaulkes tegefaulkes changed the title CLI GRPC Client should be using direct TLS to the GRPC Client Service: https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/207/diffs#note_651473935 Implementing TLS for the GRPC Client Service Aug 18, 2021
@tegefaulkes tegefaulkes added the development Standard development label Aug 18, 2021
@tegefaulkes tegefaulkes changed the title Implementing TLS for the GRPC Client Service Implementing TLS for ClientService Aug 18, 2021
@CMCDragonkai
Copy link
Member

CMCDragonkai commented Aug 23, 2021

  • CLI communication goes directly to the GRPC server, not through the forward and reverse proxies. This avoids creating unnecessarily expensive proxy objects just to perform a single CLI call.
  • This means client service should only be exposed over TLS.
  • There should be stub code or pre-existing code that allows the GRPC server to serve TLS.
  • CLI and GUI can use TLS but not MTLS. That is client side shouldn't need to provide certificates... they can just accept and validate the server certificate. See the certification verification utility function inside network/utils.ts.
  • Server side validates by the usage of the session token.

@tegefaulkes please spend time to clarify the task list (and/or prototyping) before starting on it. Similar to how #213 was addressed and the task list on the associated MR.

@tegefaulkes
Copy link
Contributor Author

tegefaulkes commented Aug 24, 2021

After digging through the code, I think TLS is already supported by GRPCServer, it just needs to be passed a TLSConfig when starting. so we should be able to enable TLS by having PolykeyAgent start the GRPCServer with a TLSConfig at src/PolykeyAgent.ts:324

await this.grpcServer.start({
      host: this.grpcHost as Host,
      port: this.grpcPort as Port,
    });

This may enable TLS for both the client service and the agent service though.
If we just want TLS for the client connections then some small changes to GRPCServer are needed.

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Aug 24, 2021 via email

@tegefaulkes
Copy link
Contributor Author

I have gotten a test case to work with TLS doing an echo command as a test. The client doesn't have to provide any certs for this to work but the code is written to expect them so some modifications need to be made. I've pushed an example of this to https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/210

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Aug 24, 2021 via email

@tegefaulkes
Copy link
Contributor Author

Looks like the TLS credentials is for the whole server. I don't think I can enable TLS for just the clientService and not the AgentService unless we run two seperate servers for them.

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Aug 25, 2021 via email

@tegefaulkes
Copy link
Contributor Author

I will create separate servers for client and agent services.
I have updated the task list.

@tegefaulkes
Copy link
Contributor Author

Re-based on client-refactoring.
So far I've split the ClientService and AgentService into two servers, the clientService has TLS enabled while the agentservice does not. I've split host and port information in PolykeyAgent for each server.

what is left is to confirm that the client communication is over TLS and that the agent communication still works. and maybe anything else I didn't think of.

@tegefaulkes
Copy link
Contributor Author

Just tested and confirmed that the clientService is working over TLS and the agentService is insecure.
I tested both of them with a simple echo test and checking if the client was secure.

The tests are located at tests/client/PolykeyClient.test.ts:142 Can connect and echo over TLS and tests/agent/GRPCClientAgent.test.ts:204 Can connect over insecure connection.

If no other issues pop up with this. this should be fine to close when MR !210 Post session-and-misc fixes is merged.

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Aug 30, 2021 via email

@tegefaulkes
Copy link
Contributor Author

Yes, both tests check if the echo command worked and if the connection was secure with expect(pkClient.grpcClient.secured).toBeTruthy()

@tegefaulkes
Copy link
Contributor Author

I'm moving this over to QA since the implementation is done.

@CMCDragonkai CMCDragonkai added the security Security risk label Sep 2, 2021
@CMCDragonkai
Copy link
Member

Done now. But the session token stuff requires a wiki diagrams and us to work out the exact behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development r&d:polykey:core activity 1 Secret Vault Sharing and Secret History Management security Security risk
Development

No branches or pull requests

3 participants