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

Enrich Audit Logs with additional AWS Identity details (via audit logs' "extra" map) #372

Merged
merged 1 commit into from
May 18, 2021

Conversation

adrianosela
Copy link
Contributor

Enrich Audit Logs with additional AWS Identity details (via audit logs' "extra" map)

Purpose

It would be helpful for consumers of Kubernetes Audit logs to be presented with all available information about the identity performing a given action against the k8s api.

The Identity struct in token.go contains all of:

  • ARN (string): ARN is the raw Amazon Resource Name returned by sts:GetCallerIdentity
  • CanonicalARN (string): CanonicalARN is the Amazon Resource Name converted to a more canonical representation. In particular, STS assumed role ARNs like "arn:aws:sts::ACCOUNTID:assumed-role/ROLENAME/SESSIONNAME" are converted to their IAM ARN equivalent "arn:aws:iam::ACCOUNTID:role/NAME"
  • AccountID (string): AccountID is the 12 digit AWS account number.
  • UserID (string): UserID is the unique user/role ID (e.g., "AROAAAAAAAAAAAAAAAAAA").
  • SessionName (string): SessionName is the STS session name (or "" if this is not a session-based identity). For EC2 instance roles, this will be the EC2 instance ID (e.g., "i-0123456789abcdef0"). You should only rely on it if you trust that only EC2 is allowed to assume the IAM Role. If IAM users or other roles are allowed to assume the role, they can provide (nearly) arbitrary strings here.
  • AccessKeyID (string): The AWS Access Key ID used to authenticate the request. This can be used in conjuction with CloudTrail to determine the identity of the individual if the individual assumed an IAM role before making the request.

Everything in the Identity struct is now being logged:

  • AccessKeyID is/was already logged in the extra map.
  • AccountID and UserID is/was already logged as the uid in the audit log.
  • ARN, CanonicalARN and SessionName are newly added to the extra map.

Testing

Before this change the helper function tokenReview took only the accesskeyid string as an argument:

tokenReview(username, uid string, groups []string, accesskeyid string) authenticationv1beta1.TokenReview

Now, the function takes in the entire "extra" map as an arg, to verify the newly logged parts of the identity:

tokenReview(username, uid string, groups []string, extrasMap map[string]authenticationv1beta1.ExtraValue) authenticationv1beta1.TokenReview.

Tests were modified to check the whole map and not just one field.

@k8s-ci-robot
Copy link
Contributor

Welcome @adrianosela!

It looks like this is your first PR to kubernetes-sigs/aws-iam-authenticator 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/aws-iam-authenticator has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 17, 2021
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 17, 2021
@nckturner
Copy link
Contributor

/cc @wongma7

@k8s-ci-robot k8s-ci-robot requested a review from wongma7 May 17, 2021 18:54
@nckturner
Copy link
Contributor

Thanks @adrianosela, it seems reasonable and helpful to have more information in audit logs.

@nckturner
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2021
@nckturner
Copy link
Contributor

/cc @micahhausler

@nckturner
Copy link
Contributor

Will wait for another reviewer before approving.

@wongma7
Copy link
Contributor

wongma7 commented May 17, 2021

makes sense to me. you can map multiple IAM users/roles to the same kubernetes user/group, plus different sessions may make use* of same role. So without this info it is difficult/impossible from audit log to determine i.e. audit what IAM entity actually made a given request.

/lgtm

@nckturner
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianosela, nckturner

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 18, 2021
@k8s-ci-robot k8s-ci-robot merged commit 4c5c6d9 into kubernetes-sigs:master May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants