Skip to content

KAFKA-7915: Don't return sensitive authentication errors to clients#6252

Merged
rajinisivaram merged 3 commits intoapache:trunkfrom
rajinisivaram:KAFKA-7915-auth-error
Feb 11, 2019
Merged

KAFKA-7915: Don't return sensitive authentication errors to clients#6252
rajinisivaram merged 3 commits intoapache:trunkfrom
rajinisivaram:KAFKA-7915-auth-error

Conversation

@rajinisivaram
Copy link
Copy Markdown
Contributor

@rajinisivaram rajinisivaram commented Feb 11, 2019

Don't return error messages from SaslException to clients. Error messages to be returned to clients to aid debugging must be thrown as AuthenticationExceptions. This is a fix for a regression from KAFKA-7352 which is not yet in any release (will be in 2.2.0).

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@rajinisivaram rajinisivaram requested a review from ijuma February 11, 2019 15:46
@@ -1819,8 +1882,8 @@ private void createAndCheckClientAuthenticationFailure(SecurityProtocol security
assertEquals(expectedErrorMessage, exception.getMessage());
else {
String expectedErrorMessagePrefix = "Authentication failed during authentication due to invalid credentials with SASL mechanism "
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: expectedErrorMessage rather than expectedErrorMessagePrefix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Good catch before the release. Just a few minor comments.


SecurityProtocol securityProtocol = SecurityProtocol.SASL_PLAINTEXT;
TestJaasConfig jaasConfig = configureMechanisms("SCRAM-SHA-256", Collections.singletonList("SCRAM-SHA-256"));
jaasConfig.createOrUpdateEntry(TestJaasConfig.LOGIN_CONTEXT_SERVER, PlainLoginModule.class.getName(), new HashMap<String, Object>());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we use the diamond operator?

+ mechanism + ": ";
if (exception.getMessage().startsWith(expectedErrorMessagePrefix))
+ mechanism;
if (exception.getMessage().equals(expectedErrorMessagePrefix))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use assertEquals?


public static class InvalidScramServerCallbackHandler implements AuthenticateCallbackHandler {
static volatile IOException sensitiveException;
static volatile SaslAuthenticationException clientFriendlyException;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need two fields? From looking at the code, it wasn't clear to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only checked exception we can throw from the callback handler is IOException and the second exception is a RuntimeException, hence the two exceptions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please add a comment to make it clear?

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

@rondagostino @ijuma Thanks for the reviews, I have addressed the comments.

Copy link
Copy Markdown
Member

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment, but LGTM. We can merge once that's addressed, no re-review needed.

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

retest this please

@ijuma
Copy link
Copy Markdown
Member

ijuma commented Feb 11, 2019

@mjsax we need this in 2.2 btw. We should be able to merge it today or tomorrow.

@rajinisivaram
Copy link
Copy Markdown
Contributor Author

Test failures are unrelated, merging to trunk and 2.2.

@rajinisivaram rajinisivaram merged commit 5148d7b into apache:trunk Feb 11, 2019
rajinisivaram added a commit that referenced this pull request Feb 11, 2019
…6252)

Don't return error messages from `SaslException` to clients. Error messages to be returned to clients to aid debugging must be thrown as AuthenticationExceptions. This is a fix for a regression from KAFKA-7352.

Reviewers: Ron Dagostino <rndgstn@gmail.com>, Ismael Juma <ismael@juma.me.uk
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…pache#6252)

Don't return error messages from `SaslException` to clients. Error messages to be returned to clients to aid debugging must be thrown as AuthenticationExceptions. This is a fix for a regression from KAFKA-7352.

Reviewers: Ron Dagostino <rndgstn@gmail.com>, Ismael Juma <ismael@juma.me.uk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants