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

Secure Package Installation #602

Merged
merged 1 commit into from
Mar 5, 2018
Merged

Conversation

mike-stewart
Copy link
Contributor

Description

Fixes /issues/578. This secures the package installation against MITM attacks for linux by downloading the GPG key over HTTPS.

I didn't change the linux repo URLs themselves as there is generally less benefit in downloading the packages over HTTPS given GPG checks. It requires an additional package in some cases, and it can get in the way of caching.

For Windows, I changed the package URL, as I'm not aware of a method to check package signatures there.

Motivation and Context

See #578.

How Has This Been Tested?

Executed tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

@majormoses majormoses self-requested a review March 2, 2018 08:31
Copy link
Contributor

@majormoses majormoses left a comment

Choose a reason for hiding this comment

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

👍 we really needed to do this! However as per my comment in #594 we need to install apt-transport-https on debian based installs to avoid a breaking change.

CHANGELOG.md Outdated
@@ -4,6 +4,7 @@ This file is used to track changes made in recent versions of the Sensu
cookbook. Please see HISTORY.md for changes from older versions of this project.

## [Unreleased]
* Enable gpg check for all linux repo installs using a key downloaded over HTTPS. Download windows MSI over HTTPS. #578 (@mike-stewart)
Copy link
Contributor

Choose a reason for hiding this comment

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

I can fix it up post acceptance but you should use a ### Security header for security changes.

We follow the same changelog guidelines as here and if you are curious on how we version security changes you can read about it here

@@ -23,9 +23,13 @@
when "debian"
include_recipe "apt"

package 'apt-transport-https' do
action :remove
Copy link
Contributor

@majormoses majormoses Mar 2, 2018

Choose a reason for hiding this comment

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

we need to install this not remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry - this was a test commit, just trying to validate an assumption on the Travis build.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, no problem if it is a wip then it's best to label the PR title with [WIP]

Copy link
Contributor

Choose a reason for hiding this comment

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

Also sadly we never added travis and kitchen integration. It's something I want to add when I have the time.

@majormoses majormoses changed the title Secure Package Installation [WIP] Secure Package Installation Mar 2, 2018
@mike-stewart
Copy link
Contributor Author

@majormoses We shouldn't actually need to install apt-transport-https here - as I mentioned in the description of the PR the difference is that we're not installing the package itself over HTTPS, we're just fetching the GPG key. The package can be downloaded securely over HTTP if it's signed with a GPG key that we can trust.

I've confirmed this through a manual test on Ubuntu 16.04. With apt-transport-https not installed, I can fetch the key over HTTPS, add the repo, and install the package.

Let me know if this makes sense. I can dig into the test suite more later to try to prove this if necessary.

@majormoses
Copy link
Contributor

majormoses commented Mar 2, 2018

@mike-stewart gotcha I read the title and the code and after seeing #594 I assumed it was the same deal. 👍 on merging whether we switch over later and agree that a pgp signed artifact is good enough if you download the key over https/ssl. One concern I have about eventually needing to support it down the road is that at some overzealous admin might redirect http -> https. But we can worry about that later.

Let me know if this makes sense. I can dig into the test suite more later to try to prove this if necessary.

Nope I got you, I will run it through the test suites this weekend and if it looks good I will merge and release this before monday.

I won't pretend to know much about windows but from what I read we should be good to use https.

@mike-stewart
Copy link
Contributor Author

Sounds great. I hadn't noticed #594, but that would have some advantages as well. I decided to go with the least change required to get good security.

From what I've read about apt, it's typically best from a compatibility perspective to allow package download over HTTP, as that doesn't break environments that use caching proxies for distributing packages.

@mike-stewart mike-stewart changed the title [WIP] Secure Package Installation Secure Package Installation Mar 2, 2018
@majormoses
Copy link
Contributor

Validated this looks good with linux, the windows vagrant failed because of other reasons:

---- Begin output of vagrant up --no-provision --provider virtualbox ----
STDOUT: Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'mwrock/Windows2012R2' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
STDERR: The box 'mwrock/Windows2012R2' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:

URL: ["https://atlas.hashicorp.com/mwrock/Windows2012R2"]
Error: The requested URL returned error: 404 Not Found

I say :shipit:

@majormoses majormoses merged commit cc3da41 into sensu:develop Mar 5, 2018
@majormoses
Copy link
Contributor

@majormoses majormoses mentioned this pull request Mar 5, 2018
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package Installation Vulnerable to MITM by Default
2 participants