Browse Source

清理新生产环境PHP攻击面

移除 vConsole 示例目录及上传目录中的 PHP 后缀文件,阻止示例源码继续暴露。
在内外网 Nginx 增加 PHP/PHTML/PHAR 全站拦截,并为 vConsole 示例路径增加永久 404 防护。
保留双节点文件与配置备份,恢复并校验发布器历史隔离文件,仅保留本次清理的 3 个 PHP 文件安全备份。

Validation:
- 双节点 PHP 程序、包、进程和 Nginx PHP 配置均为 0。
- 双节点 PHP/PHTML/PHAR 探针全部返回 404。
- 51/51 正式域名 HTTPS 首页最终返回 200。
- 内外网 nginx -t 通过并 graceful reload,未重启 MySQL、Redis、Tomcat。
- 文件发布器保持 active。
非繁 2 weeks ago
parent
commit
bd53c5fec8

+ 0 - 4
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/ajax.php

@@ -1,4 +0,0 @@
-<?php
-header('Content-Type: application/json; charset=utf-8');
-$data = array('msg' => '收到一个AJAX回包,可在[Network]中查看');
-echo json_encode($data);

+ 0 - 142
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/demo1.html

@@ -1,142 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <meta charset="utf-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
-  <title>vConsole/Demo1</title>
-  <link href="./lib/weui.min.css" rel="stylesheet"/>
-  <link href="./lib/demo.css" rel="stylesheet"/>
-
-  <script src="./lib/zepto.min.js"></script>
-  <script src="./lib/zepto.touch.min.js"></script>
-
-  <!-- 引入vConsole的JS库 -->
-  <script src="../dist/vconsole.min.js"></script>
-
-</head>
-<body ontouchstart>
-  <div class="page">
-    <h1 class="page_title">Demo 1</h1>
-    <div class="weui_text_area">
-      <p class="weui_msg_desc">点击下面的按钮,即可打印 log。<br/>点击右下角按钮,即可查看 log。</p>
-    </div>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log" data-type="log">普通日志(log)</a>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log" data-type="info">信息日志(info)</a>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log" data-type="debug">调试日志(debug)</a>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log" data-type="warn">警告日志(warn)</a>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log" data-type="error">报错日志(error)</a>
-
-    <a href="javascript:;" class="weui_btn weui_btn_default js_btn_log_obj">打印Object</a>
-    <a href="javascript:;" class="weui_btn weui_btn_default js_btn_trigger_error">触发JS Error</a>
-    <a href="javascript:;" class="weui_btn weui_btn_default js_btn_log_sys">打印到系统面板</a>
-    <a href="javascript:;" class="weui_btn weui_btn_default js_btn_ajax_get">发起AJAX(GET)</a>
-    <a href="javascript:;" class="weui_btn weui_btn_default js_btn_ajax_post">发起AJAX(POST)</a>
-
-    <a href="javascript:;" class="weui_btn weui_btn_default js_btn_clear">清除日志</a>
-    <a href="javascript:;" class="weui_btn weui_btn_warn js_btn_hideswitch">隐藏按钮</a>
-    <a href="javascript:;" class="weui_btn weui_btn_warn js_btn_destroy">销毁vConsole</a>
-  </div>
-  <div class="weui_toptips weui_notice" id="js_tips">已打印log</div>
-</body>
-
-<script>
-// 初始化vConsole
-window.vConsole = new window.VConsole({
-  defaultPlugins: ['system', 'network', 'element', 'storage'], // 可以在此设定要默认加载的面板
-  maxLogNumber: 1000,
-  // disableLogScrolling: true,
-  onReady: function() {
-    console.log('vConsole is ready.');
-  },
-  onClearLog: function() {
-    console.log('on clearLog');
-  }
-});
-
-console.info('欢迎使用 vConsole。vConsole 是一个由微信公众平台前端团队研发的 Web 前端开发者面板,可用于展示 console 日志,方便开发、调试。');
-
-$('.js_btn_log').on('tap', function(e) {
-  var type = $(this).data('type');
-  console[type](type); // 例如,console.log(type)
-  showTips();
-});
-$('.js_btn_log_obj').on('tap', function(e) {
-  var obj = {
-    'foo': 'bar',
-    'obj': {'bool': true},
-    'arr': [9, 8, 7],
-    'tips': 'JS对象可以折叠展示'
-  };
-  console.log(obj);
-  showTips();
-});
-$('.js_btn_trigger_error').on('tap', function(e) {
-  showTips();
-  var err = undefined;
-  err.a = 1;
-});
-$('.js_btn_log_sys').on('tap', function(e) {
-  // 输出到系统面板
-  console.log('[system]', '当前时间戳:', (+new Date()));
-  showTips();
-});
-$('.js_btn_ajax_get').on('tap', function(e) {
-  // 发起一个AJAX
-  $.get('ajax.php',  { id: Math.random(), action: 'Get' }, function(resp) {
-    console.log(resp);
-  });
-  showTips();
-});
-$('.js_btn_ajax_post').on('tap', function(e) {
-  // 发起一个AJAX
-  $.post('ajax.php',  { id: Math.random(), action: 'Post' }, function(resp) {
-    console.log(resp);
-  });
-  showTips();
-});
-$('.js_btn_clear').on('tap', function(e) {
-  console.clear();
-});
-$('.js_btn_hideswitch').on('tap', function(e) {
-  var that = this;
-  if ($(this).hasClass('weui_btn_disabled')) {
-    return false;
-  }
-  $(this).addClass('weui_btn_disabled');
-  window.vConsole.hideSwitch();
-  var count = 6;
-  var cb = function() {
-    count--;
-    if (count == 0) {
-      window.vConsole.showSwitch();
-      $(that).removeClass('weui_btn_disabled');
-      $(that).html('隐藏按钮');
-      clearInterval(timer);
-      return;
-    }
-    $(that).html('隐藏按钮(' + count + ')');
-  }
-  cb();
-  var timer = setInterval(cb, 1000);
-});
-$('.js_btn_destroy').on('tap', function(e) {
-  if ($(this).hasClass('weui_btn_disabled')) {
-    return false;
-  }
-  $('.weui_btn').addClass('weui_btn_disabled');
-  window.vConsole.destroy();
-  $(this).html('刷新页面以重载vConsole');
-});
-
-// 用于页面内展示顶部tips
-var tipsTimer;
-function showTips() {
-  tipsTimer && clearTimeout(tipsTimer);
-  $('#js_tips').show();
-  tipsTimer = setTimeout(function() {
-    $('#js_tips').hide();
-  }, 1500);
-}
-
-</script>
-</html>

