From e58c4ff2278161c62b6a22144aded3f7f521f831 Mon Sep 17 00:00:00 2001 From: Min Ni Date: Sat, 9 Dec 2023 15:34:01 -0800 Subject: [PATCH 1/2] minor fix the IAM user arn verification --- pkg/mapper/dynamicfile/mapper.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/mapper/dynamicfile/mapper.go b/pkg/mapper/dynamicfile/mapper.go index d11cda4fc..6112c4265 100644 --- a/pkg/mapper/dynamicfile/mapper.go +++ b/pkg/mapper/dynamicfile/mapper.go @@ -3,6 +3,7 @@ package dynamicfile import ( "strings" + "github.com/sirupsen/logrus" "sigs.k8s.io/aws-iam-authenticator/pkg/arn" "sigs.k8s.io/aws-iam-authenticator/pkg/config" "sigs.k8s.io/aws-iam-authenticator/pkg/errutil" @@ -46,31 +47,34 @@ func (m *DynamicFileMapper) Map(identity *token.Identity) (*config.IdentityMappi } if roleMapping, err := m.RoleMapping(key); err == nil { - if err := m.match(identity, roleMapping.RoleARN, roleMapping.UserId); err != nil { + if err := m.match(canonicalARN, roleMapping.RoleARN); err != nil { return nil, err } return roleMapping.IdentityMapping(identity), nil } if userMapping, err := m.UserMapping(key); err == nil { - if err := m.match(identity, userMapping.UserARN, userMapping.UserId); err != nil { + if err := m.match(canonicalARN, userMapping.UserARN); err != nil { return nil, err } return userMapping.IdentityMapping(identity), nil - } + } return nil, errutil.ErrNotMapped } -func (m *DynamicFileMapper) match(token *token.Identity, mappedARN, mappedUserID string) error { +func (m *DynamicFileMapper) match(canonicalARN string, mappingARN string) error { if m.userIDStrict { // If ARN is provided, ARN must be validated along with UserID. This avoids having to // support IAM user name/ARN changes. Without preventing this the mapping would look // invalid but still work and auditing would be difficult/impossible. - strippedArn, _ := arn.StripPath(mappedARN) - if strippedArn != "" && token.CanonicalARN != strings.ToLower(strippedArn) { + strippedArn, _ := arn.StripPath(mappingARN) + logrus.Infof("additional arn comparison for IAM arn. arn from STS response is %s, arn in mapper is %s", + canonicalARN, strings.ToLower(strippedArn)) + if strippedArn != "" && canonicalARN != strings.ToLower(strippedArn) { return errutil.ErrIDAndARNMismatch } + return nil } return nil } From 92c363cd7c12e69600a3138bfe4430726d603548 Mon Sep 17 00:00:00 2001 From: Min Ni Date: Sat, 9 Dec 2023 19:51:08 -0800 Subject: [PATCH 2/2] release v0.6.16 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 6769f67e2..c4c2d2b11 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.6.15 +0.6.16