Commit b90170b
committed
fix(aws): harden AWS SSO importer and provisioner against hostile inputs
Address findings from a pre-PR security review. Each fix is local to the
AWS SSO net-new code introduced in the previous commit; pre-existing SDK
bugs surfaced by the same review are deferred to a follow-up PR.
Importer (plugins/aws/sso_importer.go):
- Validate sso_start_url (https + non-empty host)
- Regex-check sso_account_id (12 digits) and sso_region
- Reject NUL bytes mid-value
- Refuse non-regular, symlinked, or non-owned AWS_CONFIG_FILE overrides
- Match SDK ~/ prefix convention (bare ~root no longer silently joined)
- Use ini.LoadSources directly with strict botocore-parity options:
KeyValueDelimiters="=", IgnoreContinuation=true, Loose=true
Provisioner (plugins/aws/sso_provisioner.go):
- assertSSOTokenCacheSafe rejects symlinks, non-regular files, group/world
readable modes, and files not owned by the current uid before passing
the path to ssocreds.New
- translateSSORetrieveError whitelists known smithy codes (Unauthorized,
Forbidden, ResourceNotFound, TooManyRequests); unknown codes get a
generic plugin-controlled message so server-controlled error text
doesn't reach user-visible output
- Wrap sso:GetRoleCredentials in context.WithTimeout(30s)
SDK validator (sdk/schema/credential_type.go):
- Replace the previous severity downgrade with an opt-in
AllowsExternalSecretCache flag on CredentialType. The "must have at
least one secret field" check is restored to Error severity globally;
only the SSO Profile (whose bearer token lives in the AWS SDK's
external cache) opts out
Tests (plugins/aws/sso_*_test.go):
- Hostile-input cases for the importer (non-HTTPS, file:// scheme, short
account ID, malformed region, NUL byte, malformed section header,
duplicate-section last-wins)
- Direct unit tests for assertSSOTokenCacheSafe and
validateExternalConfigPath covering symlink, world-readable,
directory, non-existent
- Smithy-error translation table with a token-leak guard that asserts no
JSON-key-shaped or JWT-shaped fragment from a hostile server message
ever appears in the translated user-visible error
Deferred to follow-up PR (pre-existing code, out of scope here):
- F-2: plugins/registry.go:50-60 GetCredentialType ignores credentialName
- F-6: sdk/schema/plugin.go:116-134 MarshalJSON truncates to Credentials[0]
- F-7: plugins/aws/cli_provisioner.go:28-53 strip-by-value mis-routing
- F-9: sdk/importer/helpers.go:41-53 SanitizeNameHint byte-truncation
- F-15: plugins/aws/sts_provisioner.go:399-405 log.SetOutput global state1 parent 30e52bf commit b90170b
8 files changed
Lines changed: 534 additions & 26 deletions
File tree
- plugins/aws
- sdk/schema
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | | - | |
24 | | - | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
27 | | - | |
| 37 | + | |
| 38 | + | |
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
36 | 63 | | |
37 | 64 | | |
38 | 65 | | |
| |||
51 | 78 | | |
52 | 79 | | |
53 | 80 | | |
54 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
55 | 91 | | |
56 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
57 | 98 | | |
58 | 99 | | |
59 | 100 | | |
| |||
82 | 123 | | |
83 | 124 | | |
84 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
85 | 152 | | |
86 | 153 | | |
87 | 154 | | |
| |||
106 | 173 | | |
107 | 174 | | |
108 | 175 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
112 | 180 | | |
113 | 181 | | |
114 | 182 | | |
| |||
120 | 188 | | |
121 | 189 | | |
122 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
123 | 194 | | |
124 | 195 | | |
125 | 196 | | |
| |||
152 | 223 | | |
153 | 224 | | |
154 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
155 | 242 | | |
156 | 243 | | |
157 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
158 | 266 | | |
159 | 267 | | |
160 | 268 | | |
| |||
0 commit comments