+ 0 - 55
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/demo2.php

@@ -1,55 +0,0 @@
-<?php
-// 这个demo示例如何通过PHP动态加载vConsole
-// (1)访问 demo2.php 时(一般情况),不加载vConsole
-// (2)访问 demo2.php?dev_mode=1 时(调试模式),加载vConsole
-
-$dev_mode = isset($_GET['dev_mode']) ? $_GET['dev_mode'] : '0';
-?><!DOCTYPE html>
-<html>
-<head>
-  <meta charset="utf-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
-  <title>vConsole/Demo2</title>
-  <link href="./lib/weui.min.css" rel="stylesheet"/>
-  <link href="./lib/demo.css" rel="stylesheet"/>
-  
-  <script src="./lib/zepto.min.js"></script>
-  <script src="./lib/zepto.touch.min.js"></script>
-
-  <?php if ($dev_mode == '1') { ?>
-    <!-- 引入vConsole的JS库 -->
-    <script src="../dist/vconsole.min.js"></script>
-    <script>
-      // 初始化vConsole
-      window.vConsole = new window.VConsole();
-    </script>
-  <?php } ?>
-</head>
-
-<body ontouchstart>
-  <div class="page">
-    <h1 class="page_title">Demo 2</h1>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log">Hello World</a>
-  </div>
-  <div class="weui_toptips weui_notice" id="js_tips">已打印log</div>
-</body>
-
-<script>
-$('.js_btn_log').on('tap', function(e) {
-  // 打印log时无须判断是否为dev_mode,
-  // 未加载vConsole时,console.log()不会显示到前台
-  console.log('Hello World');
-  showTips();
-});
-
-// 用于页面内展示顶部tips
-var tipsTimer;
-function showTips() {
-  tipsTimer && clearTimeout(tipsTimer);
-  $('#js_tips').show();
-  tipsTimer = setTimeout(function() {
-    $('#js_tips').hide();
-  }, 1500);
-}
-</script>
-</html>

+ 0 - 51
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/demo3.php

@@ -1,51 +0,0 @@
-<?php
-// 这个demo用于测试CSP的规则
-$nonce = rand(10000, 99999);
-header("Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval' 'nonce-" . $nonce . "';");
-?><!DOCTYPE html>
-<html>
-<head>
-  <meta charset="utf-8">
-  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
-  <title>vConsole/Demo3</title>
-  <link href="./lib/weui.min.css" rel="stylesheet"/>
-  <link href="./lib/demo.css" rel="stylesheet"/>
-  
-  <!-- <script src="./lib/zepto.min.js" nonce="<?php echo $nonce; ?>"></script>
-  <script src="./lib/zepto.touch.min.js" nonce="<?php echo $nonce; ?>"></script> -->
-
-  <!-- 引入vConsole的JS库 -->
-  <script src="../dist/vconsole.min.js" nonce="<?php echo $nonce; ?>"></script>
-  <script nonce="<?php echo $nonce; ?>">
-    // 初始化vConsole
-    window.vConsole = new window.VConsole();
-  </script>
-</head>
-
-<body>
-  <div class="page">
-    <h1 class="page_title">Demo 3</h1>
-    <a href="javascript:;" class="weui_btn weui_btn_primary js_btn_log">Hello World</a>
-  </div>
-  <div class="weui_toptips weui_notice" id="js_tips">已打印log</div>
-</body>
-
-<script nonce="<?php echo $nonce; ?>">
-$('.js_btn_log').on('tap', function(e) {
-  // 打印log时无须判断是否为dev_mode,
-  // 未加载vConsole时,console.log()不会显示到前台
-  console.log('Hello World');
-  showTips();
-});
-
-// 用于页面内展示顶部tips
-var tipsTimer;
-function showTips() {
-  tipsTimer && clearTimeout(tipsTimer);
-  $('#js_tips').show();
-  tipsTimer = setTimeout(function() {
-    $('#js_tips').hide();
-  }, 1500);
-}
-</script>
-</html>

+ 0 - 39
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/lib/demo.css

@@ -1,39 +0,0 @@
-html, body {
-  height: 100%;
-}
-.page {
-  padding: 25px 15px 60px;
-  height: 100%;
-  background-color: #fbf9fe;
-  -webkit-tap-highlight-color: transparent;
-}
-.page_title {
-  color: #225fba;
-  text-align: center;
-  font-size: 34px;
-  font-weight: 400;
-  margin: 0 15%;
-}
-
-.weui_toptips.weui_notice {
-  background-color: #FFBE00;
-}
-
-.weui_text_area {
-  margin: 15px 0 25px;
-  padding: 0 20px;
-  text-align: center;
-}
-.weui_msg_desc {
-  font-size: 14px;
-  color: #888;
-}
-
-.weui_extra_area {
-  margin-bottom: 15px;
-  font-size: 14px;
-  color: #888;
-}
-.weui_extra_area a {
-  color: #61749B;
-}

File diff suppressed because it is too large
+ 0 - 4
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/lib/weui.min.css


File diff suppressed because it is too large
+ 0 - 1
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/lib/zepto.min.js


File diff suppressed because it is too large
+ 0 - 3
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/lib/zepto.touch.min.js


BIN
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/snapshot/log_panel.png


BIN
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/snapshot/qq_group.png


BIN
WebRoot/apps/space/plug-in/vConsole-3.3.4/example/snapshot/qrcode.png


+ 16 - 4
local-run/anti-tamper/runtime-config/nginx-default.conf

@@ -31,8 +31,18 @@ server {
         return 404;
     }
 
+    # No PHP runtime exists in this stack. Deny PHP-family files globally as defense in depth.
+    location ~* \.(php|phtml|phar)$ {
+        return 404;
+    }
+
+    # vConsole sample pages are not application assets and must never be public.
+    location ^~ /apps/space/plug-in/vConsole-3.3.4/example/ {
+        return 404;
+    }
+
     location ^~ /web/upload/modules/sys/improt/ {
-        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|sh)$") { return 404; }
+        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|phar|sh)$") { return 404; }
         if ($uri ~ "/\.zq-(quarantine|stage)") { return 404; }
         proxy_pass http://10.0.42.6:8080;
         proxy_set_header Host $host;
