smi-spec icon indicating copy to clipboard operation
smi-spec copied to clipboard

Should objectReferences be used in TrafficTargets to prevent exceeding RBAC

Open dtomcej opened this issue 4 years ago • 4 comments

Describe the proposal

When defining TrafficTarget sources and destinations, the elements name and namespace are not validated to ensure that the user has access to those resources.

This can lead to situations where a user may be able to allow traffic to or from sources that they shouldn't.

Using objectReferences could prevent this by leveraging the RBAC and built-in kubernetes validation to ensure that the referenced objects are visible to the user, and that the objects exist.

Scope

  • [ ] New specification
  • [x] Traffic Access Control
  • [ ] Traffic Specs
  • [ ] Traffic Metrics
  • [ ] Traffic Split

Possible use cases

A user in namespace default with RBAC restrictions restricting users to that namespace should not be able to create a TrafficTarget allowing traffic out of that namespace and into another.

dtomcej avatar May 13 '20 20:05 dtomcej

@dtomcej when you're talking about objectReferences, is it something specific to the go client or RBAC specifically in k8s? Any pointers to docs I could read would be greatly appreciated =)

grampelberg avatar May 13 '20 22:05 grampelberg

Hey @grampelberg, objectReferences are a core type in kubernetes:

https://godoc.org/k8s.io/api/core/v1#ObjectReference

An example of its usage, is in the EndpointAddress type, which has an objectReference to the Pod that has the endpoint address:

https://github.com/kubernetes/api/blob/master/core/v1/types.go#L4219

dtomcej avatar May 13 '20 22:05 dtomcej

@dtomcej yeah, I've used objectReferences before, but I've never needed read access on the referenced object to apply it.

grampelberg avatar May 14 '20 15:05 grampelberg

A user in namespace default with RBAC restrictions restricting users to that namespace should not be able to create a TrafficTarget allowing traffic out of that namespace and into another.

If a user has rights to multiple namespaces, they should be allowed to have sources and destinations in different namespaces. There is definitely a use case for the source and destination to be in different namespaces.

shashankram avatar May 22 '20 19:05 shashankram