Repository navigation
Commit 96a84de
authored
fix(backend): handle IPv6 single-stack in outbound URL and TLS cert validation (#10418)
* fix(backend): handle IPv6 single-stack in outbound URL + TLS cert validation
On IPv6-only clusters the dashboard backend failed TLS hostname
validation against the Kubernetes API server (ERR_TLS_CERT_ALTNAME_INVALID),
returning HTTP 500 for /api/config, storageclasses, etc. Two distinct
failure modes:
- Pattern 1 (truncated host): raw IPv6 literals were concatenated into
host:port URLs without brackets, so the first colon truncated the host
to its first hextet (e.g. fc00:30::1 -> host=fc00).
- Pattern 2 (full host, still rejected): outbound calls set no custom
checkServerIdentity, so Node's default IP identity check rejected a
correctly-formed IPv6 host whose cert SAN was present but in a different
canonical form (compressed vs expanded, or listed as a DNS SAN).
Adds backend/src/utils/networkUtils.ts with:
- bracketHostIfIPv6 to safely wrap IPv6 literals during URL construction
- normalizeIPv6 to canonicalize addresses for comparison
- ipv6AwareCheckServerIdentity, which defers to Node's default check and
only falls back to normalized IPv6 SAN comparison for IPv6 hosts
Routes outbound URL builders (proxy, feature store ClusterIP) through the
bracket helper, and wires the IPv6-aware identity check into proxyCall and
the feature store HTTPS request. Non-IPv6 hosts are completely unaffected.
* fix(backend): address review - structured IPv6 cert check, fix Feast host
Addresses PR review findings:
- Cert identity (CWE-295): replace the hand-rolled SAN string parsing and
the DNS-SAN fallback with Node's structured X509Certificate.checkIP(),
which matches an IPv6 host only against real iPAddress SANs with proper
canonicalization. This is fail-closed: no comma-splitting of
subjectaltname (so a comma inside a quoted SAN can't masquerade as an IP
entry), and a DNS SAN never authorizes an IP host.
- Feast IPv6 request: makeAuthenticatedHttpRequest now passes the URL
string to http(s).request so Node strips the IPv6 brackets when deriving
the connect host (URL.hostname keeps brackets, which the hostname option
would reject). Keeps bracketHostIfIPv6 in URL construction.
- Drop the no-op checkServerIdentity from the Feast path (it uses
rejectUnauthorized: false, so a custom identity check has no effect).
Tests rewritten to use a real certificate fixture for the structured check,
including a regression that a DNS-only SAN is rejected for an IP host.
* test(backend): update Feast https.request mock for url-first signature
makeAuthenticatedHttpRequest now calls request(url, options, callback); the
mock previously assumed request(options, callback), so the response callback
was never invoked. Read the callback from the last argument.
* test(backend): cover proxyCall IPv6 checkServerIdentity wiring
Addresses review follow-up: adds integration tests that proxyCall installs
ipv6AwareCheckServerIdentity on https requests (including when a proxy agent
is present, since the agent tunnels TLS to the origin) and omits it for http
targets.
* fix(backend): scope IPv6 cert check to IPv6 hosts; real-cert tests
Addresses remaining review findings:
- Scope checkServerIdentity to IPv6 destinations: proxyCall now only installs
ipv6AwareCheckServerIdentity when the target host is an IPv6 literal (new
isIPv6Url helper). DNS and IPv4 https targets keep Node's default identity
check untouched (CodeRabbit).
- Add representative tests that exercise the REAL Node identity checker (no tls
mock) against real certificate fixtures: an IPv6 host is accepted against an
IP Address SAN, and rejected when the address is only a DNS SAN or matches no
SAN. Documents that current Node already canonicalizes IP SANs by default, so
the structured fallback is defensive hardening (Fullsend test-inadequate).
- Cover the IPv6-only wiring in proxyCall (IPv6 https sets the check; DNS https
and http do not).
* fix(backend): skip IPv6 cert check on proxied (E2E) connections
Addresses review: only install ipv6AwareCheckServerIdentity for direct IPv6
HTTPS connections, not when a proxy agent is in use. getProxyAgent only returns
an agent under E2E_USE_PROXY_FROM_ENV (E2E-only), and a tunneled TLS connection
may not surface the origin host to the identity callback, so we leave Node's
default check in place there rather than risk validating against the proxy host.
The production IPv6-cluster path (no proxy) is unchanged.
* fix(backend): apply IPv6 cert check to makeApiClient k8s clients too
The IPv6-aware checkServerIdentity was only wired into proxyCall. The typed
Kubernetes clients from kc.makeApiClient(...) use @kubernetes/client-node's
own 'request' transport, which never received it — so startup reads
(plugins/kube.ts) and the dashboard-config watcher (resourceUtils.ts) could
still fail with ERR_TLS_CERT_ALTNAME_INVALID on IPv6 single-stack clusters.
Root cause confirmed by reviewers: Node 22.23.1/.2 regression nodejs/node#64144
mis-normalizes IPv6 literals in the default identity check (fixed in later
22.x), so the fallback is genuinely load-bearing on the shipped UBI9 Node.
Adds applyIpv6AwareIdentityCheck(kc): wraps KubeConfig.applyToRequest to attach
an https.Agent carrying the kube TLS material plus ipv6AwareCheckServerIdentity.
A pre-built agent is required because 'request' drops a bare checkServerIdentity
option and pools agents by a key that ignores it. Applied to the shared kc and
the per-user Feast userKc. Verified end-to-end against real client-node +
makeApiClient; added unit coverage for the wiring.
* fix(backend): only attach IPv6 TLS agent for HTTPS API servers
Addresses review: applyIpv6AwareIdentityCheck attached an https.Agent
unconditionally. When KubeConfig.loadFromDefault() falls back to
http://localhost:8080, assigning an HTTPS agent to an HTTP request makes Node
reject it with ERR_INVALID_PROTOCOL. Now no-op unless the current cluster
server is https. Added unit coverage for the http-fallback and no-cluster
cases.1 parent 243f25f commit 96a84de
8 files changed
Lines changed: 541 additions & 13 deletions
File tree
- backend/src
- __tests__
- plugins
- routes/api/featurestores
- utils
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
| |||
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
139 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
498 | 500 | | |
499 | 501 | | |
500 | 502 | | |
501 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
502 | 506 | | |
503 | 507 | | |
504 | 508 | | |
| |||
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
| 561 | + | |
561 | 562 | | |
562 | 563 | | |
563 | 564 | | |
| |||
568 | 569 | | |
569 | 570 | | |
570 | 571 | | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | 572 | | |
575 | 573 | | |
576 | 574 | | |
| |||
579 | 577 | | |
580 | 578 | | |
581 | 579 | | |
582 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
3 | 17 | | |
4 | 18 | | |
5 | 19 | | |
| |||
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
0 commit comments