Commit ad26f69
fix(security): confine CRI localhostProfile seccomp path to the seccomp root (#143)
LOW. `parse_localhost_seccomp_deny` did `std::fs::read_to_string(localhost_ref)`
with no path confinement. `localhost_ref` is the pod's
`securityContext.seccompProfile.localhostProfile` — attacker-settable through the
CRI by anyone who can create pods — so it was an arbitrary host-file OPEN
primitive (a path-traversal / file-existence oracle). Information disclosure is
limited (the parse error is only warn-logged, never returned to the gRPC caller,
and content only escapes as syscall names from valid OCI-seccomp JSON into the
attacker's own container), hence LOW — but the missing guard is real.
Fix: `confined_seccomp_path(localhost_ref, root)` rejects any `..` component and
requires an absolute ref to lie within the seccomp root; a relative ref resolves
under it. The root is injected (default /var/lib/kubelet/seccomp via
`seccomp_profile_root()`, override A3S_BOX_SECCOMP_PROFILE_ROOT) so the check is
testable without process-global env. An out-of-root/traversing ref is rejected
and the caller falls back to RuntimeDefault (never unconfined).
Tests: new confines_localhost_profile_to_root_and_rejects_traversal (rejects
`../../etc/passwd`, `/etc/passwd`, prefix-confusion, etc.); the two existing
parse_localhost_seccomp_deny tests now pass their tempdir as the root. Full
a3s-box-cri lib suite (250) green; neuter-verified (disabling the root check
makes the new test FAIL on /etc/passwd); fmt + clippy clean.
Completes the untrusted-input security audit (4/4): after #141 (CRITICAL digest
traversal), #142 (HIGH/MED bombs), #140 (HIGH whiteout deletion).
Co-authored-by: Roy Lin <roylin@a3s.box>1 parent 0e4ed61 commit ad26f69
2 files changed
Lines changed: 87 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
213 | 255 | | |
214 | 256 | | |
215 | 257 | | |
| |||
218 | 260 | | |
219 | 261 | | |
220 | 262 | | |
221 | | - | |
222 | | - | |
223 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
224 | 270 | | |
225 | 271 | | |
226 | 272 | | |
| |||
249 | 295 | | |
250 | 296 | | |
251 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
252 | 330 | | |
253 | 331 | | |
254 | 332 | | |
| |||
1151 | 1229 | | |
1152 | 1230 | | |
1153 | 1231 | | |
1154 | | - | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
1155 | 1236 | | |
1156 | 1237 | | |
1157 | 1238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1955 | 1955 | | |
1956 | 1956 | | |
1957 | 1957 | | |
1958 | | - | |
| 1958 | + | |
1959 | 1959 | | |
1960 | 1960 | | |
1961 | 1961 | | |
| |||
1966 | 1966 | | |
1967 | 1967 | | |
1968 | 1968 | | |
1969 | | - | |
| 1969 | + | |
1970 | 1970 | | |
1971 | 1971 | | |
1972 | 1972 | | |
| |||
0 commit comments