Repository navigation
feat(ingress): make the ECDH curves of proxied upstreams configurable - #4697
ThxCode-Chen wants to merge 1 commit into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4697 +/- ##
=======================================
Coverage ? 52.88%
=======================================
Files ? 89
Lines ? 13842
Branches ? 0
=======================================
Hits ? 7321
Misses ? 6042
Partials ? 479
🚀 New features to boost your workflow:
|
c2f1568 to
6960d3f
Compare
|
In the case where the provider has a proxy, it currently appears that EnvoyFilter cannot support the reconfiguration of ecdhCurves. When a proxy is present, we hope to have support for reconfiguring ecdhCurves. |
johnlanni
left a comment
There was a problem hiding this comment.
Review: request changes — engineering is solid; two changes requested (one is a design re-home)
First, the good news: the mechanism analysis in this PR is excellent and independently verified. The REMOVE+ADD cluster rewrite in constructProxyEnvoyFilters() (ingress_config.go:1996-2073) genuinely discards the Istio-generated cluster — the only place meshConfig.tlsDefaults.ecdhCurves and DestinationRule TLS settings are applied — and the rebuilt UpstreamTlsContext carries only the SNI. I also verified the curves land on the correct hop: the local proxy listener uses HTTP CONNECT tunneling (%REQUESTED_SERVER_NAME%), so the ClientHello reaches the real upstream and ecdh_curves on the rewritten cluster governs the actual handshake. The opt-in semantics, the drop-unsupported-names-with-warning behavior, and both test assertions are correct.
Requested change 1: re-home the config from global ConfigMap to per-registry
Please move ecdhCurves from the higress-config ConfigMap to McpBridge.spec.registries[], next to the existing sni field (api/networking/v1/mcp_bridge.pb.go RegistryConfig):
- Scope match: the affected surface is exactly the registries bound via
proxyName— a per-upstream property. A global list forces operators into a union of all upstreams' needs, which weakens the handshake posture of every other proxied service (more curves = larger attack surface). - Precedent:
sniis precisely "per-registry upstream TLS parameter" —ecdhCurvesbelongs beside it, and the emission point (ingress_config.go:2035-2041) already reads registry fields one by one, so the code motion is small. - Coverage: Ingress annotations would miss pure-McpBridge registrations (non-K8s domains); RegistryConfig covers both.
- Unset on a registry = current behavior (no
tls_paramsemitted) — same opt-in guarantee, better granularity.
Requested change 2: fill the PR template's agent-participation section
The commit carries Co-Authored-By: Claude (material agent participation), but the PR body skips §IV/§VII entirely. Per AGENTS.md, the issue-spec gate applies — and since the verified-maintainer exception requires maintain/admin (your current role on this repo is read), the normal path applies to this PR: please fill in §IV (choose the applicable participation checkbox), §VII (AI disclosure), and link any Proposal/Design issue. For a scoped, opt-in config knob like this one, a full Proposal is likely overkill — a maintainer can waive on the record once the disclosure is filled.
Minor items (non-blocking, feel free to fold into the next push)
ingress_config.go:1912-1913: the comment "the default set is then applied" is inaccurate — nothing is applied; the context is left untouched (the comment at:1924-1925is the correct one).ingress_config.go:1932: Istio'sValidECDHCurvesaccepts names BoringSSL may reject (e.g.X25519Kyber768Draft00); a rejected name fails transport-socket init → cluster NACK → 503, the exact failure this knob exists to prevent. Consider narrowing the accepted set or documenting the risk.global.go:85-86: worth noting X25519 is not FIPS-approved — the PR's own example list would fail on a FIPS gateway.global.go:176-179:deepCopyGlobaldrops the new field (not functional today, but a trap for the next consumer).proxy_envoyfilter_test.go: SNI/endpoint preservation is only asserted in the unset case — add the configured case.- Docs:
helm/core/values.yaml/ README don't mention the knob (fine to omit from defaults for opt-in, but worth documenting — adjust for the new location).
Follow-up (not this PR)
The real root fix is for constructProxyEnvoyFilters() to merge with the Istio-generated TLS context instead of replacing transport_socket wholesale — then meshConfig/DestinationRule settings would flow naturally and this knob could eventually be retired. Would you like to open that issue, or shall we?
A friendly note on AI-assisted contributions
To be clear: AI-assisted contributions are welcome here — a good number of recent changes in this repo were developed with AI assistance, and the quality bar this PR demonstrates (the mechanism analysis, the reproduction, the tests) is exactly what we hope for. The governance template (§IV/§VII) isn't friction against AI use — it exists so that the review can account for how a change was produced, and so agent-driven work gets the same review rigor as human-only work. Fill it in and you're all set; if anything in the process is unclear, ask away. We'd love to see more contributions from you.
6960d3f to
14e679a
Compare
|
Thanks for the review — both requested changes are in, plus the minor items. ecdhCurves now lives on McpBridge.spec.registries[] next to sni (the global higress-config item is gone entirely); the accepted names are narrowed to P-256/P-384/P-521/X25519, so a name Envoy cannot use is dropped instead of NACKing the cluster; the "default set" comment is gone, and the configured case now asserts the SNI/endpoint invariants too. §IV/§VII are filled in the PR body — no Proposal/Design exists, so I marked the gate noncompliant and asked for a waiver on the record rather than claiming an exception. Re the follow-up: please go ahead and own it — I am not familiar with that part of the logic. Thank you. If possible, please @-mention me when the follow-up code is submitted, so I can follow the progress. One more thing worth flagging: I tested this on the all-in-one deployment, and the apiserver shipped with it needs a corresponding update. It currently depends on github.com/alibaba/higress/v2 v2.1.8 and would have to reference a newer Higress version to pick up the new CRD field. Is it right to bump that dependency only after this change is merged (i.e. once it is available in a published version)? I will update it at that point.@johnlanni |
The cluster rebuilt for an McpBridge service bound to a proxy server carries only the SNI of the upstream, so Envoy falls back to the default curves of its TLS library (X25519, P-256). An upstream whose certificate uses another curve (e.g. ECDSA P-384) is then rejected during the handshake under TLS 1.2 (RFC 8422, section 5.1.1). Add an optional ecdhCurves field to McpBridge.spec.registries[], next to sni, so the curves are declared per upstream; names that Envoy cannot use are dropped with a warning. When the field is unset, the generated TLS context is left unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: ThxCode-Chen <cwchen1995@gmail.com>
14e679a to
63711de
Compare
I. Summary
A service registered in
McpBridgeand bound to a proxy server(
spec.registries[].proxyName) gets its cluster rebuilt inconstructProxyEnvoyFilters(): the cluster is replaced by aSTATICone pointing at the localproxy listener, and its
transport_socketis rebuilt carrying only the SNI of the upstream.Everything Istio would derive from the
DestinationRule/ mesh configuration for that cluster istherefore dropped — including
meshConfig.tlsDefaults.ecdhCurves— and Envoy falls back to thedefaults of its linked TLS library, which are
X25519andP-256for non-FIPS BoringSSL builds(see
TlsParameters.ecdh_curvesinenvoy/extensions/transport_sockets/tls/v3/common.proto).An upstream that only presents a certificate on another curve is then unreachable: under TLS 1.2
the server must not use a certificate whose curve is missing from the client's
supported_groups(RFC 8422, §5.1.1), so it aborts the handshake and the gateway returns 503 with
SSLV3_ALERT_HANDSHAKE_FAILURE/HANDSHAKE_FAILURE_ON_CLIENT_HELLO.This PR adds an optional
ecdhCurvesfield toMcpBridge.spec.registries[], next to the existingsnifield, so the curves can be declared per upstream:transport socket fail to initialize and reject the whole cluster configuration);
code path.
Compatibility: additive CRD field; older control planes ignore it.
II. Related issue
N/A — no issue was filed for this; the failure was diagnosed from a production 503 (see §V).
III. Change type
IV. Agent participation and issue-spec gate
For material participation that does not use the verified maintainer/administrator exception,
check each timed obligation:
Issues, and authorized implementation TASKs linked the work to the applicable SPECs.
verification evidence is recorded in §V (unit tests plus the reproduction below).
Overall gate status:
Gate-status explanation:
The change was implemented before any Proposal/Design Issue existed, so the first two timed
obligations were not satisfied. The author is aware of the policy in
docs/developers/agent-assisted-contributions.mdand is not claiming an exception: no authenticatedghcheck was run, and the author's role on this repository isread, so theverified-maintainer/administrator exception does not apply.
Requested action: because the change is a scoped, opt-in CRD field with no behavior change when
unset, the author asks the maintainers to waive the Proposal/Design requirement on the record and
evaluate the change on its merits (§VI lists the follow-up work that would address the root cause).
Trivial-exception explanation (or N/A): N/A — the change is material.
Verified maintainer/administrator exception evidence (or N/A): N/A — the exception is not used.
Approved Proposal Issue URL (or N/A with explanation): N/A — no Proposal Issue exists; see the
gate-status explanation.
Approved Design Issue URL (or N/A with explanation): N/A — no Design Issue exists; see the
gate-status explanation.
Maintainer approval link(s) (or N/A with explanation): N/A — implementation predates any
approval.
Authorized implementation TASK link(s) (or N/A with explanation): N/A — no issue-spec TASKs
exist.
Verification Plan and verification TASK/evidence link(s) (or N/A with explanation): N/A — no
Design Issue exists; the verification performed is recorded in §V.
V. Testing and verification
Test and deterministic rerun commands:
Environment and configuration:
Exact tested revision, version, image tag/digest, manifests, and values:
Baseline reproduction evidence for bug fixes (or N/A with explanation):
Before the change, against an upstream that presents a single ECDSA P-384 certificate (host redacted):
The corresponding ClientHello captured on the gateway's egress carries
supported_groups = [X25519(0x001d), secp256r1(0x0017)](nosecp384r1), and the upstream answerswith a fatal alert 40 while the handshake is still at the ClientHello. This is not an SNI problem:
an unknown SNI produces
unrecognized_name(112), nothandshake_failure(40).Fixed-version verification evidence for bug fixes (or N/A with explanation):
Unit tests (same commit):
pkg/ingress/config/proxy_envoyfilter_test.goasserts, for the proxy-bound registry:ecdhCurvesunset → nocommon_tls_contextis emitted, and the SNI plus the local proxyendpoint (
127.0.0.1:<listenerPort>) are unchanged;ecdhCurves: ["X25519","P-256","P-384","X25519Kyber768Draft00","bogus"]→ exactly["X25519","P-256","P-384"]is emitted, with the same SNI and endpoint assertions.Live end-to-end verification on a running gateway (a request against an upstream with a P-384
certificate, with and without the new field) has not been performed; the author can run it in a
disposable cluster on request.
Wasm source revision and SHA-256 (or N/A with explanation): N/A — control-plane change only.
VI. Special notes for reviewers
spec.registries[].proxyName) are affected;everything else keeps the Istio-generated TLS context, where
meshConfig.tlsDefaults.ecdhCurvescontinues to apply.
security.ValidECDHCurves(
P-256,P-384,P-521,X25519): names such asX25519Kyber768Draft00orX25519MLKEM768are not implemented by every TLS library, and an unsupported name makes thetransport socket fail to initialize, which rejects the whole cluster configuration and would
break every service behind the cluster — the exact failure this field exists to avoid.
X25519is not FIPS approved; on a gateway built for FIPS 140-2 onlyP-256/P-384should belisted. This is noted in the API comment.
api/networking/v1/mcp_bridge.pb.gowas regenerated withprotoc-gen-go v1.31.0+buf v1.28.1; the two CRD manifests were updated by hand becausecue-genis no longer published withistio.io/toolsin this environment (the added schemaentry follows the exact shape of the neighbouring
repeated stringfields). Please re-runmake gen-apiwhen convenient to confirm the artifacts match.constructProxyEnvoyFilters()to merge with the Istio-generated TLS context instead of replacingtransport_socketwholesale; that would letmeshConfig/DestinationRulesettings flownaturally and would make this field unnecessary. It requires changes in the internal control-plane
TLS generation (the packet-level EnvoyFilter semantics of the rewritten cluster, and how the
Istio-generated TLS context is produced) that the author is not familiar with, so the author
suggests the maintainers own it. The analysis and reproduction recorded in §V/§VI are available as
input, and the author will assess the size of the change and open a tracking issue separately
rather than proposing a hand-rolled internal change. Two candidate directions, for reference only:
(a) emit the relevant
meshConfig.tlsDefaultsvalues into the TLS context generated for proxiedclusters; (b) stop replacing the socket wholesale, which first requires confirming at the Envoy
level how a
MERGEpatch treats theAny-typedtyped_config.VII. AI coding disclosure
Tool(s) used: Claude Code (Anthropic), driving an agent that read the repository, produced the
patch, and ran the build and unit tests locally.
Prompts or instructions
Summarized and redacted (internal hostnames, addresses and credentials removed):
upstream_transport_failure_reason: ... SSLV3_ALERT_HANDSHAKE_FAILURE | HANDSHAKE_FAILURE_ON_CLIENT_HELLO; the upstream is reached through a proxy configured inMcpBridge. Explain why."openssl s_client -tls1_2 -curves X25519:P-256(alert 40) and disappears whenP-384is added to the client's curves. Add a wayto configure the curves of the TLS context that Higress generates for proxy-bound registries."
ecdhCurvesfrom the globalhigress-configConfigMap toMcpBridge.spec.registries[], next tosni", narrow the accepted curve names, correct thecomment that claimed a default was applied, note the X25519/FIPS caveat, and assert the
SNI/endpoint invariants in the configured case as well.
AI-assisted work summary
Key decisions and considerations:
UpstreamTlsContextcarrying only the SNI→ library default curves) was confirmed against a packet capture of the gateway's egress and
against the generated configuration, before any code was written.
byte as before, so no existing deployment changes behavior.
socket initialization failure that would NACK the cluster configuration.
updated by hand because
cue-gencould not be installed in this environment.