@@ -47,7 +57,7 @@ server {
     }
 
     location ^~ /web/upload/modules/sys/upload/ {
-        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|sh)$") { return 404; }
+        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|phar|sh)$") { return 404; }
         if ($uri ~ "/\.zq-(quarantine|stage)") { return 404; }
         proxy_pass http://10.0.42.6:8080;
         proxy_set_header Host $host;
@@ -62,7 +72,7 @@ server {
     }
 
     location ^~ /web/upload/ {
-        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|sh)$") { return 404; }
+        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|phar|sh)$") { return 404; }
         if ($uri ~ "/\.zq-(quarantine|stage)") { return 404; }
         proxy_pass http://zq-tomcat-external:8080;
         proxy_set_header Host $host;
@@ -77,7 +87,7 @@ server {
     }
 
     location ^~ /main/ {
-        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|sh)$") { return 404; }
+        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|phar|sh)$") { return 404; }
         if ($uri ~ "/\.zq-(quarantine|stage)") { return 404; }
         root /srv/zq-webapp;
         try_files $uri =404;
@@ -97,6 +107,7 @@ server {
     }
 
     location ^~ /app/ {
+        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|phar|sh)$") { return 404; }
         proxy_pass http://10.0.42.6:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
@@ -127,6 +138,7 @@ server {
     }
 
     location ^~ /apps/ {
+        if ($uri ~* "\.(jsp|jspx|class|war|php|phtml|phar|sh)$") { return 404; }
         proxy_pass http://10.0.42.6:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;

+ 10 - 0
local-run/anti-tamper/runtime-config/nginx-default.internal.conf

@@ -31,6 +31,16 @@ server {
         return 404;
     }
 
+    # No PHP runtime exists in this stack. Deny PHP-family files globally as defense in depth.
+    location ~* \.(php|phtml|phar)$ {
+        return 404;
+    }
+
+    # vConsole sample pages are not application assets and must never be public.
+    location ^~ /apps/space/plug-in/vConsole-3.3.4/example/ {
+        return 404;
+    }
+
     location = /apps/workbench {
         return 302 /apps/workbench/;
     }

+ 106 - 0
local-run/reports/security-php-cleanup-20261113/README.md

@@ -0,0 +1,106 @@
+# 华夏正式生产环境 PHP 攻击面清理报告
+
+- 执行日期:2026-11-13
+- 环境:华夏正式生产环境
+- 外网节点:`10.0.42.5`
+- 内网节点:`10.0.42.6`
+- 范围:仅处理新生产环境,不处理旧生产系统
+
+## 1. 漏洞结论
+
+旧漏洞材料列出的风险是 PHP 8.x 运行时漏洞。华夏正式生产环境不存在 PHP 运行时:
+
+- 两个节点均无 `php`、`php-fpm` 程序;
+- 无相关系统包和进程;
+- 无 PHP Docker 镜像;
+- Nginx 无 `fastcgi_pass`、`php-fpm`、`mod_php` 配置;
+- `.php` 请求在新双节点均返回 `404`;
+- 实际运行栈为 Nginx 1.26 + Tomcat 8.5/JDK 8 + MySQL 5.7 + Redis 7。
+
+因此,该 PHP 运行时漏洞在新生产环境不存在。
+
+## 2. 清理内容
+
+### 2.1 vConsole 示例目录
+
+已从本地仓库和生产双节点移除:
+
+`WebRoot/apps/space/plug-in/vConsole-3.3.4/example/`
+
+涉及 11 个文件,包括 3 个会暴露 PHP 源码的示例文件:
+
+- `demo2.php`
+- `demo3.php`
+- `ajax.php`
+
+Nginx 同时增加永久防护:
+
+`location ^~ /apps/space/plug-in/vConsole-3.3.4/example/ { return 404; }`
+
+即使未来部署包误带回该目录,公网仍返回 `404`。
+
+### 2.2 上传目录中的 PHP 后缀文件
+
+已从内网权威 webroot 删除,并由发布器同步删除外网文件:
+
+- `web/upload/articles/files/HUfwstpKPQae.php`
+- `web/upload/articles/files/N6ThEvL82klw.php`
+- `web/upload/articles/files/SKhm7KXbzJxj.php`
+
+这 3 个文件实际内容是旧 HTML 页面,不是 PHP 程序;数据库中也没有文章或附件引用它们。
+
+外网发布器按设计将删除记录放入 `.zq-quarantine`,随后已将本次 3 个文件移出 webroot,保存到独立安全备份。
+
+### 2.3 Nginx 防御
+
+外网和内网配置均增加 PHP 家族文件全站拦截:
+
+`location ~* \.(php|phtml|phar)$ { return 404; }`
+
+上传目录原有脚本拦截规则补充 `phar`,现覆盖:
+
+`jsp|jspx|class|war|php|phtml|phar|sh`
+
+## 3. 验证结果
+
+- 外网 `10.0.42.5`:PHP 后缀文件数 `0`
+- 内网 `10.0.42.6`:PHP 后缀文件数 `0`
+- 双节点 `php/php-fpm` 程序、包、进程、Nginx PHP 配置:均为 `0`
+- 双节点 `.php/.phtml/.phar` 探针:全部 `404`
+- 51 个正式域名最终 HTTPS 首页回归:`51/51` 返回 `200`
+- 主站、新闻网、`dd.gzhxtc.edu.cn`、后台工作台均正常
+- `nginx -t` 双节点通过,Nginx 使用 graceful reload
+- 未重启 MySQL、Redis 或 Tomcat
+- 文件发布器保持 `active`
+
+## 4. 备份与回滚
+
+内网备份:
+
+`/home/hxxy/zq/backups/security-php-cleanup-20261113/internal/`
+
+外网备份:
+
+`/home/hxxy/zq/backups/security-php-cleanup-20261113/external/`
+
+备份包含:
+
+- vConsole `example` 原始 11 个文件;
+- 3 个上传目录 PHP 后缀文件;
+- 清理前的内外网 Nginx 配置;
+- 文件 SHA-256 清单。
+
+## 5. 隔离区完整性
+
+清理上传文件时,发布器会生成 `.zq-quarantine`。为确认历史隔离数据不丢失:
+
+- 已逐文件核对并恢复历史隔离文件 `11,668` 个;
+- 恢复后 SHA-256 全部一致;
+- 仅将本次明确清理的 3 个 PHP 后缀文件移至独立安全备份;
+- 隔离区访问路径仍受 Nginx `.zq-quarantine/.zq-stage` 404 规则保护。
+
+## 6. 代码与配置
+
+- `local-run/anti-tamper/runtime-config/nginx-default.conf`
+- `local-run/anti-tamper/runtime-config/nginx-default.internal.conf`
+- 删除 `WebRoot/apps/space/plug-in/vConsole-3.3.4/example/`

+ 43 - 0
local-run/reports/security-php-cleanup-20261113/verification.json

@@ -0,0 +1,43 @@
+{
+  "checked_at": "2026-11-13T10:55:00+08:00",
+  "environment": "华夏正式生产环境",
+  "nodes": ["10.0.42.5", "10.0.42.6"],
+  "php_runtime": {
+    "binaries": 0,
+    "packages": 0,
+    "processes": 0,
+    "nginx_php_configs": 0,
+    "docker_php_images": 0
+  },
+  "php_family_files_after_cleanup": {
+    "10.0.42.5": 0,
+    "10.0.42.6": 0
+  },
+  "php_probe_status": {
+    ".php": 404,
+    ".phtml": 404,
+    ".phar": 404
+  },
+  "site_regression": {
+    "checked": 51,
+    "http_200": 51,
+    "failed": 0
+  },
+  "nginx": {
+    "syntax_check": "passed",
+    "reload": "graceful",
+    "external_config_sha256": "68adee5c5327c39deb2981883519846d61a5d9aa4a5d48ce7eb8a6a884880d09",
+    "internal_config_sha256": "eff38ac8e35ef7df3a7956a7204135e259890ce9db4ba8008b70c85d867cc702"
+  },
+  "historical_quarantine": {
+    "restored_files": 11668,
+    "sha256_mismatch": 0,
+    "retained_security_backup_files": 3
+  },
+  "services": {
+    "mysql_restarted": false,
+    "redis_restarted": false,
+    "tomcat_restarted": false,
+    "artifact_publisher": "active"
+  }
+}

Some files were not shown because too many files changed in this diff