@@ -86,20 +86,31 @@ invoke the tools they already depend upon.
86
86
- Enable an ecosystem of users authoring plugins and sharing them
87
87
- Reduce friction for publicly published whitebox ` kustomization.yaml ` s to generate Secrets
88
88
89
-
90
89
## Proposal
91
90
92
91
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
97
103
- 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.
103
114
104
115
## Risks and Mitigations
105
116
@@ -111,37 +122,27 @@ Required steps to exploit:
111
122
112
123
- Alice executes (via ` -k ` or ` kustomize ` ) an untrusted kustomization.yaml containing
113
124
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 `
119
136
120
137
Analysis:
121
138
122
139
This is a very low risk profile, with Alice having to install the targeted binary on their
123
140
PATH as a kustomize plugin (using the name-prefix), the binary would have to be one that could
124
141
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
126
143
to get Alice to perform these steps, he would likely be able to get her to run
127
144
` $ curl <site> | bash ` which would be a more effective technique.
128
145
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
-
145
146
## Alternatives Considered
146
147
147
148
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.
185
186
186
187
Update the "Kubectl Book" Secret Generator chapter.
187
188
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
+
188
193
## Implementation History
189
194
190
195
(TODO add PR's here)
0 commit comments