Skip to content

OCPBUGS-67363: fixes ip traffic fragmentation verification#730

Open
raphaelvrosa wants to merge 1 commit into
openshift:masterfrom
raphaelvrosa:67363
Open

OCPBUGS-67363: fixes ip traffic fragmentation verification#730
raphaelvrosa wants to merge 1 commit into
openshift:masterfrom
raphaelvrosa:67363

Conversation

@raphaelvrosa

@raphaelvrosa raphaelvrosa commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Impact: Attackers can access blocked ports by fragmenting IP packets in specific ways that exploit the firewall's failure to validate IP fragmentation headers before extracting Layer 4 port information.

Root Cause: The eBPF code assumes all packets have complete TCP/UDP/SCTP headers immediately following the IP header, without checking if the packet is a non-first fragment that contains only payload data.

Solution:

  • Check iph->frag_off before extracting L4 headers
  • Deny all non-first fragments (secure by default)
  • First fragments (offset = 0) still processed normally with L4 inspection

The solution was verified and validate locally with kind and ovn-kubernetes as CNI. The ebpf program was loaded, and traffic was blocked.
The verification of the fragmentation issue could not be fully verified, as docker and host were probably dropping fragmented packets before it reached the cluster.

- What this PR does and why is it needed

- Special notes for reviewers

- How to verify it

- Description for the changelog

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of fragmented IPv4 traffic so packets that are not the first fragment are now denied instead of being processed incorrectly.
    • Updated firewall behavior to more reliably reject packets missing layer 4 header information.
  • Chores

    • Updated the cert-manager version used by deployment and cleanup workflows to a newer release.
    • Added IPv4 fragmentation constants to support packet handling changes.

Impact: Attackers can access blocked ports by fragmenting IP packets
in specific ways that exploit the firewall's failure to validate IP
fragmentation headers before extracting Layer 4 port information.

Root Cause: The eBPF code assumes all packets have complete
TCP/UDP/SCTP headers immediately following the IP header,
without checking if the packet is a non-first fragment that
contains only payload data.

Solution:
- Check iph->frag_off before extracting L4 headers
- Deny all non-first fragments (secure by default)
- First fragments (offset = 0) still processed normally with L4 inspection

The solution was verified and validate locally with kind
and ovn-kubernetes as CNI. The ebpf program was loaded, and
traffic was blocked.
The verification of the fragmentation issue could not be
fully verified, as docker and host were probably dropping
fragmented packets before it reached the cluster.

Signed-off-by: Raphael Rosa <raprosa@redhat.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@raphaelvrosa: This pull request references Jira Issue OCPBUGS-67363, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Impact: Attackers can access blocked ports by fragmenting IP packets in specific ways that exploit the firewall's failure to validate IP fragmentation headers before extracting Layer 4 port information.

Root Cause: The eBPF code assumes all packets have complete TCP/UDP/SCTP headers immediately following the IP header, without checking if the packet is a non-first fragment that contains only payload data.

Solution:

  • Check iph->frag_off before extracting L4 headers
  • Deny all non-first fragments (secure by default)
  • First fragments (offset = 0) still processed normally with L4 inspection

The solution was verified and validate locally with kind and ovn-kubernetes as CNI. The ebpf program was loaded, and traffic was blocked.
The verification of the fragmentation issue could not be fully verified, as docker and host were probably dropping fragmented packets before it reached the cluster.

- What this PR does and why is it needed

- Special notes for reviewers

- How to verify it

- Description for the changelog

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Walkthrough

Adds IPv4 fragmentation constants and updates ip_extract_l4info() to detect non-first fragments, returning a new error code that both ipv4_firewall_lookup() and ipv6_firewall_lookup() handle by immediately denying the packet. Separately, the Makefile's CERT_MANAGER_VERSION is bumped from v1.9.1 to v1.20.2.

Changes

Non-first IP Fragment Denial

Layer / File(s) Summary
Fragmentation constants
bpf/ingress_node_firewall.h
Adds IP_MF, IP_OFFSET_MASK, and IP_DF macros with RFC 791 comments.
Fragment detection logic
bpf/ingress_node_firewall_kernel.c
Updates ip_extract_l4info() docs and adds a fragment-offset check returning -2 for non-first IPv4 fragments.
Firewall lookup denial handling
bpf/ingress_node_firewall_kernel.c
Updates ipv4_firewall_lookup() and ipv6_firewall_lookup() to capture the return value and deny the packet immediately when -2 is returned, instead of generic extraction-error handling.

