Skip to content
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

[Bug] update sample policies to include all container types in a pod #951

Open
2 of 6 tasks
JimBugwadia opened this issue Mar 22, 2024 · 0 comments
Open
2 of 6 tasks
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@JimBugwadia
Copy link
Member

Kyverno Version

1.12

Kubernetes Version

1.29

Kubernetes Platform

Minikube

Description

A end user brought this up at KubeCon EU 2024. A number of sample policies target containers in a pod, but do not handle initContainers and ephemeralContainers.

Note that this is not an issue for any Pod Security Standard related policies, but applies to best practices and other security samples.

However, this may be something end users are oblivious of and hence end up using the sample policy which leaves a potential gap.

This can be handled easily as done in the following policy:

https://kyverno.io/policies/psp-migration/restrict-adding-capabilities/restrict-adding-capabilities/

      validate:
        message: >-
          Any capabilities added other than NET_BIND_SERVICE or CAP_CHOWN are disallowed.          
        foreach:
          - list: request.object.spec.[ephemeralContainers, initContainers, containers][]
            deny:
              conditions:
                all:
                - key: "{{ element.securityContext.capabilities.add[] || '' }}"
                  operator: AnyNotIn
                  value:
                  - NET_BIND_SERVICE
                  - CAP_CHOWN
                  - ''

Here is a list of some of these policies:

Steps to reproduce

  1. Check samples like: https://kyverno.io/policies/psp-migration/add-apparmor/add-apparmor/

Expected behavior

  1. Update all security and best practices related policies to handle all pod types.
  2. Update test cases to handle initContainers

Screenshots

No response

Kyverno logs

No response

Slack discussion

No response

Troubleshooting

  • I have read and followed the documentation AND the troubleshooting guide.
  • I have searched other issues in this repository and mine is not recorded.
@JimBugwadia JimBugwadia added bug Something isn't working Contribfest Good first issues for KubeCon EU 2024 labels Mar 22, 2024
@realshuting realshuting added good first issue Good for newcomers and removed Contribfest Good first issues for KubeCon EU 2024 labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: No status
Status: No status
Development

No branches or pull requests

2 participants