e5e2582743
收紧 PUBLIC 路径误匹配、强制 health/detail 与壁纸 sync 鉴权、默认关闭 OpenAPI; 安装锁定后 /api/install/* 统一 404;附探测脚本、测试与审计文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
1.3 KiB
1.3 KiB
Changelog — 外网攻击面加固(BL-01~BL-04)
日期:2026-06-06
摘要
修复外网巡检发现的 P2/H 问题:收紧 PUBLIC_PREFIXES 前缀误匹配、强制 /health/detail 与壁纸 sync 鉴权、生产默认关闭 OpenAPI/Swagger/ReDoc。
动机
生产探测 EXT-01/02/03:/health/detail 与 bing-wallpapers/sync 无 JWT 可访问;全量 API schema 公网暴露。
涉及文件
| 文件 | 变更 |
|---|---|
server/api/auth_jwt.py |
精确路径 + 方法感知 _is_public_path;require_current_admin |
server/api/health.py |
health_detail 使用 require_current_admin |
server/api/settings.py |
bing_wallpapers_sync 使用 require_current_admin |
server/config.py |
EXPOSE_API_DOCS(默认 false) |
server/main.py |
docs_url/redoc_url/openapi_url 按配置关闭 |
tests/test_external_attack_surface_hardening.py |
回归测试 |
配置
# 仅本地开发需要时开启
NEXUS_EXPOSE_API_DOCS=true
迁移 / 重启
需重启 API 进程。无 DB 迁移。
验证
pytest tests/test_external_attack_surface_hardening.py -q
NEXUS_PROBE_BASE=https://api.synaglobal.vip bash scripts/security_probe_external.sh
# 部署后期望:health/detail 401;bing sync 401;openapi 404