Skip to content

Conversation

@philnichol
Copy link
Contributor

@philnichol philnichol commented Dec 30, 2021

Issue #, if available:

Relates aws-controllers-k8s/community#1112

Description of changes:

  • No longer runs as root, runs as nobody instead, since runtime is from scratch I've added a "dummy" /etc/shadow file
  • Runtime image is now "from scratch" since we don't need much other than ca-certs and the binary itself (eg. curl, vim, etc)
  • Standard principle of least privilege security caps in deployment manifest (drop all plus explicit least privilege deployment/pod settings and capabilities)

This is a draft since there's still stuff missing, and not sure if you would want to go in a different direction

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

- No longer runs as root
- Runtime image is now "from scratch"
- Standard principle of least privilege security caps in deployment manifest
@ack-bot ack-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 30, 2021
@ack-bot ack-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 30, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Dec 30, 2021

Hi @philnichol. Thanks for your PR.

I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vijtrip2
Copy link
Contributor

/ok-to-test

@ack-bot ack-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 30, 2021
Copy link
Contributor

@vijtrip2 vijtrip2 left a comment

Choose a reason for hiding this comment

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

one single comment, otherwise looks good (I will test it locally once just for proof and then approve :) )

Copy link
Contributor

@vijtrip2 vijtrip2 left a comment

Choose a reason for hiding this comment

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

This is excellent stuff! Thank you!

I tested it locally by building ecr-controller image, installing using new helm chart template, creating an ecr repository and deleting it. Everything works fine! :)

I will let another ACK team member give this a look as well but LGTM.


P.S. two more files need update, Dockerfile.local and templates/config/controller/deployment.yaml.tpl but I can handle that in separate PR.

@@ -1,5 +1,11 @@
# Base image to use for the final stage
ARG base_image=public.ecr.aws/amazonlinux/amazonlinux:2
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Please remove this base_image arg as it is no longer used.

@vijtrip2
Copy link
Contributor

/ok-to-test

@philnichol
Copy link
Contributor Author

thanks @vijtrip2 ! Have addressed your feedback and included the files you mentioned. Also just realised since this is security-related it probably should have been raised via a more private medium, apologies for that, won't happen again

@vijtrip2
Copy link
Contributor

/ok-to-test

@philnichol philnichol marked this pull request as ready for review December 31, 2021 13:22
@ack-bot ack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 31, 2021
@philnichol
Copy link
Contributor Author

/retest

Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Firstly, @philnichol thank you so much for your PR and for raising awareness of this important topic. I really appreciate it!

That said, I'd like to request that for this particular PR, we remove any changes to the Dockerfiles and only update the deployment.yaml files/templates.

I've just had a conversation with @micahhausler (who is my go-to person to talk about container build/toolchain security) and I'd like ACK to move away from the fat AL2 container image base and into the distroless-like EKS-D minimal AL2-based base non-root container image available here:

https://gallery.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot
(source code for the above image is here: https://github.com/aws/eks-distro-build-tooling/tree/main/eks-distro-base)

The reason I'd like to do this is twofold:

  1. The EKS-D/EKS-Anywhere team has expertise in build toolchain provenance and security and all aspects of the EKS-D build toolchain are audited and owned by AMZN

  2. We (the ACK team) should take advantage of the work that the EKS-D team has done over the last 2 years and reduce our overall surface area (for both supply-chain attacks as well as simply the amount of work it takes to keep a build chain up to date and secure).

Therefore, @philnichol if we could slim this particular PR down to just the changes to the deployment manifests (which are awesome, BTW!) and tackle the refactoring of the base image in a separate PR, that would be great. Thank you!

@philnichol
Copy link
Contributor Author

@jaypipes thanks for the feedback! Great point, makes sense to use the work that you guys already have on minimal container images 😄 , I've removed the Dockerfiles from this PR

@jaypipes
Copy link
Collaborator

jaypipes commented Jan 3, 2022

/lgtm

thanks @philnichol

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 3, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Jan 3, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jaypipes, philnichol, vijtrip2

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit d29e4e8 into aws-controllers-k8s:main Jan 3, 2022
@philnichol philnichol deleted the hardening-container branch January 3, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants