traefik-helm-chart icon indicating copy to clipboard operation
traefik-helm-chart copied to clipboard

feat: restrict access to secrets

Open jnonino opened this issue 1 year ago • 2 comments

What does this PR do?

This PR aims to allow to users to restrict the secrets accesible by Traefik on the Kubernetes cluster. For this reason, I have added a new field into RBAC configuration secretResourceNames. By default, that value is an empty list ([]) and the behaviour is the same as before this change, all secrets are accesible from Traefik.

When that field contains one or more secret names, then only those secrets are the ones accessible from Traefik.

Motivation

Access to secrets without limits raises a security concern and Traefik should have access only to the secrets it requires to work properly, for example TLS certificates stored in secrets and used by Traefik. All other secrets in the cluster should not be accessible. This was raised in the issue 1006.

More

  • [x] Yes, I updated the tests accordingly
  • [x] Yes, I ran make test and all the tests passed

jnonino avatar Feb 21 '24 15:02 jnonino

Hi @darkweaver87, I'll change the name of the field. I was actually expecting feedback about it :smile:

jnonino avatar Feb 23 '24 09:02 jnonino

Linking with issue https://github.com/traefik/traefik/issues/7097 in Traefik repo as the discussion is relevant to the change added in this PR.

jnonino avatar Feb 27 '24 11:02 jnonino

@jnonino , it looks like our bot is not able to merge this PR because it can't rebase on master and push to your branch. Would you mind to rebase it ?

darkweaver87 avatar Mar 11 '24 07:03 darkweaver87

@jnonino any chance that you can rebase this PR ?

mloiseleur avatar Apr 03 '24 08:04 mloiseleur

@jnonino any chance that you can rebase this PR ?

Done!!! Sorry for the delay

jnonino avatar Apr 03 '24 09:04 jnonino

With

  - apiGroups:
      - ""
    resources:
      - secrets
    verbs:
      - list

still present in roles.yaml, this

  - apiGroups:
      - ""
    resources:
      - secrets
    {{- if gt (len $.Values.rbac.secretResourceNames) 0 }}
    resourceNames: {{ $.Values.rbac.secretResourceNames }}
    {{- end }}
    verbs:
      - get
      - list

poses no restriction, since the list verb is a superset of get. With this, traefik still has access to every resource in that namespace. I understand that traefik is "broken" in a way that it needs that permission, but being able to define a list of resourceNames gives the user a false feeling of security.

Or what am I missing?

Alestrix avatar Jun 20 '24 10:06 Alestrix