saml2aws icon indicating copy to clipboard operation
saml2aws copied to clipboard

Array index out of bounds error with Okta and MFA

Open simontrasler opened this issue 3 years ago • 2 comments

When running saml2aws 2.36.8, I get the output included below. I am able to authenticate with no issues using version 2.36.5. Let me know if you need more information.

I suspect this is an issue with the new block of code https://github.com/Versent/saml2aws/blob/v2.36.8/pkg/provider/okta/okta.go#L947-L973. This builds an array from one data source, and an index into that array from an another source, and expects them to match. In my case, the array length is 1, and the wanted index into that array is 1. The result is a crash.

strasler@strasler-mbp work % saml2aws --verbose login --duo-mfa-option 'Duo Push'
DEBU[0000] Running                                       command=login
DEBU[0000] Check if creds exist.                         command=login
DEBU[0000] Expand                                        name=/Users/strasler/.aws/credentials pkg=awsconfig
DEBU[0000] resolveSymlink                                name=/Users/strasler/.aws/credentials pkg=awsconfig
DEBU[0000] ensureConfigExists                            filename=/Users/strasler/.aws/credentials pkg=awsconfig
Using IdP Account default to access Okta https://springserve.okta.com/home/amazon_aws/XXX/272
DEBU[0000] Get credentials                               helper=osxkeychain serverURL="https://springserve.okta.com/home/amazon_aws/XXX/272"
To use saved password just hit enter.
? Username strasler
? Password ***********************

DEBU[0032] building provider                             command=login idpAccount="account {\n  DisableSessions: false\n  DisableRememberDevice: false\n  URL: https://springserve.okta.com/home/amazon_aws/XXX/272\n  Username: strasler\n  Provider: Okta\n  MFA: DUO\n  SkipVerify: false\n  AmazonWebservicesURN: urn:amazon:webservices\n  SessionDuration: 43200\n  Profile: default\n  RoleARN: arn:aws:iam::XXX:role/SSO-Developer\n  Region: us-east-1\n}"
DEBU[0032] okta | disableSessions: false                 provider=okta
DEBU[0032] okta | rememberDevice: true                   provider=okta
Authenticating as strasler ...
DEBU[0032] HTTP Req                                      URL="https://springserve.okta.com/api/v1/authn" http=client method=POST
DEBU[0033] HTTP Res                                      Status="200 OK" http=client
DEBU[0033] MFA                                           factorID=XXX mfaIdentifer="DUO WEB" oktaVerify="https://springserve.okta.com/api/v1/authn/factors/XXX/verify?rememberDevice=true" provider=okta
DEBU[0033] HTTP Req                                      URL="https://springserve.okta.com/api/v1/authn/factors/XXX/verify?rememberDevice=true" http=client method=POST
DEBU[0033] HTTP Res                                      Status="200 OK" http=client
DEBU[0033] HTTP Req                                      URL="https://api-6469eab8.duosecurity.com/frame/web/v1/auth?parent=https%3A%2F%2Fspringserve.okta.com%2Fsignin%2Fverify%2Fduo%2Fweb&tx=TX%7CXXX%3D%3D%7CXXX&v=2.8" http=client method=POST
DEBU[0033] HTTP Res                                      Status="200 OK" http=client
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/versent/saml2aws/v2/pkg/provider/okta.verifyMfa(0xc0003ed4a0, {0xc000030329, 0x14}, 0xc0000bc4d0, {0xc00017c380, 0x368})
	github.com/versent/saml2aws/v2/pkg/provider/okta/okta.go:975 +0x8505
github.com/versent/saml2aws/v2/pkg/provider/okta.(*Client).Authenticate(0xc0003ed4a0, 0xc0000bc4d0)
	github.com/versent/saml2aws/v2/pkg/provider/okta/okta.go:481 +0x1c6
github.com/versent/saml2aws/v2/cmd/saml2aws/commands.Login(0xc000082d00)
	github.com/versent/saml2aws/v2/cmd/saml2aws/commands/login.go:105 +0x4da
main.main()
	github.com/versent/saml2aws/v2/cmd/saml2aws/main.go:191 +0x76f8

simontrasler avatar May 25 '23 01:05 simontrasler

There has been a merged PR with a reference to this issue. Are you able to confirm the PR has resolved the issue?

tinaboyce avatar Dec 04 '23 13:12 tinaboyce

Unfortunately no, we've stopped using Okta since I posted the issue. However, I took a look at the PR and it does the right thing. Thanks for following up!

simontrasler avatar Dec 04 '23 18:12 simontrasler