Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittrock committed Mar 13, 2019
1 parent 0db4133 commit 1617d0d
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions keps/sig-cli/kustomize-exec-secret-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,24 @@ invoke the tools they already depend upon.
- Enable an ecosystem of users authoring plugins and sharing them
- Reduce friction for publicly published whitebox `kustomization.yaml`s to generate Secrets


## Proposal

Re-introduce `exec` Secret generators, but require the executables to have a whitelisted prefix
and require a flag.

- Introduce a flag `--secret-generator-exec-prefix` defaulted to `kustomize-sg-`
- Introduce a flag `--enable-exec-secret-generator` defaulted to `false`
and require a flag with the search location for the prefixes.

- Introduce a flag `--sg-exec-prefix` defaulted to `kustomize-sg-`
- if set to the empty string, no prefix is used
- Introduce a flag `--sg-exec-path` defaulted to ``
- Defines where to find the executables
- May be one of:
- (default) the empty string - disable exec secrets altogether
- `$PATH` - any executable in the user's path matching the prefix
- an absolute directory path - only executables matching the prefix in that directory
- a relative directory - only executables matching the prefix in that directory
- Commands provided to generate Secrets *must* start with the prefix, or kustomize will exit 1
- The enable flag *must* be provided if an exec Secret Generator is specified, or kustomize will exit 1
- Command is executed from the `PATH` variable, it cannot be an absolute or relative path
- This is to prevent Carl from publishing a malicious generator with the kustomization.yaml and invoking it
- Users can override the prefix with a string value with `len(value) > 2` - e.g. `sg-`
- Min length is to prevent users from providing an empty value, which would allow arbitrary command execution
- The `sg-exec-path` flag *must* be provided if an exec Secret Generator is specified, or kustomize will exit 1
- Command location is restricted to what is supplied in the `sg-exec-path` flag
- Users can override the prefix with a string value of their choice. May use an empty string.

## Risks and Mitigations

Expand All @@ -111,37 +115,27 @@ Required steps to exploit:

- Alice executes (via `-k` or `kustomize`) an untrusted kustomization.yaml containing
a SecretGenerator
- Alice opted-in to generation by providing `--enable-exec-secret-generator`
- Alice "installed" the targeted SecretGenerator locally on their PATH
- Added the command starting with `kustomize-sg-` (or whatever they provided via the flag) to her `PATH`
- The installed SecretGenerator can be provided arguments in a way that can be exploited
- e.g. A command like `cat` would not be possible for Carl to exploit in a meaningful way
- Alice opted-in to generation by providing `--sg-exec-path`
- Either
- Option A
- Alice "installed" the targeted SecretGenerator locally on their PATH
- Added the command starting with `kustomize-sg-` (or whatever they provided via the flag) to her `PATH`
- Alice set the `sg-exec-path` to `$PATH`
- The installed SecretGenerator can be provided arguments in a way that can be exploited
- e.g. A command like `cat` would not be possible for Carl to exploit in a meaningful way
- Option B
- Alice set the `sg-exec-prefix` to empty
- Alice set the `sg-exec-path` to `$PATH`

Analysis:

This is a very low risk profile, with Alice having to install the targeted binary on their
PATH as a kustomize plugin (using the name-prefix), the binary would have to be one that could
be exploited by Carl, Alice would need to run kustomize against an untrusted `kustomization.yaml`,
and Alice would need to provide the flag `--enable-exec-secret-generator`. If Carl was able
and Alice would need to provide the flag `--sg-exec-path` with `$PATH`. If Carl was able
to get Alice to perform these steps, he would likely be able to get her to run
`$ curl <site> | bash` which would be a more effective technique.

### Easy of Use

**Risk:** This is too hard or confusing for users to use.

Required steps to use:

- Alice creates a script to generate the Secret called `kustomize-sg-my-cool-script.sh`
- Alice adds the script to her PATH
- Alice authors the `kustomization.yaml` with a SecretGenerator invoking the script
- Alice runs kustomize with `--enable-exec-secret-generator`

Analysis:

There are a small number of simple and well defined steps that ensure Alice explicitly configures
her environment so that kustomize can execute specific commands.

## Alternatives Considered

Create a plugin mechanism similar to git or kubectl plugins and exec to plugins only.
Expand Down Expand Up @@ -185,6 +179,9 @@ Gather user feedback. Determine if there are addressable gaps.

Update the "Kubectl Book" Secret Generator chapter.

- Document security implications of no prefix
- Document security implications of various paths (e.g. relative paths into an untrusted location)

## Implementation History

(TODO add PR's here)

0 comments on commit 1617d0d

Please sign in to comment.