Skip to content

Verify the two unexercised paths in transparent inbound: ambient (HBONE) capture and inbound mTLS #780

Closed

Description

@huang195

Summary

Transparent inbound interception (#330) is merged and its main path is verified end-to-end. Two code paths shipped unexercised — they are implemented and structurally verified, but no test or live run has driven traffic through them. Tracking them here rather than leaving them implicit in a closed issue.

Neither is a known defect. Both are "we have not observed this work," which is a different claim from "this works."

1. Ambient (HBONE) inbound — the higher-risk one

Ambient inbound never traverses PREROUTING: ztunnel terminates HBONE and re-originates a LOCAL connection, so it appears in nat OUTPUT. It is captured by a mark-based DNAT at the head of AB_REDIRECT, ahead of that chain's ztunnel-mark RETURN.

Verified: the rule is installed with the full mark 0x539 / ! --uid-owner / --dst-type LOCAL match, ordered before the DNAT and before the RETURN that would otherwise leak; all nine inbound exemptions are present on that hook too. test-enforce-redirect.sh asserts the ordering explicitly, and the rules were inspected live in a pod netns.

Not verified: that ztunnel's re-originated connection actually matches that tuple at runtime. That is reasoned from redirect mode's precedent (init-iptables.sh, "Rule 2"), not observed. The Kind cluster used for e2e runs only istiod — no ztunnel DaemonSet, no istio-cni — so there is no ambient data plane despite namespaces carrying istio.io/dataplane-mode=ambient. Counters confirm which path was exercised: AB_INBOUND REDIRECT took 4 packets, the ambient DNAT 0.

Why it matters: a PREROUTING-only implementation looks correct while waving every mesh-delivered request through unvalidated. That is precisely the failure this rule exists to prevent, so it deserves an observation rather than an argument.

  • Run the transparent-inbound e2e in an ambient-enrolled namespace on a cluster with ztunnel deployed
  • Confirm from rule counters that the ambient DNAT — not AB_INBOUND — carried the traffic
  • Confirm the exemptions hold on that path (:9091 reachable, so probes do not gate)

2. Inbound mTLS through the transparent listener

The transparent listener reuses the reverse proxy's mTLS posture via WrapListener, so tlssniff handles permissive/strict identically for both inbound shapes. Startup logs confirm the wrap is active (Transparent inbound server listening ... mtls=true).

Not verified: no TLS client has been driven against :8083. Unit coverage exists for the wrap (TestWrapListener_NoMTLSIsPassthrough) and for tlssniff itself, but the combination of SO_ORIGINAL_DST recovery and a TLS handshake on the same connection is untested end-to-end — and that combination is the novel part, since the recovery happens on the raw conn before tlssniff peeks.

  • e2e with a TLS client against a transparent-inbound agent — done as strict throughout
    (permissive is already covered by the main module's plaintext 401, which is what makes
    the strict rejection below meaningful as an A/B)
  • Same with strict, asserting plaintext is rejected — http_code=000, vs 401 permissive
  • Beyond the original ask: a valid SVID completes the handshake and still gets 401
    from jwt-validation (test(e2e): cover inbound mTLS and the ambient/HBONE path in transparent inbound rossoctl#2404)

Not in scope

Intra-pod loopback is deliberately not captured — containers share a netns and are one entity to every network enforcement layer, so that traffic is inside the trust boundary. See #330.

Related

Activity

  1. huang195 commented on Aug 20, 2026

    @huang195
    MemberAuthor

    mTLS half: done ✅

    Verified end-to-end and encoded as e2e tests in rossoctl/rossoctl#2404
    (rossoctl/tests/e2e/transparent_inbound/test_transparent_inbound_mtls.py).

    Run on kind against operator + authbridge + proxy-init images built from merged
    main
    , so the shipped code was under test — not a local branch build.

    Case Result Evidence
    strict + plaintext connection closed, http_code=000 vs 401 under permissive → tlssniff provably engaged on the transparent listener
    strict + TLS, no client cert tlsv13 alert certificate required sidecar log: http: TLS handshake error ... client didn't provide a certificate
    strict + TLS, valid SVID http_code=401 handshake completed, then pipeline: plugin rejected request plugin=jwt-validation status=401

    Sidecar attribution: mTLS enabled mode=strict +
    Transparent inbound server listening addr=[::]:8083 mtls=true.
    SVID used: spiffe://localtest.me/ns/team1/sa/ti-mtls.

    The 401 in the third row is the point — the full chain runs in one request
    (REDIRECT → SO_ORIGINAL_DST → tlssniff → tls.Server client-cert
    verification → jwt-validation), and it stops at 401 rather than 200 because
    authentication of the transport is not authorization of the request. Row 2 is
    its control, so the pass cannot be explained by lax verification.

    The specific worry this closes: SO_ORIGINAL_DST recovery happens on the raw
    connection, before tlssniff peeks the first byte. If those interfered, the
    startup logs would still have read mtls=true and looked fine. They don't
    interfere.

    Suite: 13/13 passing, 0 skipped.

    Ambient (HBONE) half: still open ⬜

    Unchanged and still blocked on infrastructure. This cluster runs only istiod —
    no ztunnel DaemonSet, no istio-cni, PILOT_ENABLE_AMBIENT unset — despite
    namespaces carrying istio.io/dataplane-mode=ambient. Packet counters confirm
    nothing ambient ever ran: AB_INBOUND REDIRECT carried all traffic, the ambient
    DNAT in AB_REDIRECT counted 0.

    So the DNAT rule remains verified as installed and correctly ordered (ahead of
    the ztunnel-mark RETURN, which is load-bearing — see #330), but its
    mark/dst-type matching is still only reasoned from redirect-mode precedent, never
    traversed. Needs a cluster with a real ambient data plane.

    Worth noting separately: that gap may itself be a deployment bug. The
    namespace labels say ambient, the data plane is absent. If the platform is meant
    to run ambient, that is its own issue; if it isn't, the labels are misleading.

    Assisted-By: Claude Code

  2. huang195 commented on Aug 20, 2026

    @huang195
    MemberAuthor

    Correction on the mTLS half: verified locally, not covered by CI

    Following up on my comment above, because it would have read as stronger than it is.

    The three-case verification stands exactly as described — it was a real run against
    images built from merged main, and the local suite is 13/13. What I should have
    checked before posting: whether the encoded tests actually run on the shared Kind
    e2e job.

    They don't. All 13 skip there — including the 10 from rossoctl/rossoctl#2393.
    On the CI run for #2404: three ~3-minute fixture stalls (exactly READY_TIMEOUT),
    each followed by an instant batch of skips, because the per-agent Keycloak
    client-credentials Secret is never created for the agents this suite deploys. This
    is pre-existing — the suite has been inert in CI since it merged, not something
    #2404 introduced — and it is the same intermittent Kind client registration that
    e2e-kind.yaml already works around with a wait loop plus continue-on-error for
    the token-exchange suite. Injected agents do start on that cluster (the separate
    AuthBridge Weather E2E step), so it is not a sidecar problem.

    So the accurate status of the mTLS half:

    • ✅ Verified — manually, and reproducibly via the committed tests, on a cluster
      running merged-main images.
    • ⬜ Not yet a regression gate — nothing in CI would catch a future break.

    I have left the #780 boxes ticked, since what they asked for (verify these paths) is
    genuinely done. But if the intent was a standing gate rather than a one-time
    verification, that is not achieved yet, and the fix is either repairing Kind client
    registration or setting TI_STUB_CREDENTIALS=1 in 90-run-e2e-tests.sh — the
    latter reverses the deliberate opt-in reasoning in the suite README, so it wants a
    decision rather than a silent flip. Say which and I will do it.

    #2404 also rewrites the skip message, which previously named only a missing
    k8s.keycloak.org CRD as the cause. That is real on community-provider installs
    but is not what happens in CI, so it was pointing debuggers at the wrong thing.

    Assisted-By: Claude Code

  3. huang195 commented on Aug 20, 2026

    @huang195
    MemberAuthor

    Correcting my correction above

    My previous comment said the mTLS half was "verified locally, not covered by
    CI", and blamed intermittent Keycloak client registration on Kind. The first part
    was right about the state; the diagnosis was wrong. It is now fixed, and the suite
    does gate.

    Root cause was deterministic, not flaky. With SPIRE enabled, the operator's
    ClientRegistration controller derives the Keycloak client ID from the Deployment
    pod template's
    serviceAccountName and refuses on default:

    "msg":"cannot resolve Keycloak client id yet"
    "reason":"SPIRE enabled: set spec.template.spec.serviceAccountName to a dedicated
              ServiceAccount (not default) on the workload for a stable SPIFFE client ID"
    

    It requeues every 30s forever at Info level, so the per-agent credentials Secret
    is never created and the injected pod never leaves FailedMount. The e2e fixtures
    set no serviceAccountName; the platform's own agent deploy scripts create a
    dedicated SA for exactly this reason. One line in the fixture manifest fixes it.

    rossoctl/rossoctl#2404 now runs 13 passed, 0 skipped, with no credential
    stubbing
    — real controller-issued credentials. So the mTLS half is verified and
    gated, and the ticked boxes are now backed by CI rather than a one-time manual run.

    Also, a platform defect worth its own issue (not part of #780, I'll file it
    unless someone objects): the AuthBridge webhook creates a per-agent ServiceAccount,
    sets it on the pod, and pre-populates the annotation naming the credentials
    Secret — but never touches the Deployment template the controller reads. The two
    halves of one feature disagree; the pod is promised a Secret the controller has
    already declined to create; nothing surfaces an error. internal/clientreg's
    package doc states its purpose is keeping these two sides in lockstep — they agree
    on the Secret name and disagree on the input. Any workload deployed as a plain
    Deployment without an explicit dedicated SA hits this, silently and permanently.

    Minor second finding: those webhook-created SAs have no ownerReference, so
    nothing garbage-collects them.

    Ambient/HBONE half is still open — unchanged, still needs a cluster with a real
    ambient data plane.

    Assisted-By: Claude Code

  4. huang195 commented on Aug 20, 2026

    @huang195
    MemberAuthor

    Correcting my comment above on the platform-defect aside — the mTLS findings in it stand, this
    is only about the ServiceAccount tangent.

    I wrote that "any workload deployed as a plain Deployment without an explicit dedicated SA hits
    this, silently and permanently," and filed it as operator#513. That sentence is literally true
    but gives the wrong impression of severity, and the issue generalized from a single caller —
    mine. Every path that creates a workload for real already sets serviceAccountName: the
    backend's agent manifests (agents_manifests.py:379,581,723,832), tools
    (tools.py:1330,1492), simulation_manifests.py:253, agents_migration.py:487 (whose comment
    says exactly why), plus the 7x-deploy-* scripts. The only caller that lacked one was my
    hand-written e2e fixture.

    Nothing regressed either: the default refusal has been in place since the commit that
    introduced that controller (9637c03, 2026-03-26), and spire.enabled has defaulted to true
    since 2025-11-06.

    operator#513 is closed with a retraction. The webhook/controller split is real but latent — a
    trap for hand-written manifests, not an active bug. What I'd still call worth fixing there is
    unrelated to the SA: client-ID resolution failures surface only as logger.Info plus a 30s
    requeue forever, with no Event or status condition, for every reason they can fail.

    No change to the mTLS half or to the ambient/HBONE half, which is still open.

  5. self-assigned this
    on Aug 20, 2026
  6. huang195 commented on Aug 20, 2026

    @huang195
    MemberAuthor

    Ambient / HBONE half verified end-to-end, and now gated

    The three remaining boxes were open because no cluster in the loop had a ztunnel,
    so the ambient DNAT was structurally unreachable rather than untested. That turned
    out to be a config gate, not missing infrastructure:
    charts/rossoctl-deps/templates/istio-operand.yaml wraps the Istio, IstioCNI
    and ZTunnel operands in {{- if and .Values.components.istio.enabled .Values.openshift }},
    and deployments/envs/dev_values*.yaml set openshift: false. Kind therefore has
    no ambient data plane by construction, which is why the DNAT counter always read 0.

    Installed one by hand on Kind (istiod 1.28.0 profile=ambient with
    PILOT_ENABLE_AMBIENT=true, istio-cni, ztunnel) and ran a transparent-inbound
    agent in team1 with a probe in team2, both istio.io/dataplane-mode=ambient.

    Rules as programmed (agent pod netns, 10.244.0.99)

    PREROUTING pos 1:  -p tcp -j AB_INBOUND            (ahead of ISTIO_PRERT)
    AB_REDIRECT:       9 exemption RETURNs, then
      -A AB_REDIRECT -p tcp -m mark --mark 0x539/0xfff -m owner ! --uid-owner 1337 \
         -m addrtype --dst-type LOCAL -j DNAT --to-destination 10.244.0.99:8083
      -A AB_REDIRECT -m mark --mark 0x539/0xfff -j RETURN
    

    Observed

    # Request from team2 Result AB_INBOUND REDIRECT ambient DNAT :9091 RETURN
    0 baseline — [2:120] [0:0] [1:60]
    1 amb-780-agent.team1:8000 (Service) 401 [2:120] unchanged [1:60] +1 —
    2 10.244.0.99:8000 (direct pod dial) 401 [2:120] unchanged [2:120] +1 —
    3 10.244.0.99:9091/healthz 200 [2:120] unchanged [2:120] unchanged [2:120] +1
    • The ambient DNAT carried every mesh-delivered request; AB_INBOUND never
      fired for one.
      That is the box, and it is also the hazard this issue named — a
      PREROUTING-only implementation would have waved all three through unvalidated.
    • The plain --mark 0x539 -j RETURN stayed at [6:708] throughout, having taken
      6 outbound HBONE packets earlier. Live confirmation that --dst-type LOCAL on
      the DNAT is load-bearing: ztunnel reuses 0x539 for outbound.
    • The exemption is confirmed positively, not by absence — the dport-9091
      RETURN's own counter incremented on request 3. Same source, same mesh path,
      different port, different rule. Probes do not gate. Pod stayed 2/2, 0 restarts.

    Request 1 corroborated at three layers within the same millisecond:

    ztunnel     src.identity="spiffe://cluster.local/ns/team2/sa/default"
                dst.addr=10.244.0.99:15008  dst.hbone_addr=10.244.0.99:8000
                dst.identity="spiffe://cluster.local/ns/team1/sa/amb-780-agent"
                direction="inbound"                                    13:50:49.636
    authbridge  plugin=jwt-validation status=401 reason="missing Authorization header"
                                                                       13:50:49.636
    

    Encoded as a gate

    rossoctl/rossoctl#2404 gains test_transparent_inbound_ambient.py (2 tests; suite
    is now 15 passed / 0 skipped locally, up from 13). It asserts the delivery path
    as well as the status — from ztunnel's access log — because both paths end in the
    same 401, so without that it would silently become a duplicate of
    test_direct_pod_dial_is_validated the moment ambient stopped being engaged.

    Negative control, since a test that cannot fail proves nothing. Deleting that
    one DNAT rule from the live pod's netns makes the mesh-delivered request return
    200 — the app answering it unvalidated — and the module fails naming that
    cause, while the health-port test keeps passing. Recreating the pod reprograms the
    rule from proxy-init and both pass again.

    Rule ordering and packet counters are not asserted in the test: not reachable from
    a test pod, and unnecessary — every way the rule can regress (deleted, ordered
    after the mark RETURN, matching too narrowly) ends in that same 200.

    Deliberately not kind_only, unlike the rest of that suite, since ambient
    ships on OpenShift only; it self-gates on a ready ztunnel (found by label across
    namespaces — the chart uses istio-ztunnel, a community install defaults to
    istio-system) plus dataplane-mode=ambient on both namespaces. Consequence
    worth flagging: it becomes the first module in that suite to run on OpenShift, so
    its first run there may surface pre-existing suite or platform issues rather than
    ambient ones.

    Caveat on the data plane used

    Community Helm charts, with ztunnel in istio-system rather than the platform's
    istio-ztunnel. The namespace does not enter the iptables tuple under test, and
    pilot.trustedZtunnelNamespace only governs which namespace istiod accepts
    ztunnel XDS from — but this is a hand-built ambient install, not the sail-operator
    operands the platform ships. Confirming on OpenShift, where those operands are
    what runs, is what the unmarked test now does automatically.

  7. huang195 commented on Aug 20, 2026

    @huang195
    MemberAuthor

    Closing: both paths are verified, and the e2e encoding merged as rossoctl/rossoctl#2404 (4c50dcd1).

    What CI actually ran

    From the Deploy & Test job on the merged head (Kind):

    Test CI
    test_hbone_delivered_request_is_validated PASSED
    test_health_port_exempt_on_the_hbone_path PASSED
    test_strict_rejects_plaintext SKIPPED
    test_strict_terminates_tls_on_the_recovered_connection SKIPPED
    test_strict_completes_mtls_and_still_enforces SKIPPED

    So the ambient half is now a live CI gate, which is better than this issue asked for and better than I predicted.

    Correction to my earlier comment

    I claimed ambient could not run on Kind, because charts/rossoctl-deps/templates/istio-operand.yaml gates the Istio/IstioCNI/ZTunnel operands on .Values.openshift. That is true of the operand path but wrong as a statement about Kind: the Kind installer installs the community ztunnel chart (ztunnel-1.28.0, helm release ztunnel in istio-system) and there is already a TestIstioAmbient::test_ztunnel_release covering it. team1/team2 are genuinely ambient-enrolled there, ztunnel logged the terminated-HBONE line for the agent pod, and the request was denied on that path. The module's docstring and README carry the same wrong claim and need a doc-only fix.

    The mTLS tests skip in CI

    Not a feature failure, and not the code under test. Both mTLS skips — and test_reverse_proxy_control_bypass_is_reachable, which predates this work — waited ~183s and then took _wait_ready's missing-credentials skip. The pattern: the session-scoped agent gets its per-agent Keycloak client-credentials Secret and its 9 tests pass; the additional deployments (the mTLS strict agent, the reverse-proxy control agent) do not get one inside the fixture timeout. rossoctl/rossoctl#2404 already improved this materially — before it, all 13 tests skipped in CI — but it did not close it.

    The mTLS assertions themselves are verified: run locally against images built from merged main, all three cases including a valid SVID completing the handshake and still getting a 401. The evidence is in the comments above. What is missing is a permanent CI gate for them, which is a fixture/credential-timing problem rather than anything about inbound mTLS, so it belongs in its own issue rather than holding this one open.

    Residual work, tracked separately

    • rossoctl e2e: additional agent deployments don't get credentials within the fixture timeout, so the mTLS module skips in CI.
    • cortex: no Go test for the assembled NewInboundListener → WrapListener with mTLS on. Today a cortex regression fails only rossoctl's e2e, in a different repo.
    • Doc fix for the "ambient can't run on Kind" claim in the ambient module docstring and transparent_inbound/README.md.

    All six boxes are checked and neither path is unexercised any more, so this closes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions