aws / aws/aws-network-policy-agent

Allowing ICMP in network policy

Open
#90 10 comments 3 reactions 0 assignees View on GitHub
feature request
Dominant language
Go
Stars
75
Forks
68
Avg merge
2d 11h
Merged PRs (30d)
10

Description

Currently it seems that ICMP is not allowed as a protocol in a network policy but it seems to be at least partially implemented and planned for.

https://github.com/aws/aws-network-policy-agent/blob/d764cafebca031cadd28eaa962e9af524edb2298/pkg/utils/utils.go#L21
https://github.com/aws/aws-network-policy-agent/blob/d764cafebca031cadd28eaa962e9af524edb2298/pkg/ebpf/events/events.go#L118

However when attempting to use protocol ICMP in the following way

```
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
namespace: cnitest
name: demo
spec:
podSelector:
matchLabels: {}
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: 8.8.8.8/32
ports:
- protocol: ICMP
```

It results in an error message
`The NetworkPolicy "demo-app-deny-all" is invalid: spec.egress[0].ports[0].protocol: Unsupported value: "ICMP": supported values: "TCP", "UDP", "SCTP"`

This is an issue for any network using IPv6. [RFC4890](https://datatracker.ietf.org/doc/html/rfc4890#section-4.3.1) states that certain ICMP messages should always be allowed while others may be filtered.

As soon as a filter is applied it negates all ICMP traffic unless the protocol is not specified and even then, only to the network or pods that are targeted. This makes it impossible to allow ICMP within the cluster while only allowing specific ports and protocols for direct communication.

Contributor guide

Open the contributing guide

Research direction

Start with the referenced protocol definitions in pkg/utils/utils.go and event handling in pkg/ebpf/events/events.go. Reproduce the Kubernetes NetworkPolicy validation error using the ICMP example, then trace how protocol and port rules are enforced. Done means ICMP can be expressed and enforced without preventing targeted port and protocol rules, including the IPv6 considerations described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
networking, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.