Cert-manager Version Bump

Layer / File(s) Summary
Version variable update
Makefile
CERT_MANAGER_VERSION is changed from v1.9.1 to v1.20.2, affecting the cert-manager download URL used by install-cert-manager and undeploy-kind targets.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Packet
  participant ip_extract_l4info
  participant ipv4_firewall_lookup
  participant ipv6_firewall_lookup

  Packet->>ip_extract_l4info: parse IP header
  ip_extract_l4info->>ip_extract_l4info: check fragment offset
  alt non-first fragment
    ip_extract_l4info-->>ipv4_firewall_lookup: return -2
    ipv4_firewall_lookup->>ipv4_firewall_lookup: SET_ACTIONRULE_RESPONSE(DENY, INVALID_RULE_ID)
    ip_extract_l4info-->>ipv6_firewall_lookup: return -2
    ipv6_firewall_lookup->>ipv6_firewall_lookup: SET_ACTIONRULE_RESPONSE(DENY, INVALID_RULE_ID)
  else extraction failure
    ip_extract_l4info-->>ipv4_firewall_lookup: return generic error
    ip_extract_l4info-->>ipv6_firewall_lookup: return generic error
  end
Loading
🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PASS: The PR only changes Makefile and BPF source; no Ginkgo test declarations or titles were added or modified in the touched files.
Test Structure And Quality ✅ Passed The PR changes only Makefile and BPF sources/binaries; no Ginkgo or test files are in the diff, so the test-quality check is not applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added in this PR; only Makefile and eBPF sources changed.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No Ginkgo/e2e test files were added; the PR only changes Makefile and BPF sources, with no SNO-related test assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only Makefile and eBPF firewall sources/objects changed; no deployment manifests, operator code, or workload scheduling settings were introduced.
Ote Binary Stdout Contract ✅ Passed PR touches only Makefile and BPF code; no main/TestMain/BeforeSuite stdout or logging additions were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo/e2e tests were added or modified; the PR only changes Makefile and eBPF sources.
No-Weak-Crypto ✅ Passed Touched files only update cert-manager version and IPv4 fragmentation logic; no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed PASS: The PR only changes Makefile and eBPF source/binaries; no Kubernetes/container manifests or privilege settings were added or modified.
No-Sensitive-Data-In-Logs ✅ Passed No new logs expose secrets or PII; added fragment handling is silent, and existing printks only mention protocol, ports, rule IDs, or generic errors.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clearly about the fragmentation fix and matches the main change in ingress-node-firewall.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@raphaelvrosa: This pull request references Jira Issue OCPBUGS-67363, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @anuragthehatter

Details

In response to this:

Impact: Attackers can access blocked ports by fragmenting IP packets in specific ways that exploit the firewall's failure to validate IP fragmentation headers before extracting Layer 4 port information.

Root Cause: The eBPF code assumes all packets have complete TCP/UDP/SCTP headers immediately following the IP header, without checking if the packet is a non-first fragment that contains only payload data.

Solution:

  • Check iph->frag_off before extracting L4 headers
  • Deny all non-first fragments (secure by default)
  • First fragments (offset = 0) still processed normally with L4 inspection

The solution was verified and validate locally with kind and ovn-kubernetes as CNI. The ebpf program was loaded, and traffic was blocked.
The verification of the fragmentation issue could not be fully verified, as docker and host were probably dropping fragmented packets before it reached the cluster.

- What this PR does and why is it needed

- Special notes for reviewers

- How to verify it

- Description for the changelog

Summary by CodeRabbit

  • Bug Fixes

  • Improved handling of fragmented IPv4 traffic so packets that are not the first fragment are now denied instead of being processed incorrectly.

  • Updated firewall behavior to more reliably reject packets missing layer 4 header information.

  • Chores

  • Updated the cert-manager version used by deployment and cleanup workflows to a newer release.

  • Added IPv4 fragmentation constants to support packet handling changes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: raphaelvrosa
