Commit Graph
7 Commits
Author SHA1 Message Date
qing 2832566e87 waf 同端口明文 HTTP 请求 301 重定向到 HTTPS
按连接首字节分发 TLS(0x16)与明文连接:明文走独立 handler
301 跳转 https 同路径(保留路径/查询串),替代被停用的
redirect80 的入口重定向职责;证书改为显式 LoadX509KeyPair
注入 TLSConfig。
2026-08-27 14:31:30 +00:00
qing 01c6d0cb1f waf: CLI 标准化(--log-level/--instance + config.yaml 字段全 CLI 覆盖)
- 新增 --listen/--host (覆盖 listen)、--upstream、--tls-cert、--tls-key、--rules-dir
- 新增 --log-level debug|info|warn|error(logclient 加级别过滤)
- 新增 --instance 实例名(注册中心用)
- 自定义 --help 用法文本
- logclient: 新增 SetLevel() + Debug() + ENV LOG_LEVEL 支持
- services.yaml: waf 声明 --instance 和 --log-level
2026-08-10 11:38:08 +08:00
qing 00ce3eac6a fix(waf): 修复P3安全审计缺陷
P3-1: logclient 复用 TCP 长连接,失败时重建,消除 TIME_WAIT 堆积
P3-2: TLS 显式限定 CipherSuites + CurvePreferences,排除弱加密套件
P3-3: CheckInput query 编码改用 url.Parse + Query().Encode()

修复率 76% -> 94%(P3 全部清零,仅剩 P0-3 为设计依赖)
2026-08-08 02:39:22 +08:00
qing dd9f8e51ff fix(waf): 修复P1/P2安全审计缺陷
P1-1: IPv6 地址解析改用 net.SplitHostPort,修复 XFF 带方括号致限流失效
P1-2: 捕获 ProcessResponseHeaders 返回值,命中记录 WARNING 告警
P1-4: 新增 SIGINT/SIGTERM 优雅关闭 + logclient.Flush()
P1-5: 标准日志输出到 stderr,保留 panic 堆栈
P2-1: 规则文件加载前校验大小(1 MiB 上限)防 OOM
P2-2: logclient db 地址支持 LOG_DB_ADDR 环境变量
P2-5: 日志失败输出到 stderr 而非 stdout

修复率 35% -> 76%(P1/P2 全部清零)
2026-08-08 02:36:22 +08:00
qing b4436b192a fix(waf): harden against OOM and Slowloris DoS attacks
- P0: add 10MB hard request body size limit with io.LimitReader,
  return 413 Request Entity Too Large when exceeded, prevents OOM
- P0: configure http.Server timeouts: ReadHeaderTimeout=10s (Slowloris),
  ReadTimeout=15s, WriteTimeout=30s, IdleTimeout=120s, MaxHeaderBytes=1MB
- P1: properly handle body read errors, log and return on client disconnect
- P2: drain and close r.Body in defer to ensure TCP connection reuse
- Log errors from ReadRequestBodyFrom and ProcessRequestBody
- Inject security headers on 413 responses
- Add security audit report (docs/SECURITY_AUDIT_20260801.md)
- Update README with timeout/body-limit docs and changelog
2026-08-01 04:13:39 +08:00
qing 49c0dca8cf waf log >> db.logs 2026-07-25 21:54:30 +08:00
qing 202f2804b2 增加waf模块 2026-07-25 01:27:08 +08:00