Security: the superuser password of hypha.php is stored in plain text; options to improve password storage

Đang mở
#642 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ó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
53/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
authentication, security

Hướng nghiên cứu

Start with hypha.php, especially the password declaration near line 10, the installer write near line 111, and the login check near line 454; then read system/core/crypto.php to see how password hashing is handled. The issue recommends hashing the superuser password, verifying it on login, and safely writing the value into PHP source. Done means existing installs can transition safely and new passwords are no longer stored in plain text.

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

Mô tả

Impact: Medium Level: Easy Type: Bug Value: Security

How Hypha stores passwords now

Password Where How
Member accounts data/hypha.xml, attribute password of <user> password_hash($password, PASSWORD_DEFAULT) (bcrypt with salt) in system/core/crypto.php. Accounts from older Hypha versions can still hold an unsalted MD5 hash, compared with ==. That part is #426, with PR #491.
Superuser of hypha.php (install and maintenance) hypha.php itself, line 10: $password = '...'; Plain text. The installer writes the posted value into the PHP source with preg_replace (line 111), and the login compares it with === (line 454).

So member passwords are hashed (not encrypted, which is right for passwords), apart from the legacy MD5 hashes of #426. The superuser password is not protected at all.

Why the superuser password matters

  • Anyone who gets a copy of hypha.php reads the password. Ways to get one: a backup, a .vorige or .bak copy in the web root, the builder of #413, a mistake in the web server configuration that serves PHP as text, or a container image or repository that contains the file.
  • People reuse passwords, so the password often opens other services as well.
  • The installer puts the posted value into PHP source without escaping. A ' in the password breaks hypha.php, and $1 or \1 in it is changed by preg_replace. Only someone already logged in to hypha.php can do this, but it turns a password field into PHP code.
  • === on a secret is not constant-time.

Options to improve

  1. Hash the superuser password. Store password_hash() output in hypha.php and check it with password_verify(). When $password is not a hash (an existing install), accept it once, then write the hash at that login, or ask for a new password. Write the value with var_export() instead of preg_replace, so no character can break the source. Effort: small. This option alone takes away most of the risk.
  2. Retire the legacy MD5 member hashes and rehash on login: #426 / PR #491.
  3. Use Argon2id where available. PASSWORD_ARGON2ID exists when PHP is built with libargon2 or libsodium (the official PHP images have it). Together with password_needs_rehash() (part of PR #491), hashes move over at the next login. Bcrypt with cost 12, the default from PHP 8.4, is also acceptable. This is a choice, not a must.
  4. Keep the hashes out of reach. Make sure data/ can never be downloaded (#427 / PR #494), and preferably support a data folder outside the web root. A hash that cannot be read cannot be attacked offline.
  5. Limit guessing of member and superuser passwords: #424 / PR #493 for members. hypha.php has no limit yet.
  6. Optional, larger: move the superuser credentials out of hypha.php into a file outside the web root, or into an environment variable (useful for containers). Or drop the separate superuser and let an administrator account of the site do maintenance.

Suggested order

Option 1 first: it is small, it closes the plain-text password, and it is not covered by any open issue. Then merge PR #491 and PR #494.

🤖 Generated with Claude Code

Ngôn ngữ chính
JavaScript
Star
5
Fork
9
Merge trung bình
18 giờ 49 phút
Pull request đã merge (30 ngày)
13

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 PlanBCode/hypha

Tất cả issue của PlanBCode/hypha

Issue tương tự

Thêm issue về JavaScript

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.