Once this PR has been reviewed and has the lgtm label, please assign danwinship for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bpf/ingress_node_firewall_kernel.c`:
- Around line 309-318: The current fragment-handling branch in
ip_extract_l4info() only denies IPv4 non-first fragments via the -2 return path,
but IPv6 Fragment headers are still not detected. Update the IPv6 parsing path
in bpf/ingress_node_firewall_kernel.c so ip_extract_l4info() walks IPv6
extension headers, explicitly checks for NEXTHDR_FRAGMENT, and identifies
non-first fragments as a deny case; then make the existing caller logic in the
l4_result check return DENY for those IPv6 fragments instead of falling through
to SET_ACTION(UNDEF).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d4ba6ea4-4664-4622-95ab-3845b7991dd2

📥 Commits

Reviewing files that changed from the base of the PR and between f1e4ccd and 8247162.

⛔ Files ignored due to path filters (4)
  • pkg/ebpf/bpf_arm64_bpfel.o is excluded by !**/*.o
  • pkg/ebpf/bpf_powerpc_bpfel.o is excluded by !**/*.o
  • pkg/ebpf/bpf_s390_bpfeb.o is excluded by !**/*.o
  • pkg/ebpf/bpf_x86_bpfel.o is excluded by !**/*.o
📒 Files selected for processing (3)
  • Makefile
  • bpf/ingress_node_firewall.h
  • bpf/ingress_node_firewall_kernel.c

Comment on lines +309 to 318
int l4_result = ip_extract_l4info(data, data_end, &proto, &dstPort, &icmpType,
&icmpCode, 0);
if (unlikely(l4_result < 0)) {
if (l4_result == -2) {
// Non-first IP fragment: deny by security policy
return SET_ACTIONRULE_RESPONSE(DENY, INVALID_RULE_ID);
}
ingress_node_firewall_printk("failed to extract l4 info");
return SET_ACTION(UNDEF);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm there's no other IPv6 extension-header walking logic elsewhere in the bpf dir
rg -n 'nexthdr|NEXTHDR|ipv6hdr' bpf/

Repository: openshift/ingress-node-firewall

Length of output: 1822


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant IPv4/IPv6 parsing and lookup flow.
sed -n '80,170p' bpf/ingress_node_firewall_kernel.c
printf '\n---\n'
sed -n '280,340p' bpf/ingress_node_firewall_kernel.c
printf '\n---\n'
sed -n '340,420p' bpf/ingress_node_firewall_kernel.c

# Look for any IPv6 fragment/extension-header handling in the repo.
printf '\n=== search ===\n'
rg -n 'NEXTHDR_FRAGMENT|fragment|ext header|extension header|ipv6 fragment|IPV6_EXT' bpf/ .

Repository: openshift/ingress-node-firewall

Length of output: 18706


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find how UNDEF propagates to the final packet decision.
rg -n 'SET_ACTION\(UNDEF\)|UNDEF|DENY|ALLOW|SET_ACTIONRULE_RESPONSE' bpf/ingress_node_firewall_kernel.c bpf/ingress_node_firewall.h

printf '\n=== action helpers ===\n'
sed -n '1,140p' bpf/ingress_node_firewall.h

printf '\n=== lookup callers ===\n'
rg -n 'ipv6_firewall_lookup|ipv4_firewall_lookup|SET_ACTIONRULE_RESPONSE|SET_ACTION\(' bpf/ingress_node_firewall_kernel.c

Repository: openshift/ingress-node-firewall

Length of output: 7842


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the final action mapping for XDP and TCX paths.
sed -n '440,575p' bpf/ingress_node_firewall_kernel.c

Repository: openshift/ingress-node-firewall

Length of output: 4810


IPv6 fragments still bypass port matching
ip_extract_l4info() only returns -2 for IPv4; the IPv6 path never checks NEXTHDR_FRAGMENT or walks extension headers. IPv6 packets with a Fragment header fall through as UNDEF and are passed, so this does not close the fragmentation bypass for IPv6. Add IPv6 extension-header parsing and deny non-first fragments.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bpf/ingress_node_firewall_kernel.c` around lines 309 - 318, The current
fragment-handling branch in ip_extract_l4info() only denies IPv4 non-first
fragments via the -2 return path, but IPv6 Fragment headers are still not
detected. Update the IPv6 parsing path in bpf/ingress_node_firewall_kernel.c so
ip_extract_l4info() walks IPv6 extension headers, explicitly checks for
NEXTHDR_FRAGMENT, and identifies non-first fragments as a deny case; then make
the existing caller logic in the l4_result check return DENY for those IPv6
fragments instead of falling through to SET_ACTION(UNDEF).

@raphaelvrosa raphaelvrosa changed the title OCPBUGS-67363: fixes ip traffic fragmentation OCPBUGS-67363: fixes ip traffic fragmentation verification Jul 9, 2026
@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@raphaelvrosa: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants