Skip to content

[#2967] - Shiro1CryptFormat.parse() throws ArrayIndexOutOfBoundsException for malformed hashes - #2968

Open
kayodeo1 wants to merge 1 commit into
apache:mainfrom
kayodeo1:fix-shiro1-parse
Open

kayodeo1 wants to merge 1 commit into
apache:mainfrom
kayodeo1:fix-shiro1-parse

Conversation

@kayodeo1

@kayodeo1 kayodeo1 commented Nov 23, 2026 •

Copy link
Copy Markdown

Fixes #2967

Shiro1CryptFormat.parse() read tokens from the end of the split string without checking the token count, so truncated input such as "$shiro1$SHA-256" threw ArrayIndexOutOfBoundsException. Validate that all four tokens (algorithm, iterations, salt, digest) are present and throw IllegalArgumentException otherwise, consistent with the existing invalid-prefix and non-numeric-iterations handling.

LLM was used with this PR.

Following this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GitHub issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a GitHub issue. Your pull request should address just this issue, without pulling in other changes.
  • Format the pull request title like [#XXX] - Fixes bug in SessionManager,
    where you replace #XXX with the appropriate GitHub issue. Best practice
    is to use the GitHub issue title in the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • add fixes #XXX if merging the PR should close a related issue.
  • Run mvn verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • Committers: Make sure a milestone is set on the PR
  • Committers: Use "Squash and Merge" to combine all commits into one when merging a PR when appropriate.

Trivial changes like typos do not require a GitHub issue (javadoc, comments...).
In this case, just format the pull request title like [DOC] - Add javadoc in SessionManager.

If this is your first contribution, you have to read the Contribution Guidelines

If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement
if you are unsure please ask on the developers list.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 21:19

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lprimak lprimak left a comment •

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.

Just 2 nits, the testing one is more important.
Thank you for your contribution!
Can you please tick appropriate checkboxes (especially licensing)
Also, can you redo your commit without the claude code attribution

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues were identified for the malformed-hash input-validation change.

No open issues 🎉

Review effort: Balanced

@lprimak lprimak left a comment

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.

Requesting changes until at least license boxes are clicked

@lprimak lprimak added this to the 3.1.0 milestone Nov 24, 2026
@lprimak

lprimak commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@kayodeo1 Can you please update the PR accordingly? Thank you!

…sException for malformed hashes

Shiro1CryptFormat.parse() read tokens from the end of the split string
without checking the token count, so truncated input such as
"$shiro1$SHA-256" threw ArrayIndexOutOfBoundsException. Validate that
all four tokens (algorithm, iterations, salt, digest) are present and
throw IllegalArgumentException otherwise, consistent with the existing
invalid-prefix and non-numeric-iterations handling.

Fixes apache#2967
@kayodeo1 kayodeo1 changed the title fix(crypto): reject malformed shiro1 hashes with IllegalArgumentExcep… [#2967] - Shiro1CryptFormat.parse() throws ArrayIndexOutOfBoundsException for malformed hashes Nov 24, 2026
@kayodeo1

Copy link
Copy Markdown
Author

Thanks @lprimak! I've addressed everything:

For transparency: I used an AI assistant to help with this change, and I've reviewed and verified it myself. CI hasn't run on the PR yet, so I haven't ticked the mvn verify box.

@lprimak lprimak added CLA and removed pending-cla labels Nov 24, 2026
@lprimak
lprimak requested a balanced review from Copilot November 24, 2026 16:32
@github-actions github-actions Bot added java Pull requests that update Java code tests groovy labels Nov 24, 2026

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues are reported for the change to reject truncated Shiro1 hashes with IllegalArgumentException.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA core Core Modules groovy java Pull requests that update Java code tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Shiro1CryptFormat.parse() throws ArrayIndexOutOfBoundsException for malformed hashes

3 participants