Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@cpanato @ameukam So the issue I have with this is that it allows this service account to act as any other service account in this project. That's privilege escalation waiting to happen. Can we not constrain this binding to the actual service account that needs to be used?
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.
This is the same comment I had here #2061 (comment)
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.
@spiffxp we could bind the service account to the default SA for the compute service.
I'll investigate this week-end.
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.
sorry for the delay to reply, i tried to be off this weekend
How can we fix that? I will try to create the same environment again and apply other roles to check.
but the comment from @ameukam is something that we can do?
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.
Basically it would help to know what service account packer is trying to use, so we could apply this role just to that service account
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 thought the service account it is using is the one we set in the Job Config : https://github.com/kubernetes/test-infra/blob/master/config/jobs/kubernetes/wg-k8s-infra/trusted/image-builder/image-builder-periodics.yaml#L12
it is available in the container and packer uses that one.
This is my understanding, now I don't know if that is correct. :/
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.
The service account that the job (and thus packer) runs as is what we set in the job config, correct. However packer's instructions [1] indicate that whatever is running packer needs the
Service Account Userrole, meaning they expect packer to be able to impersonate a different service account [2]I'm going to take a wild guess that this is to allow packer to attach the service account it's currently running as to any other instances it happens to create [4]. So probably narrow the binding to itself. I would hope that logs or the code could confirm the guess and allow us to narrow the binding's scope.
References:
[1]: https://www.packer.io/docs/builders/googlecompute#running-on-google-cloud
[2]: https://cloud.google.com/iam/docs/impersonating-service-accounts
[3]: https://cloud.google.com/iam/docs/impersonating-service-accounts#attaching-to-resources
[4]: https://cloud.google.com/compute/docs/access/service-accounts#associating_a_service_account_to_an_instance