Commit 7d08e2e
Unify subject provider defaulting, hard-error xaa (#5708)
* Unify subject provider defaulting, hard-error xaa
The YAML and operator paths each defaulted a backend's
SubjectProviderName to the first configured upstream, but drifted
apart: the YAML path was missing aws_sts entirely (#5687), so an
aws_sts backend with an unset field failed at request time instead
of being defaulted. Separately, both paths silently picked
upstream[0] for xaa even with multiple upstreams configured, a
security-relevant footgun since sending the wrong subject token to
Step A yields a confusing IdP error or a token minted for the wrong
subject (#5697).
Extract a shared authtypes.DefaultSubjectProviderName helper used by
both the YAML (pkg/vmcp/config/defaults.go) and operator
(cmd/thv-operator/controllers/virtualmcpserver_controller.go) paths,
covering token_exchange, aws_sts, and xaa. xaa now hard-errors on
ambiguous multi-upstream configs on both paths; on the operator side
this surfaces as a non-fatal per-backend AuthConfigError condition
rather than a Reconcile failure.
Fixes #5687, #5697
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Deep-copy backend strategy, correct xaa risk framing
DefaultSubjectProviderName shallow-copied each strategy's sub-config
by hand, leaving slice fields (Scopes, RoleMappings) aliased with the
caller's original struct. Use the generated DeepCopy() instead, which
removes the aliasing risk and lets the doc comment drop its "never
mutated" hedge.
The doc comment also framed the wrong-subject-token risk as specific
to xaa, which isn't accurate: token_exchange and aws_sts read from
the same UpstreamTokens map and are exposed to the identical risk.
xaa hard-errors first purely because it has no existing deployments
to break; hard-erroring the other two would be a breaking change
needing a deprecation path, tracked separately in #5697.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Exclude backends with failed auth from served config
A backend whose auth-strategy injection failed (e.g. an ambiguous xaa
config) was omitted from OutgoingAuthConfig.Backends, but still fully
served in the ConfigMap's static backend list. At runtime,
ResolveForBackend falls through to Default for any backend absent
from that map, so the backend ended up authenticated with a
different, valid-looking strategy instead of being rejected -
exactly the wrong-identity outcome this defaulting work exists to
prevent, just relocated to a different code path (CWE-285/863).
Track failed backend names via backendsWithFailedAuth and exclude
them from convertBackendsToStaticBackends's output entirely, mirroring
the existing k8s.go precedent of dropping a backend outright when its
auth config can't be resolved, rather than serving it with a
fallback strategy.
A backend can accumulate an auth error from one path (e.g. a broken
discovered ExternalAuthConfigRef) while still resolving a valid
strategy from another (e.g. an inline override) - discoverExternalAuthConfigs
records the discovered-path error before checking whether an inline
override makes it irrelevant. backendsWithFailedAuth only excludes a
backend if it also lacks a successfully-resolved strategy, so a
backend with valid resolved auth is never dropped just because an
unrelated path also produced an error for the same name.
Also reworded the injectSubjectProviderIfNeeded doc comment: it named
pkg/runner/middleware.go's sibling implementation as if the
duplication were a settled non-issue, when in fact two of the three
call sites operate on the identical UpstreamRunConfig type and are a
legitimate extraction candidate for a future, separate change.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent c46b038 commit 7d08e2e
9 files changed
Lines changed: 1008 additions & 225 deletions
File tree
- cmd/thv-operator/controllers
- pkg/vmcp
- auth/types
- cli
- config
Lines changed: 80 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| |||
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
| |||
2399 | 2413 | | |
2400 | 2414 | | |
2401 | 2415 | | |
2402 | | - | |
2403 | | - | |
2404 | | - | |
2405 | | - | |
2406 | | - | |
2407 | | - | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
2408 | 2434 | | |
2409 | 2435 | | |
2410 | 2436 | | |
| |||
2483 | 2509 | | |
2484 | 2510 | | |
2485 | 2511 | | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
2486 | 2519 | | |
2487 | | - | |
| 2520 | + | |
2488 | 2521 | | |
2489 | 2522 | | |
2490 | 2523 | | |
| |||
2509 | 2542 | | |
2510 | 2543 | | |
2511 | 2544 | | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
2512 | 2552 | | |
2513 | | - | |
| 2553 | + | |
2514 | 2554 | | |
2515 | 2555 | | |
2516 | 2556 | | |
| |||
2520 | 2560 | | |
2521 | 2561 | | |
2522 | 2562 | | |
2523 | | - | |
2524 | | - | |
2525 | | - | |
2526 | | - | |
2527 | | - | |
2528 | | - | |
2529 | | - | |
2530 | | - | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
2531 | 2578 | | |
2532 | 2579 | | |
2533 | 2580 | | |
2534 | | - | |
| 2581 | + | |
2535 | 2582 | | |
2536 | | - | |
2537 | | - | |
2538 | | - | |
2539 | | - | |
2540 | | - | |
2541 | | - | |
2542 | | - | |
2543 | | - | |
2544 | | - | |
2545 | | - | |
2546 | | - | |
2547 | | - | |
2548 | | - | |
2549 | | - | |
2550 | | - | |
2551 | | - | |
2552 | | - | |
2553 | | - | |
2554 | | - | |
2555 | | - | |
2556 | | - | |
2557 | | - | |
2558 | | - | |
2559 | | - | |
2560 | | - | |
2561 | | - | |
2562 | | - | |
2563 | | - | |
2564 | | - | |
2565 | | - | |
2566 | | - | |
2567 | | - | |
2568 | | - | |
2569 | | - | |
2570 | | - | |
2571 | | - | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
| 2583 | + | |
2575 | 2584 | | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
2576 | 2590 | | |
2577 | 2591 | | |
2578 | 2592 | | |
| |||
2590 | 2604 | | |
2591 | 2605 | | |
2592 | 2606 | | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
2593 | 2610 | | |
2594 | 2611 | | |
2595 | 2612 | | |
2596 | 2613 | | |
2597 | 2614 | | |
| 2615 | + | |
2598 | 2616 | | |
2599 | 2617 | | |
2600 | 2618 | | |
2601 | 2619 | | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
2602 | 2626 | | |
2603 | 2627 | | |
2604 | 2628 | | |
| |||
0 commit comments