Skip to content

fix(policy-controller)!: Disallow requests to undefined service ports #14149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

adleong
Copy link
Member

@adleong adleong commented Jun 17, 2025

Fixes #13922

When a meshed client attempts to connect to a clusterIP Service on a port that is not present in that service's spec, Linkerd allows that connection through anyway. This is in contrast to bare kube-proxy behavior where only the ports defined in the service spec are forwarded to the service endpoints.

We update the policy-controller to return an opaque route with a forbidden filter for such connections. This causes the outbound Linkerd proxy to immediately reset the connection if a client attempts to connect to a port not defined in the service spec.

This shows up in Linkerd proxy metrics as a Forbidden error with the "undefined-port" synthetic route:

outbound_tcp_route_close_total{
	parent_group="core",
	parent_kind="Service",
	parent_namespace="default",
	parent_name="nginx",
	parent_port="80",
	parent_section_name="",
	route_group="",
	route_kind="default",
	route_namespace="",
	route_name="undefined-port"
	,target_ip=""
	target_port="80",
	error="forbidden"
} 1

@adleong adleong requested a review from a team as a code owner June 17, 2025 23:40
Signed-off-by: Alex Leong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linkerd exposes all ports on pod regardless of Service definition
2 participants