Skip to content

Updating AWSSDK to v4 causes Invalid authentication payload exceptions from AWS MSK brokers #4020

@janv97

Description

@janv97

Describe the bug

After upgrading AWSSDK.SecurityToken to version 4.x, we began encountering sporadic errors from the Kafka brokers with the message: Invalid authentication payload. These errors occur intermittently, typically every 5 to 30 minutes, a few times per day.

We have since reverted to AWSSDK version 3.x, which resolves the issue for now.

I’m currently in contact with AWS Support, and they recommended that I post the issue here as well. Additionally, I couldn’t find any relevant information in the migration docs.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

There are no authentication failures logged, nor any documentation explaining what changes are required to avoid these exceptions.

Current Behavior

Exception:

/bootstrap: SASL authentication error: [53fb19f7-525a-47e4-a7cd-9b7bed03310c]: Invalid authentication payload (after 101ms in state AUTH_REQ)

Reproduction Steps

Upgrade

    <PackageReference Include="AWS.MSK.Auth" Version="1.0.0" />
    <PackageReference Include="AWSSDK.Glue" Version="3.7.408.2" />

To

    <PackageReference Include="AWS.MSK.Auth" Version="1.1.1" />
    <PackageReference Include="AWSSDK.Glue" Version="4.0.16.2" />
    <PackageReference Include="AWSSDK.SecurityToken" Version="4.0.2.2" />

Possible Solution

No response

Additional Information/Context

OAuthCallback method:

    public void OAuthCallback(IClient client, string principalName)
    {
        try
        {
            // Warning: These are blocking calls. We cannot use async/await here due to Confluent.Kafka limitations.
            (string token, long expiryMs) = _mskTokenGenerator.GenerateAuthTokenAsync(Amazon.RegionEndpoint.EUWest1).Result;

            client.OAuthBearerSetToken(token, expiryMs, principalName);
        }
#pragma warning disable CA1031 // Do not catch general exception types
        catch (Exception ex)
#pragma warning restore CA1031
        {
            client.OAuthBearerSetTokenFailure(ex.ToString());
        }
    }

Consumer builder:

return new ConsumerBuilder<string, TMessageValue>(consumerConfig)
    .SetOAuthBearerTokenRefreshHandler((client, _) => oAuthService.OAuthCallback(client, principalName))
    .SetKeyDeserializer(Deserializers.Utf8)
    .SetValueDeserializer(valueDeserializer)
    .Build();

AWS .NET SDK and/or Package version used

    <PackageReference Include="AWS.MSK.Auth" Version="1.1.1" />
    <PackageReference Include="AWSSDK.Glue" Version="4.0.16.2" />
    <PackageReference Include="AWSSDK.SecurityToken" Version="4.0.2.2" />

Targeted .NET Platform

.NET 8.0

Operating System and version

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.investigatingThis issue is being investigated and/or work is in progress to resolve the issue.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions