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

Đang mở Phù hợp với người mới
#2,967 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
authentication, security

Hướng nghiên cứu

Shiro1CryptFormat nằm dưới module crypto/hash (các package module lang/crypto trong shiro-core); mở phương thức parse(String) và theo dõi cách nó tách trên $ và duyệt các phần ngược lại bằng chỉ mục. Chạy bốn input đang lỗi từ issue để xác nhận AIOOBE, sau đó thêm một guard độ dài để ném IllegalArgumentException("The argument is not a valid 'shiro1' formatted hash.") trước mọi thao tác đánh chỉ mục. Xong trông như cả bốn snippet đều ném IAE và các unit test hiện có của Shiro1CryptFormat vẫn pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Search before asking
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

Ngôn ngữ chính
Java
Star
4.5k
Fork
2.3k
Merge trung bình
1 ngày 5 phút
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/shiro

Tất cả issue của apache/shiro

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.