Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Add tls support #2

Merged
merged 8 commits into from
Feb 4, 2019
Merged

Add tls support #2

merged 8 commits into from
Feb 4, 2019

Conversation

brandonbodnar-wk
Copy link

Upstream PR at github#705

Description

This PR adds initial support for enforcing TLS/SSL connections for the databases involved in the schema changes. In this initial pass, a gh-ost user can enforce ssl be used for connections using the --ssl flag on the command line. If the user wishes to enforce checking validity of the database's certificate, the user can also specify a CA certificate in pem format with the --ssl-ca option.

Adding these two options is sufficient for our use case right now in connecting to AWS RDS instances. While there are plenty more options that can be specified by the native mysql client regarding ssl, this can provide a good starting point for other work by those with more complex needs.

Testing

We tested this updated code against an Aurora2 cluster running a MySQL 5.7 compatible engine.

  • For testing we added a user to the mysql cluster with REQUIRE SSL set.
  • We then attempted to run an alter table command using gh-ost against the cluster, but without the new ssl options enabled. As expected we received an access denied when attempting to connect with gh-ost.
  • We then attempted the same alter table command using all the same options, except also adding on the new --ssl flag, along with specifying the --ssl-ca certificate for AWS RDS. The job executed flawlessly.

- Adding a command line option for users to enforce tls/ssl connections
  for the applier, inspector, and binlog reader.
- The user can optionally request server certificate verification through
  a command line option to specify the ca cert via a file path.
- Fixes an existing bug appending the timeout option to the singleton
  applier connection.
@aviary-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Copy link

@ericklaus-wf ericklaus-wf left a comment

Choose a reason for hiding this comment

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

Same commits we previously reviewed.

Copy link

@ericklaus-wf ericklaus-wf left a comment

Choose a reason for hiding this comment

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

+10 This worked on wk-dev when we turned on require SSL.

@teresarevious-wf
Copy link

RM +1 dependencies won't be scanned for this repo. this is a temporary fork/fix for tls, once the PR into the original fork is merged that will be used again.

@matthewbelisle-wf
Copy link

Don't merge this yet @brandonbodnar-wk because once #3 is merged the builds will pass on this.

if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
return errors.New("could not add ca certificate to cert pool")
}
}

Choose a reason for hiding this comment

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

@brandonbodnar-wk Can you tweak the logic here so that if it uses ssl, it verifies the cert by default?

Choose a reason for hiding this comment

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

(Like how curl only skips cert verification if you pass a --insecure flag.)

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

@matthewbalvanz-wf That is not the default behavior for mysql. This (calling --ssl in on the command line) attempts to emulate the behavior of --ssl-mode=REQUIRED in 5.7, which is the same as --enable-ssl for mysql 5.6. That setting only requires that the connection by encrypted with no guarantees about the certificate provided by the server is from a valid CA (self-signed certificates are okay).

Those (like us) who want additional guarantees that the cert is signed by a specific CA authority, can use the additional --ssl-ca flag to behave like --ssl-mode=VERIFY_CA from the mysql command line client.

Copy link
Author

Choose a reason for hiding this comment

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

The caCertificatePath is set using that flag.

Copy link

@matthewbelisle-wf matthewbelisle-wf Feb 4, 2019

Choose a reason for hiding this comment

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

Hmm I see what you're saying @brandonbodnar-wk , but it seems best to make that --ssl flag emulate VERIFY_CA instead, unless an --ssl-insecure flag is specifically set. The rest of the infosec team agrees that having ssl without verification by default is not a good idea. Here's a PR that achieves what I'm thinking.

#4

Can you check that out and merge it if it looks good? Once that's merged then I'll +1 this PR and approve it in the RM console.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @matthewbalvanz-wf. I've made a few tweaks to that PR and merged it here.

@matthewbelisle-wf
Copy link

Security +1

@teresarevious-wf
Copy link

RM +1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants