Skip to content

fix(destination)!: Disallow requests to undefined service ports - #15473

Merged
adleong merged 5 commits into
mainfrom
alex/service-profile-port
Jul 16, 2026
Merged

fix(destination)!: Disallow requests to undefined service ports#15473
adleong merged 5 commits into
mainfrom
alex/service-profile-port

Conversation

@adleong

@adleong adleong commented Jul 14, 2026

Copy link
Copy Markdown
Member

#14149 fixed #13922 in the case where no ServiceProfile was defined for the target service.

However, when a ServiceProfile is defined for a service, Linkerd will use the GetProfile API instead of the client policy API and requests will be allowed to ports not defined in the service.

Unfortunately, the GetProfile API does not have a mechanism to signal that connections should be denied. Therefore, when we encounter a GetProfile request for a port which is not defined on the service, we return an empty DestinationProfile. This causes the proxy to fall back to the client policy API which correctly returns a Forbidden filter and causes the connection to be denied.

We also add an integration test for both the ServiceProfile and non-ServiceProfile cases.

adleong added 2 commits July 14, 2026 17:28
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong
adleong requested a review from a team as a code owner July 14, 2026 18:02
adleong added 2 commits July 14, 2026 18:09
Signed-off-by: Alex Leong <alex@buoyant.io>
Signed-off-by: Alex Leong <alex@buoyant.io>
Comment thread controller/api/destination/server.go Outdated
case <-s.shutdown:
case <-canceled:
log.Debugf("GetProfile %s cancelled", fqn)
case <-streamEnd:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears as if this case is unreachable, does it make sense to create streamEnd below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch, thanks!

Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong
adleong merged commit 59813f0 into main Jul 16, 2026
67 of 69 checks passed
@adleong
adleong deleted the alex/service-profile-port branch July 16, 2026 18:03
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

3 participants