Skip to content

Cilium 403 "Access denied": the L7 rule blocks the request

Ciliumtested on Cilium v1.20.5

On L7 there is no timeout but an answer: if a CiliumNetworkPolicy allows the port but not the HTTP request, Envoy answers it with "403 Access denied". Hubble shows which method and which URL were dropped.

Symptom

k -n tag12 exec client -- curl -s -m3 -X POST -H 'X-API-Key: lab-key-123' \
  -d '{"text":"L7"}' notes-api/notes
k -n tag12 exec client -- curl -s -o /dev/null -w '%{http_code}\n' notes-api/notes/42
Access denied
403

Other requests from the same client to the same port go through. The connection is up – it is the single request that is rejected.

Diagnosis

Look at the dropped HTTP requests in the namespace. Each line names method and URL.

hubble observe -P --port-forward-port 0 --namespace tag12 --verdict DROPPED \
  --protocol http --last 2
tag12/client:49996 (ID:15951) -> tag12/notes-api-…-dkctb:8080 (ID:64913)
  http-request DROPPED (HTTP/1.1 POST http://notes-api/notes)
tag12/client:57836 (ID:15951) -> tag12/notes-api-…-nd4cg:8080 (ID:64913)
  http-request DROPPED (HTTP/1.1 GET http://notes-api/notes/42)

Causes

MethodMethod missing from rules.http

The rule only allows GET for /notes. Envoy rejects a POST to the same path.

Pathpath is a regular expression over the whole path

path: "/notes" allows exactly /notes. /notes/42 is rejected because the expression has to match the whole path.

ClientThe rule differs per client

HTTP rules are tied to the source. If one client may only read and another may also write, the first gets a 403 for POST, the second doesn't.

Fix

Append exactly the missing combination as a rule of its own instead of loosening the existing one – method: ".*" would open DELETE too.
k patch cnp notes-l7 --type=json -p '[{"op":"add",
 "path":"/spec/ingress/0/toPorts/0/rules/http/-",
 "value":{"method":"POST","path":"/notes"}}]'
k get cnp notes-l7 -o jsonpath='{.spec.ingress[0].toPorts[0].rules.http}'; echo
ciliumnetworkpolicy.cilium.io/notes-l7 patched
[{"method":"GET","path":"/(version|healthz|notes)"},{"method":"POST","path":"/notes"}]
▶
Break it yourself and find it – free
Cilium hands-on, day 12: default deny, DNS exception, L3/L4, L7 and FQDN egress, proven with Hubble and cilium-dbg.
Go to day 12 →

FAQ

What is the difference between 403 and a timeout?

403 Access denied comes from the Envoy proxy: L4 allowed, L7 not. A timeout means the packet was already dropped on L3/L4.

How do I see the allowed requests too?

hubble observe --type l7 also shows the allowed requests with status and latency.

Related error patterns

More