Repository navigation
Description
Summary
init-iptables.sh's detect_iptables_cmd() selects the wrong iptables backend on nft-only nodes (ROSA, recent RHEL/OpenShift, EKS, recent Ubuntu). It decides which backend to use by checking whether the legacy nat table can be listed, treats that read as proof the legacy backend is in use, and prefers legacy whenever the read succeeds. On nft-only hosts the legacy nat table is still readable (just empty), so the script picks iptables-legacy and programs our chains into a table the live datapath never consults. The result is a silent no-op: enforce-redirect (and redirect) rules insert successfully but never take effect.
File: authbridge/authproxy/init-iptables.sh (detect_iptables_cmd).
Current logic
detect_iptables_cmd() {
if [ -n "${IPTABLES_CMD:-}" ]; then
echo "${IPTABLES_CMD}"; return
fi
if command -v iptables-legacy >/dev/null 2>&1 && \
iptables-legacy -t nat -L -n >/dev/null 2>&1; then # readability probe
echo "iptables-legacy" # legacy-first bias
else
echo "iptables" # nft backend
fi
}Root cause
Linux exposes two independent packet-filtering subsystems behind the same CLI syntax: legacy x_tables (iptables-legacy) and nf_tables (iptables, the nft backend on Alpine). Rules written to one are not evaluated against the other. Our rules only work if they go into the backend the host (kube-proxy / CNI / Istio) actually uses.
Two problems with the current detection:
- Readability ≠ liveness.
iptables-legacy -t nat -L -nonly answers "can I enumerate the legacy nat table?" — a read. It does not answer "is the legacy backend where the live rules live?" On an nft-only node the legacy nat table typically lists fine (empty), so the probe passes and legacy is chosen even though every real NAT rule is in nf_tables. - Legacy-first bias. The "prefer legacy for compatibility" default reflects an era when K8s/Istio used legacy. Most current clusters are nft-only, so the default is backwards.
Failure mode is silent
Because the rules insert successfully into a real (but dead) table, every command returns success: the init container exits 0, the pod is healthy, and iptables-legacy -t nat -L shows the chains present — yet egress that should be captured/redirected leaks straight out. There is no error to alert on; you only notice that traffic isn't being intercepted.
This is distinct from the capability/SCC failure seen on ROSA (a hard EPERM initializing the nat table that CrashLoops the init container). That one is loud and is about CAP_NET_ADMIN/SCC admission, not backend selection. The detection bug doesn't crash — it leaks. Both can be present on the same platform.
Proposed fix
- Probe liveness, not readability. Pick the backend that already holds the host's rules — e.g. compare
iptables-legacy-save -t natvsiptables-nft-save -t natand prefer the backend that contains the existing kube-proxy / Istio chains. - Write-probe the chosen backend (insert a throwaway rule, then delete it) so failures cleanly distinguish "wrong backend" from "no
CAP_NET_ADMIN", and so a silent no-op can't happen. - Default to nft when ambiguous, not legacy.
- Keep the existing
IPTABLES_CMD/IP6TABLES_CMDoverride as the escape hatch, and have the operator set it explicitly on known platforms.
Impact
enforce-redirect(proxy-sidecar / lite) silently fails open on nft-only nodes — egress enforcement is bypassed without any signal.redirect(envoy-sidecar) interception silently does nothing on the same nodes.
cf. upstream caution that spawn/list success ≠ a functioning backend.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
huang195 commentedon Jun 15, 2026
Update: ROSA HCP testing shows the failure is deeper than detection, and the proposed write-probe fix is insufficient
Empirical findings from testing the actual
proxy-initimage on ROSA HCP (managed OpenShift, Red Hat-controlled nodes). These refine both the root cause and the fix proposed above.The detection bug is real, but a write-probe won't catch it
The original fix idea here was: probe writability in the chosen backend (insert + delete a throwaway rule) to detect the wrong backend. That is insufficient.
Three increasingly aggressive probes were tried under
iptables-legacy— table list, chain creation, andREDIRECTrule creation — and all three pass, because thenft_compatkernel module successfully emulates individualiptables-legacyoperations. The failure only surfaces when the full nat pipeline initializes insidesetup_enforce_redirect(). So any lightweight probe ("can I create a rule?") reports success and the script proceeds to fail mid-setup.Implication: detection cannot rely on legacy being usable just because individual ops succeed. The fix must not prefer legacy at all on nft hosts, and must verify the nft backend end-to-end rather than via a single-op probe.
The two backends fail for different reasons — only one is structural
Tested both backends with the real image on ROSA HCP:
iptables-legacyiptable_natkernel module not loaded (nodelsmodshows onlynf_tables+nft_compat), and SELinux blockscontainer_tfrom triggering its autoload. On ROSA HCP there is no MachineConfig access to load kernel modules — nodes are Red Hat-managed. Structural / unfixable from the workload side.iptables(nft)Could not fetch rule set generation id: Permission deniedThe nft failure is not a missing-module problem:
nf_tablesis loaded, and the nftnattable needs no extra module. Withroot+NET_ADMIN+NET_RAWalready granted (the pod is admitted under thekagenti-authbridgeSCC), aPermission deniedfetching the nf_tables generation id is the classic SELinuxcontainer_t→ nf_tables netlink denial — documented in Red Hat KB 5990311. The fix is to setseLinuxOptionson the container'ssecurityContext(e.g. a less-confined type).SCC blocks the SELinux fix as currently written
charts/kagenti/templates/kagenti-authbridge-scc.yamlsetsseLinuxContext: type: MustRunAs. UnderMustRunAs, a pod that specifies a customseLinuxOptionsis rejected at admission — so the KB 5990311 fix cannot even be applied until the SCC is changed toseLinuxContext: type: RunAsAny. Any nft+SELinux test that omits this SCC change has not actually exercised the fix.Net takeaways for this issue
iptables-legacy; default to nft; do not treat single-op probe success as proof the backend works (the nat pipeline init is the real test).iptable_nat, no way to load it. Not a detection or SCC problem.seLinuxContext: MustRunAs → RunAsAnyin the SCC plusseLinuxOptionson the proxy-init container. This needs a definitive yes/no test on ROSA HCP. If it works, enforce-redirect (full ext_proc enforcement) is preserved on managed OpenShift.Credit: ROSA HCP backend/SELinux/
lsmodtesting by Akram.huang195 commentedon Jun 16, 2026
PR for the detection fix: #518 — switches
detect_iptables_cmd()to a/proc/modules(iptable_nat) functional check + addsrequire_jumploud-fail. Scoped to detection only; it does not make ROSA work (selects nft + fails loud on the SELinux denial). The ROSA SELinux/SCC track and the operatorIPTABLES_CMDcompanion remain separate.Feat: Add egressEnforcement opt-out for proxy-sidecar mode
Feat: Add egressEnforcement opt-out for proxy-sidecar mode
Feat: Add egressEnforcement opt-out for proxy-sidecar mode
Fix: Select iptables backend by kernel module, fail loud on misprogram
huang195 commentedon Jun 21, 2026
PR merged. closing