bug: AppSync: a request authorised by Cognito is rejected with IncompleteSignatureException when AWS_IAM is also an allowed auth mode (GraphQL fields and Events APIs) #88
Replies: 2 comments 3 replies
|
Hello and thank you for the detailed report! The GraphQL part is already fixed and will be part of our next November release coming soon (fields with several auth directives are now evaluated under the mode matching the request's credentials). It's currently only available in the The Events part is a known gap: Cognito/OIDC auth modes aren't implemented for Events APIs yet, so a JWT is routed to the IAM check. We're tracking it, I'll try to add it before the next release is cut, and will update you once it's available to try out in Thanks again for the report! |
|
Verified end to end on localstack/localstack:dev 2026.11.0.dev993:1fdd8a47, thanks. The reproduction script: Events publish with the Cognito id token now answers 200 under [AWS_IAM, AMAZON_COGNITO_USER_POOLS] and [AMAZON_COGNITO_USER_POOLS, AWS_IAM] (403 before); the GraphQL cases as on dev958. Our real Events API restored to its CDK auth modes (user pool and IAM): websocket connect, subscribe, publish over HTTP and over the socket, both events delivered. The channel namespace Lambda handler now receives identity with claims, sub, username, issuer, sourceIp and groups for subscribe and publish, where it was null; our handler forwards to EventBridge and the application's asynchronous mutation completes with the user's identity. The absence of defaultAuthStrategy on Events identity is no problem for us; we read username and sub. Our two emulator-side workarounds (stripping @aws_iam from the deployed schema, forcing Cognito as the only Events auth mode) are no longer needed on this build. Looking forward to the November release. If you happen to be at re:Invent I owe you a couple of beers :) |
Uh oh!
There was an error while loading. Please reload this page.
Current behavior
On AWS AppSync, a GraphQL field that carries several authorization directives accepts a request authorised by any of them, and an Events API accepts a connection, publish or subscribe authorised by any of the modes listed for it. On LocalStack, as soon as
AWS_IAMis among the allowed modes, a request carrying a valid Cognito user-pool id token is rejected with:The token is parsed as a SigV4 header and the IAM check fails, although the Cognito mode would have accepted it. The same token is accepted the moment
AWS_IAMis removed from the allowed modes.GraphQL. API with
AMAZON_COGNITO_USER_POOLSas the default authentication type andAWS_IAMas an additional provider, schema:NONE data source, a resolver per field returning
"ok". With the pool user's id token in theAuthorizationheader:{ both }IncompleteSignatureException{"data":{"both":"ok"}}{ poolOnly }{"data":{"poolOnly":"ok"}}{ iamOnly }IncompleteSignatureExceptionThe LocalStack log for the failing field reads
Enforcing AWS_IAM for AppSync API <id>: [both].Events. An Events API with the auth providers
AWS_IAMandAMAZON_COGNITO_USER_POOLSand the same two modes inconnectionAuthModes,defaultPublishAuthModesanddefaultSubscribeAuthModes; one channel namespace; aPOST /eventwith the id token:[AWS_IAM, AMAZON_COGNITO_USER_POOLS]IncompleteSignatureException[AMAZON_COGNITO_USER_POOLS, AWS_IAM]IncompleteSignatureException[AMAZON_COGNITO_USER_POOLS]So the order does not matter: an IAM mode anywhere in the list makes the token fail.
Expected behavior
Any one of the allowed modes satisfying the request authorises it, as on AWS:
connectionAuthModes/ publish / subscribe as the set of modes accepted for that operation.A request should be matched to the mode its credentials correspond to (a JWT to the user-pool or OIDC mode, a SigV4 signature to IAM, an
x-api-keyheader to the API key mode) and evaluated against that mode only, failing only if no allowed mode accepts it.How are you starting LocalStack?
With a docker-compose file (LocalStack Pro 2026.10.7,
PERSISTENCE=1), the AWS CLI andcurlfrom a workstation. The schema and the three fields are created withaws appsync create-graphql-api/start-schema-creation/create-data-source/create-resolver; the Events API withcreate-api/create-channel-namespace/update-api. The full reproduction is the attached scriptrepro-multiauth.sh(needs a user pool id and a user's id token; creates and deletes its two APIs).Why it matters
Every AWS Amplify Gen 2 application hits this on its first authenticated query: the Amplify data construct enables the IAM authorization mode on every
defineDataAPI for its managed roles, and the GraphQL transformer then writes@aws_cognito_user_pools @aws_iamon every field of every type. On AWS the application's Cognito users are unaffected; on LocalStack every field answersIncompleteSignatureExceptionuntil the deployed schema is downloaded, stripped of@aws_iamand re-uploaded withstart-schema-creation, which has to be redone after every deploy. The Events API of the same application listsAWS_IAMfirst for the same reason and needs anupdate-apito Cognito-only after every deploy.Environment
localstack/localstackLOCALSTACK_HOSTset to a custom hostname#Reproduction Script
All reactions