Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] Security Bug: Switching PHP Versions Causes Protected Directory to Download PHP Source Code

未关闭
#14,234 2 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@wanghe-fit2cloud 已经在做这个了。

开始于 2026年10月28日。

评估

这个 Issue 还没有评估数据。

描述

Contact Information

No response

1Panel Version

2.4.1

Problem Description

A potential security vulnerability in 1Panel allows PHP source code to be downloaded when accessing a directory protected by Basic Authentication after switching the website's PHP runtime version.

The issue is consistently reproducible in a freshly installed 1Panel virtual machine. After switching the PHP version, accessing the password-protected directory causes the browser to download the actual PHP source code instead of executing it.

The downloaded file contains the complete, current source code, including comments. Modifying index.php on the server changes the downloaded content accordingly.

This may expose sensitive application source code and credentials.

Environment

  • 1Panel: Fresh installation in a virtual machine
  • Initial PHP runtime: PHP 8.5.12
  • Target PHP runtimes tested: PHP 7.0 and PHP 8.3
  • Web server: OpenResty 1.31.1.1-2-4-noble
  • Authentication method: Basic Authentication (password protection for a directory)

Actual Behavior

Instead of executing PHP scripts, the browser downloads a PHP source file.

When accessing the directory directly, the downloaded file contains the PHP entry-point code. When explicitly accessing index.php, the browser downloads the website's actual index.php file.

The downloaded source code is complete and up to date. If the contents of index.php are modified on the server, the downloaded file reflects those changes, including comments.

Restarting the server does not resolve the issue.

The problem has been reproduced with both PHP 7.0 and PHP 8.3 after switching from PHP 8.5.

Disabling the browser cache makes the website accessible again, but the underlying cause of the source-code exposure remains unclear.

Expected Behavior

Switching the website's PHP runtime version should not affect Basic Authentication or PHP request handling.

PHP files in password-protected directories should always be processed by PHP-FPM and should never be served as downloadable source code.

Security Impact

This behavior may expose the complete PHP source code of a website to unauthorized users, potentially including database credentials, API tokens, authentication logic, and other sensitive information.

Because the issue is reproducible after switching PHP versions and persists across server restarts, it should be investigated as a potential high-severity security vulnerability.

Additional Notes

  • The issue is reproducible on a freshly installed 1Panel virtual machine.
  • The password protection works correctly before switching PHP versions.
  • Removing the Basic Authentication configuration afterward does not immediately resolve the issue in the affected browser.
  • The issue has been reproduced with PHP 7.0 and PHP 8.3; other target PHP versions have not yet been tested.

Please investigate whether switching PHP runtime versions causes incorrect configuration generation or location matching for directories protected by Basic Authentication, resulting in PHP files being served as static files.

Steps to Reproduce
  1. Install 1Panel in a virtual machine.
  2. Install the PHP 8.5 runtime environment.
  3. Create a website and configure it to use PHP 8.5.
  4. Configure Basic Authentication to protect a specific directory of the website (eg: /test/).
  5. Access the protected directory and verify that the password prompt appears and authentication works correctly.
  6. Switch the website's PHP runtime from PHP 8.5 to PHP 7.0 or PHP 8.3.
  7. Access the same password-protected directory again.
The expected correct result

No response

Related log output

Additional Information

No response

主要语言
Go
星标
37.3k
派生
3.4k
平均合并
9 小时 52 分钟
30 天内合并 PR
99

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

1Panel-dev/1Panel 的其他 Issue

查看 1Panel-dev/1Panel 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。