-
Notifications
You must be signed in to change notification settings - Fork 391
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
🌱 Tunnel: Validate namespace/pod at the syncer side #2819
🌱 Tunnel: Validate namespace/pod at the syncer side #2819
Conversation
Skipping CI for Draft Pull Request. |
fbdc37a
to
7889f39
Compare
7889f39
to
4ae92d9
Compare
75a98a2
to
79c0ee4
Compare
/retest |
d1dd395
to
ac724b1
Compare
/retest |
ac724b1
to
5e0a7c9
Compare
/retest |
5e0a7c9
to
585ee3c
Compare
/lgtm |
pkg/syncer/tunneler.go
Outdated
// Ensure that requests are only for pods, and we have the required information, if not, return false. | ||
if requestInfo.Resource != "pods" || requestInfo.Subresource == "" || requestInfo.Name == "" || requestInfo.Namespace == "" { | ||
responsewriters.ErrorNegotiated( | ||
errors.NewForbidden(podGVR.GroupResource(), requestInfo.Name, fmt.Errorf("only pod subresources are allowed")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pod is not a subresource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
pkg/syncer/tunneler.go
Outdated
obj, err := nsInformer.Get(downstreamNamespaceName) | ||
if errors.IsNotFound(err) { | ||
responsewriters.ErrorNegotiated( | ||
errors.NewForbidden(namespaceGVR.GroupResource(), downstreamNamespaceName, fmt.Errorf("namespace %s does not exist", downstreamNamespaceName)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to leak that information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
pkg/syncer/tunneler.go
Outdated
} | ||
if locator.SyncTarget.Name != synctargetName || string(locator.SyncTarget.UID) != syncTargetUID || locator.SyncTarget.ClusterName != string(synctargetClusterName) { | ||
responsewriters.ErrorNegotiated( | ||
errors.NewForbidden(namespaceGVR.GroupResource(), downstreamNamespaceName, fmt.Errorf("namespace %q is not owned by this syncer", downstreamNamespaceName)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to leak that information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, we should not leak the existence of a namespace or a pod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm returning a more generic forbidden now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sttts is it OK for you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we complete unit tests to cover the new cases ?
585ee3c
to
182b830
Compare
Done, PTAL |
4f4d3eb
to
4d0531a
Compare
/lgtm |
4d0531a
to
ec35135
Compare
/retest |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
This PR adds an extra layer of security at the syncer side of the tunneler to ensure that the proxied requests are against a namespace owned by the syncer and a pod in upsync state.
Related issue(s)
Fixes #1975