[Bug] Shiro1CryptFormat.parse() throws ArrayIndexOutOfBoundsException for malformed hashes
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
Shiro1CryptFormat 位于 crypto/hash 模块下(shiro-core 中的模块 lang/crypto 包);打开 parse(String) 方法,跟踪它如何按 $ 拆分并用索引反向遍历各部分。运行 issue 中四个失败的输入以确认 AIOOBE,然后在任何索引操作之前添加一个长度保护,抛出 IllegalArgumentException("The argument is not a valid 'shiro1' formatted hash.")。完成的样子是四个代码片段都抛出 IAE,并且现有的 Shiro1CryptFormat 单元测试仍然通过。
由索引模型根据 Issue 内容生成。
描述
Search before asking
- I had searched in the issues, including closed issues and found no similar issues.
Environment
Not environment-specific: the bug is in pure string-parsing logic, so it happens on any OS/JDK.
Shiro version
main branch (commit ea33e99)
What was the actual outcome?
Shiro1CryptFormat.parse(String) throws ArrayIndexOutOfBoundsException when a $shiro1$ hash is missing one or more of its $-separated parts. The method counts backwards through the parts without checking how many there are.
What was the expected outcome?
IllegalArgumentException("The argument is not a valid 'shiro1' formatted hash."), the same exception the method already throws for an invalid prefix or non-numeric iterations.
How to reproduce
new Shiro1CryptFormat().parse("$shiro1$SHA-256"); // AIOOBE: Index -1 out of bounds for length 1
new Shiro1CryptFormat().parse("$shiro1$SHA-256$"); // AIOOBE
new Shiro1CryptFormat().parse("$shiro1$SHA-256$abc"); // AIOOBE
new Shiro1CryptFormat().parse("$shiro1$SHA-256$1$$"); // AIOOBE
Debug logs
No response
- 主要语言
- Java
- 星标
- 4.5k
- 派生
- 2.3k
- 平均合并
- 1 天 5 分钟
- 30 天内合并 PR
- 27
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/shiro 的其他 Issue
-
[Bug] PathMatchingFilterChainResolver.setPathMatcher() does not reach PathMatchingFilters可能已有人在做 @4n86rakam1 今天认领。 未关闭
难度 3/5 半天 新手友好度 38/100
维护者通常 1 天内回复
-
[Bug] Jakarta EE: secure-session-cookie.disabled is ignored in Faces Production mode可能已有人在做 @AndrewG10i 于 5 天前认领。 未关闭java valid
apache/shiro#2962 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Enable strict authorization configuration by default in 3.1可能已有人在做 @lprimak 于 11 天前认领。 未关闭java
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
help-wanted java valid
难度 5/5 一周以上 新手友好度 15/100
维护者通常 1 天内回复
-
valid
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
-
bug module: hybrid priority: high
难度 2/5 1-3 小时 新手友好度 72/100
bancolombia/bin-stash#92 ·
-
bug module:pubsub priority:P3
难度 2/5 1-3 小时 新手友好度 72/100
flink-gcp/flink-connector-gcp#2325 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
eclipse-dirigible/dirigible#8877 ·
维护者通常 1 天内回复