← Back to Pull requests

kvevents: refuse a non-loopback global ZMQ socket without an explicit opt-in #4106

Merged
ahg-g merged 9 files (132 lines) on Nov 18, 2026 14:24 UTC
View on GitHub
ahg-g ahg-g commented on Nov 09, 2026 11:47 UTC
Author

What type of PR is this?

/kind bug

What this PR does / why we need it:

kvEventsConfig.zmqEndpoint binds one SUB socket that every engine publishes to. A bound socket cannot tell publishers apart, so the pod identity comes from the topic, and any peer that can reach the socket publishes KV events under any pod's identity. Per-pod subscriptions (discoverPods, the default and what every guide uses) attribute events to the dialed pod and do not have this problem.

This PR is the first step of #4105:

  • kvevents.NewPool rejects a zmqEndpoint that binds a non-loopback tcp:// address unless kvEventsConfig.allowUntrustedPublishers is true. ipc://, inproc://, and loopback tcp:// binds stay allowed for single-host deployments. The error names the safe alternative and the opt-in.

  • The producer logs a deprecation notice whenever zmqEndpoint is used.

  • The precise-prefix-cache README documents the trust model and the opt-in.

  • The e2e simulator configs set allowUntrustedPublishers: true, since their simulator pods publish to the EPP's bound socket. The integration test binds 127.0.0.1 and needs no change.
  • Removal of the global socket mode, with the e2e overlays moved to pull mode, is the second step tracked in #4105. zmqEndpoint shipped in v1.0.0, so removal follows the N+2 deprecation policy: this PR is the shim and the startup notice, and the field is removed no earlier than two releases later. llm-d-benchmark's convert-guide pattern binds zmqEndpoint too and is tracked separately.

    One behavior change lands with this PR: a shipped config that binds zmqEndpoint on a non-loopback address without allowUntrustedPublishers fails at startup with an error that names both fixes.

    Which issue(s) this PR fixes:

    Part of #4105

    Test plan:

  • NewPool accepts an empty endpoint, loopback tcp:// (IPv4, localhost, [::1]), ipc://, and inproc://, and rejects 0.0.0.0, *, [::], a routable IP, a hostname, and a malformed endpoint, unless the opt-in is set.

  • Existing pkg/kvevents and precise-prefix-cache tests pass.
  • Release note:
    ``release-note
    The EPP refuses to bind
    kvEventsConfig.zmqEndpoint on a non-loopback address unless kvEventsConfig.allowUntrustedPublishers is true, because the bound socket takes the pod identity from the topic. zmqEndpoint is deprecated in favor of per-pod subscriptions (discoverPods).
    ``

    Diff: 132 lines (+130 / -2) across 9 files Reviewer: vMaroon Review duration: 13116m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.44) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 132 lines diff across 9 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.87 · 5 substantive comment(s)
    0.87
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.293
    Real PR Conversation Timeline
    9 items
    vMaroon vMaroon commented on code on Nov 09, 2026 16:54 UTC
    Code Review
    pkg/kvevents/pool.go:1
    @@ -261,6 +292,11 @@ func NewPool(cfg *Config, index kvblock.Index, tokenProcessor kvblock.TokenProce
     	if cfg.Concurrency <= 0 {
     		return nil, fmt.Errorf("kvEventsConfig.concurrency must be positive, got %d", cfg.Concurrency)
     	}
    +	if cfg.ZMQEndpoint != "" && !cfg.AllowUntrustedPublishers && !isLocalZMQEndpoint(cfg.ZMQEndpoint) {

    zmqEndpoint shipped in v1.0.0 on a Beta plugin, so I think the N+2 rule applies to the removal planned in #4105 - is next release a deliberate security exception? Also llm-d-benchmark's convert-guide patterns still set tcp://*:5557, so that needs moving too.

    vMaroon vMaroon commented on code on Nov 09, 2026 16:54 UTC
    Code Review
    pkg/kvevents/pool.go:1
    @@ -261,6 +292,11 @@ func NewPool(cfg *Config, index kvblock.Index, tokenProcessor kvblock.TokenProce
     	if cfg.Concurrency <= 0 {
     		return nil, fmt.Errorf("kvEventsConfig.concurrency must be positive, got %d", cfg.Concurrency)
     	}
    +	if cfg.ZMQEndpoint != "" && !cfg.AllowUntrustedPublishers && !isLocalZMQEndpoint(cfg.ZMQEndpoint) {
    +		return nil, fmt.Errorf("kvEventsConfig.zmqEndpoint %q binds a non-loopback address, so any network peer can publish "+
    +			"KV events under any pod's identity; use per-pod subscriptions (discoverPods) or set "+

    nit: discoverPods is already the default, so I think the message should say to drop zmqEndpoint and have the engines bind their own PUB socket.

    vMaroon vMaroon commented on code on Nov 09, 2026 16:54 UTC
    Code Review
    test/e2e/artifacts/config/sim-epp-tokenizer-vllm-http-config.yaml:1
    @@ -19,6 +19,7 @@ plugins:
           hashSeed: "42"
         kvEventsConfig:
           zmqEndpoint: tcp://0.0.0.0:5557
    +      allowUntrustedPublishers: true  # simulator pods publish to the EPP's bound socket

    The tokenizer README links this file as the complete sample for precise-prefix-cache-producer, so anyone copying it gets allowUntrustedPublishers: true along with the bind. Wonder if we could point that at a discoverPods config or call it e2e-only?

    ahg-g ahg-g commented on code on Nov 09, 2026 18:15 UTC
    Code Review
    pkg/kvevents/pool.go:1
    @@ -261,6 +292,11 @@ func NewPool(cfg *Config, index kvblock.Index, tokenProcessor kvblock.TokenProce
     	if cfg.Concurrency <= 0 {
     		return nil, fmt.Errorf("kvEventsConfig.concurrency must be positive, got %d", cfg.Concurrency)
     	}
    +	if cfg.ZMQEndpoint != "" && !cfg.AllowUntrustedPublishers && !isLocalZMQEndpoint(cfg.ZMQEndpoint) {

    Agreed on N+2. This PR is the shim: zmqEndpoint keeps working with allowUntrustedPublishers: true and logs a deprecation notice at startup. I will update #4105 so removal is two releases after the release that carries this PR, not "next release", unless maintainers decide on a security exception.

    One behavior change does land now and is deliberate: a shipped config that binds zmqEndpoint on a non-loopback address without the opt-in fails at startup with an error that names both fixes. A warning alone would leave any network peer able to write index entries under any pod's identity, which is the exposure this PR is for. If you would rather have a warning-only release first, say so and I will change it.

    Good catch on llm-d-benchmark. Its convert-guide pattern (discoverPods: false, zmqEndpoint: "tcp://*:5557") would fail startup after this lands. I will open an issue there to move the pattern to per-pod subscriptions, which also drops the need for the opt-in.

    ahg-g ahg-g commented on code on Nov 09, 2026 18:15 UTC
    Code Review
    pkg/kvevents/pool.go:1
    @@ -261,6 +292,11 @@ func NewPool(cfg *Config, index kvblock.Index, tokenProcessor kvblock.TokenProce
     	if cfg.Concurrency <= 0 {
     		return nil, fmt.Errorf("kvEventsConfig.concurrency must be positive, got %d", cfg.Concurrency)
     	}
    +	if cfg.ZMQEndpoint != "" && !cfg.AllowUntrustedPublishers && !isLocalZMQEndpoint(cfg.ZMQEndpoint) {
    +		return nil, fmt.Errorf("kvEventsConfig.zmqEndpoint %q binds a non-loopback address, so any network peer can publish "+
    +			"KV events under any pod's identity; use per-pod subscriptions (discoverPods) or set "+

    Done. The startup error and the deprecation notice now say to drop zmqEndpoint and have each engine bind its own PUB socket, which the EPP subscribes to by default.

    ahg-g ahg-g commented on code on Nov 09, 2026 18:15 UTC
    Code Review
    test/e2e/artifacts/config/sim-epp-tokenizer-vllm-http-config.yaml:1
    @@ -19,6 +19,7 @@ plugins:
           hashSeed: "42"
         kvEventsConfig:
           zmqEndpoint: tcp://0.0.0.0:5557
    +      allowUntrustedPublishers: true  # simulator pods publish to the EPP's bound socket

    Done. The tokenizer README now points at test/perf/config/router-configs/precise-prefix.yaml as the deployment-shaped sample (per-pod subscriptions) and describes the e2e file as the simulator variant that binds a socket, with allowUntrustedPublishers called out as not a deployment setting. Both e2e bind configs also carry an "e2e only" header, since sim-epp-kvcache-config.yaml is linked from docs/metrics.md the same way.

    vMaroon vMaroon commented on code on Nov 18, 2026 13:45 UTC
    Code Review
    pkg/kvevents/pool.go:1
    @@ -261,6 +292,11 @@ func NewPool(cfg *Config, index kvblock.Index, tokenProcessor kvblock.TokenProce
     	if cfg.Concurrency <= 0 {
     		return nil, fmt.Errorf("kvEventsConfig.concurrency must be positive, got %d", cfg.Concurrency)
     	}
    +	if cfg.ZMQEndpoint != "" && !cfg.AllowUntrustedPublishers && !isLocalZMQEndpoint(cfg.ZMQEndpoint) {

    Thanks - N+2 in #4105 works for me. I'd keep the hard fail here since the opt-in is one line, no need for a warning-only release.

    vMaroon vMaroon approved these changes on Nov 18, 2026 13:45 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    ahg-g ahg-g
    Labels
    risk: low confidence: 89.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.0% (MEDIUM) · Higher = larger blast radius
    44.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.0% · Lower = rushed or shallow review
    89.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.9% · Safe to merge
    4.9%