Repository navigation
Hash digest ACL ids with the platform charset, as in branch-3.6 - #192
Draft
bellatrix007 wants to merge 1 commit into
Draft
bellatrix007 wants to merge 1 commit into
bellatrix007 wants to merge 1 commit into
Conversation
ZOOKEEPER-3342 changed DigestAuthenticationProvider.digest() to hash with UTF-8, while handleAuthentication() still decodes the auth bytes with the platform charset. On a host whose default charset is not UTF-8 (prod and sandbox-blr run US-ASCII), a digest ACL persisted by 3.6.3-35 with a non-ASCII user or password no longer matches after the upgrade, so access to the znode is lost. Setting file.encoding=UTF-8 does not restore the old hash. Hash with the platform default charset again. This is identical to 3.8.7 on UTF-8 hosts and identical to 3.6.3-35 on every other host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hash digest ACL ids with the platform charset, as in branch-3.6
Based on
li-dev/base-3.8.7(P01 to P14 are already merged there).Problem
DigestAuthenticationProvider.digest()hashes with UTF-8 since ZOOKEEPER-3342, buthandleAuthentication()stilldecodes the auth bytes with the platform charset. On a host whose default charset is not UTF-8, a digest ACL persisted by
3.6.3-35 with a non-ASCII user or password no longer matches after the upgrade, and access to the znode is lost.
Setting
file.encoding=UTF-8does not bring the old hash back, because the stored ids were already built from thecharset-mangled string.
Prod is affected:
zk.sandbox-rainprod-ltx1 reportsfile.encoding=ANSI_X3.4-1968(US-ASCII), and so does everysandbox-blr node. ASCII-only credentials are unaffected.
Change
digest()callsidPassword.getBytes()again (platform default charset), as in branch-3.6, and the unusedUTF_8import isremoved. One production line, no new configuration.
Trade-offs
DigestAuthenticationProvider.generateDigestis also what the client tools use, so on a non-UTF-8 hostjava ... DigestAuthenticationProvider user:pwprints the 3.6 value again.Testing
New
DigestAuthenticationProviderCharsetTestruns the realhandleAuthenticationpath in a child JVM started with-Dfile.encoding=US-ASCII(a UTF-8 JVM cannot tell the two behaviours apart).expected: iluzynxkwbZ1KS/W7MV6IQ4Rts4= but was: F2E4i782FsuPaGBSfsCS6MLGvYM=.AuthTest,AuthSHA2Test,AuthSHA3Test,EnsembleAuthenticationProviderTestpass. Checkstyle: 0 violations.End to end on real standalone servers (server
file.encoding=US-ASCII, UTF-8 client, throwaway credentialü:pw),in-place restart on the data written by 3.6.3-35:
get /dig-uwithü:pwget /dig-awithu:pwdd(access kept)ddInsufficient permission : /dig-udddd(access kept)ddFresh server with this PR: the stored ids are byte-identical to 3.6.3-35 under US-ASCII, and identical to both versions
under UTF-8.
Script and output:
run13_digest_patched.sh.The end-to-end runs used the
3.8.7-0distribution with onlyDigestAuthenticationProvider.classreplaced; that class isidentical in
li-dev/base-3.8.7. The unit tests and checkstyle were re-run on this branch after rebasing onto the base.Not covered