Default NET_RAW Capability
Kubernetes containers run with NET_RAW capability enabled by default, allowing applications to create raw and packet sockets for arbitrary packet crafting and network sniffing operations.
Kubernetes containers running with NET_RAW capability enabled can craft and sniff network packets, perform ARP spoofing, conduct network reconnaissance, and bypass network security controls. This capability enables attackers to perform lateral movement, data exfiltration, and network-based attacks within the cluster environment.
# VULNERABLE: Pod with default capabilities (includes NET_RAW)
apiVersion: v1
kind: Pod
metadata:
name: vulnerable-app-pod
spec:
containers:
- name: app
image: app:v1.0.0
# VULNERABLE: No capabilities specified - includes NET_RAW by default
# VULNERABLE: Deployment with explicit NET_RAW capability
apiVersion: apps/v1
kind: Deployment
metadata:
name: vulnerable-network-app
spec:
replicas: 2
selector:
matchLabels:
app: network-app
template:
metadata:
labels:
app: network-app
spec:
containers:
- name: network-tool
image: network-tool:latest
securityContext:
capabilities:
add: ["NET_RAW", "NET_ADMIN"] # VULNERABLE: Explicit NET_RAW# SECURE: Pod with NET_RAW capability dropped
apiVersion: v1
kind: Pod
metadata:
name: secure-app-pod
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: app
image: app:v1.0.0
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop: ["ALL"] # SECURE: Drop all capabilities including NET_RAW
# add: ["NET_BIND_SERVICE"] # Only add specific needed capabilities
# SECURE: Deployment with minimal capabilities
apiVersion: apps/v1
kind: Deployment
metadata:
name: secure-network-app
spec:
replicas: 2
selector:
matchLabels:
app: network-app
template:
metadata:
labels:
app: network-app
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: network-tool
image: network-tool:v1.0.0
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop: ["ALL"] # SECURE: Drop NET_RAW and all other capabilities
# Only add specific capabilities if absolutely required
# add: ["NET_BIND_SERVICE"] # Example: only if binding to port <1024Kubernetes containers run with NET_RAW capability enabled by default, allowing applications to create raw and packet sockets for arbitrary packet crafting and network sniffing operations.
Sourcery automatically identifies information disclosure via net_raw capability in kubernetes containers and many other security issues in your codebase.