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

logdog: Filter sensitive settings from API output #1777

Merged
merged 1 commit into from
Oct 22, 2021

Conversation

zmrow
Copy link
Contributor

@zmrow zmrow commented Oct 14, 2021

Description of changes:

    Previously, `logdog` used the `exec` mode to run `apiclient` and dump
    everything from the datastore.  Since a few settings now exist that can
    store sensitive data, we need to filter them from being written to disk.
    
    In order to make this change, `logdog` needed to be trained to
    understand the data it was gathering, in order to filter it.  A new
    `settings` mode was added specifically for gathering settings.  This
    mode uses the `apiclient` and `datastore` libraries to be able to
    de/serialize the output, filter it, and then serialize it back to
    disk

For now, we're filtering all user-data fields, the Kubernetes bootstrap token, and https proxy.

Testing done:

  • Ran a vmware-k8s-1.20 with user data for both host containers, a bootstrap container with user data, and the required k8s token. Ran logdog and inspected the output, which did not contain any user data, or k8s token. Relevant sections below:
...
  "kubernetes": {
    "cluster-certificate": <removed for clarity's sake, it's really long :) >,
    "api-server": "https://198.18.5.50:6443",
    "authentication-mode": "tls",
    "standalone-mode": false,
    "server-tls-bootstrap": false,
    "cloud-provider": "external",
    "cluster-dns-ip": "10.96.0.10",
    "cluster-domain": "cluster.local",
    "node-ip": "198.19.128.120",
    "pod-infra-container-image": "k8s.gcr.io/pause:3.2"
  }
  "host-containers": {
    "control": {
      "source": "public.ecr.aws/bottlerocket/bottlerocket-control:v0.5.2",
      "enabled": true,
      "superpowered": false
    },
    "admin": {
      "source": "public.ecr.aws/bottlerocket/bottlerocket-admin:v0.7.2",
      "enabled": true,
      "superpowered": true
  "bootstrap-containers": {
    "bear": {
      "source": "<my private container>",
      "mode": "off"
    }
  },
...

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@zmrow zmrow requested review from tjkirch, webern and bcressey October 14, 2021 20:57
@zmrow zmrow force-pushed the logdog-sensitive-settings branch from e04b29b to 550212e Compare October 14, 2021 21:26
@zmrow
Copy link
Contributor Author

zmrow commented Oct 14, 2021

^ Fixed up the tests now that things are async.

sources/logdog/src/error.rs Show resolved Hide resolved
sources/logdog/src/log_request.rs Outdated Show resolved Hide resolved
sources/logdog/src/log_request.rs Show resolved Hide resolved
Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

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

It might not be obvious to a user that these settings were removed, which could lead someone astray if the issue under investigation is related to one of the sensitive settings. I'm not sure what to suggest though, this is the lesser of evils for sure.

Previously, `logdog` used the `exec` mode to run `apiclient` and dump
everything from the datastore.  Since a few settings now exist that can
store sensitive data, we need to filter them from being written to disk.

In order to make this change, `logdog` needed to be trained to
understand the data it was gathering, in order to filter it.  A new
`settings` mode was added specifically for gathering settings.  This
mode uses the `apiclient` and `datastore` libraries to be able to
de/serialize the output, filter it, and then serialize it back to
disk.
@zmrow zmrow force-pushed the logdog-sensitive-settings branch from 550212e to 4a6b40e Compare October 15, 2021 14:48
@zmrow
Copy link
Contributor Author

zmrow commented Oct 15, 2021

^ Implemented @tjkirch 's suggestions

@zmrow
Copy link
Contributor Author

zmrow commented Oct 15, 2021

It might not be obvious to a user that these settings were removed, which could lead someone astray if the issue under investigation is related to one of the sensitive settings. I'm not sure what to suggest though, this is the lesser of evils for sure.

Good point, but I would agree this is the lesser of evils. A user should still be able to fetch these settings via apiclient if they're needed for troubleshooting.

@@ -25,6 +27,15 @@ const COMMON_REQUESTS: &str = include_str!("../conf/logdog.common.conf");
/// The `logdog` log requests that are specific to the current variant.
const VARIANT_REQUESTS: &str = include_str!("../conf/current/logdog.conf");

/// Patterns to filter from settings output. These follow the Unix shell style pattern outlined
/// here: https://docs.rs/glob/0.3.0/glob/struct.Pattern.html.
const SENSITIVE_SETTINGS_PATTERNS: &[&str] = &[
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the cluster certificate be added to this list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so - I believe it's public.

@zmrow zmrow merged commit 8af0e4f into bottlerocket-os:develop Oct 22, 2021
@zmrow zmrow deleted the logdog-sensitive-settings branch October 22, 2021 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants