Skip to content

Commit 36b8d83

Browse files
committed
address pr comments
1 parent 0db4133 commit 36b8d83

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

keps/sig-cli/kustomize-exec-secret-generator.md

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,31 @@ invoke the tools they already depend upon.
8686
- Enable an ecosystem of users authoring plugins and sharing them
8787
- Reduce friction for publicly published whitebox `kustomization.yaml`s to generate Secrets
8888

89-
9089
## Proposal
9190

9291
Re-introduce `exec` Secret generators, but require the executables to have a whitelisted prefix
93-
and require a flag.
94-
95-
- Introduce a flag `--secret-generator-exec-prefix` defaulted to `kustomize-sg-`
96-
- Introduce a flag `--enable-exec-secret-generator` defaulted to `false`
92+
and require a flag with the search location for the prefixes.
93+
94+
- Introduce a flag `--sg-exec-prefix` defaulted to `kustomize-sg-`
95+
- if set to the empty string, no prefix is used
96+
- Introduce a flag `--sg-exec-path` defaulted to ``
97+
- Defines where to find the executables
98+
- May be one of:
99+
- (default) the empty string - disable exec secrets altogether
100+
- `$PATH` - any executable in the user's path matching the prefix
101+
- an absolute directory path - only executables matching the prefix in that directory
102+
- a relative directory - only executables matching the prefix in that directory
97103
- Commands provided to generate Secrets *must* start with the prefix, or kustomize will exit 1
98-
- The enable flag *must* be provided if an exec Secret Generator is specified, or kustomize will exit 1
99-
- Command is executed from the `PATH` variable, it cannot be an absolute or relative path
100-
- This is to prevent Carl from publishing a malicious generator with the kustomization.yaml and invoking it
101-
- Users can override the prefix with a string value with `len(value) > 2` - e.g. `sg-`
102-
- Min length is to prevent users from providing an empty value, which would allow arbitrary command execution
104+
- The `sg-exec-path` flag *must* be provided if an exec Secret Generator is specified, or kustomize will exit 1
105+
- Command location is restricted to what is supplied in the `sg-exec-path` flag
106+
- Users can override the prefix with a string value of their choice. May use an empty string.
107+
108+
### Introduce new Command in Kustomize for printing out exec commands
109+
110+
Add a new command in kustomize: `kustomize audit secret-generator`
111+
112+
This will print out which commands (including args and flags) will be invoked when kustomize is run,
113+
without actually invoking them. This will generally be helpful for users to view how secrets are generated.
103114

104115
## Risks and Mitigations
105116

@@ -111,37 +122,27 @@ Required steps to exploit:
111122

112123
- Alice executes (via `-k` or `kustomize`) an untrusted kustomization.yaml containing
113124
a SecretGenerator
114-
- Alice opted-in to generation by providing `--enable-exec-secret-generator`
115-
- Alice "installed" the targeted SecretGenerator locally on their PATH
116-
- Added the command starting with `kustomize-sg-` (or whatever they provided via the flag) to her `PATH`
117-
- The installed SecretGenerator can be provided arguments in a way that can be exploited
118-
- e.g. A command like `cat` would not be possible for Carl to exploit in a meaningful way
125+
- Alice opted-in to generation by providing `--sg-exec-path`
126+
- Either
127+
- Option A
128+
- Alice "installed" the targeted SecretGenerator locally on their PATH
129+
- Added the command starting with `kustomize-sg-` (or whatever they provided via the flag) to her `PATH`
130+
- Alice set the `sg-exec-path` to `$PATH`
131+
- The installed SecretGenerator can be provided arguments in a way that can be exploited
132+
- e.g. A command like `cat` would not be possible for Carl to exploit in a meaningful way
133+
- Option B
134+
- Alice set the `sg-exec-prefix` to empty
135+
- Alice set the `sg-exec-path` to `$PATH`
119136

120137
Analysis:
121138

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

129-
### Easy of Use
130-
131-
**Risk:** This is too hard or confusing for users to use.
132-
133-
Required steps to use:
134-
135-
- Alice creates a script to generate the Secret called `kustomize-sg-my-cool-script.sh`
136-
- Alice adds the script to her PATH
137-
- Alice authors the `kustomization.yaml` with a SecretGenerator invoking the script
138-
- Alice runs kustomize with `--enable-exec-secret-generator`
139-
140-
Analysis:
141-
142-
There are a small number of simple and well defined steps that ensure Alice explicitly configures
143-
her environment so that kustomize can execute specific commands.
144-
145146
## Alternatives Considered
146147

147148
Create a plugin mechanism similar to git or kubectl plugins and exec to plugins only.
@@ -185,6 +186,10 @@ Gather user feedback. Determine if there are addressable gaps.
185186

186187
Update the "Kubectl Book" Secret Generator chapter.
187188

189+
- Document security implications of no prefix
190+
- Document security implications of various paths (e.g. relative paths into an untrusted location)
191+
- Document that commands are executed when running `kustomize build`, `kubectl kustomize`, and `kubectl apply -k --dry-run`
192+
188193
## Implementation History
189194

190195
(TODO add PR's here)

0 commit comments

Comments
 (0)