Commit Graph
25 Commits
Author SHA1 Message Date
qing fd088f5959 fix(waf): 对 /add_note 接口豁免 CRS 误报规则
嵌入式/技术笔记含 C 代码(if()/select/sbit)被 SQLi/命令注入规则误判拦截。
仅移除误报规则(942170/942230/932xxx/934xxx),其余 CRS 规则及接口仍生效。
2026-08-04 21:32:14 +08:00
qing 6a68b3393d docs(waf): _fetch_crs.sh 生成的 coraza.conf 模板指向 tuning.conf
避免重跑脚本覆盖调优配置,模板不再包含重复的阈值/偏执规则
2026-08-04 21:11:26 +08:00
qing d036af935f feat(waf): 启用 OWASP CRS 异常评分制自动拦截
- SecRuleEngine On 自动拦截异常评分达阈值的请求(规则 949110)
- 新增 rules/local/tuning.conf 调优文件(偏执等级 1 + 阈值 5/4)
- tuning.conf 独立于自动生成的 crs/coraza.conf,重跑 fetch 不覆盖
2026-08-04 20:40:25 +08:00
qing a7a78d1424 docs: aggregate project documentation under docs/ with unified index
- Move all per-module security audit reports to docs/security/
- Move code review logs to docs/reviews/, analysis reports to docs/reports/
- Add docs/INDEX.md as single entry point for all project documentation
- Add documentation management conventions section to README.md
- Clean up empty per-module docs/ directories
2026-08-03 13:21:48 +08:00
qing 81ae84851d feat(waf): add WebSocket proxy support and fix HTTP/2 proto version
- Implement http.Hijacker on responseRecorder to enable WebSocket upgrade
  (delegates Hijack() to underlying ResponseWriter, marks hijacked state)
- After WebSocket upgrade (101 Switching Protocols), skip HTTP response-phase
  WAF checks since connection becomes a binary frame stream
- Log WebSocket upgrades at Info level for observability
- Fix P2-3: use r.Proto instead of hardcoded "HTTP/1.1" in ProcessResponseHeaders
  for correct HTTP/2 protocol version reporting
- Add Write() method to responseRecorder to ensure WriteHeader is called
  before first Write (complies with http.ResponseWriter contract)
- Add bufio/net imports required by Hijacker interface
- Update README with WebSocket support section and v1.2 changelog
- Update SECURITY_AUDIT to mark P2-3 and P2-4 as fixed
2026-08-01 04:18:30 +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 267d572906 fix(pymsg): 修复消息长度无上限导致 OOM DoS 漏洞
Python/Go 端 recv 缺失消息大小上限检查,恶意客户端发送 4 字节
超大长度头即可触发 OOM。新增 64 MiB 上限(与 C++ 端 Msg.hpp
对齐),在分配内存前拒绝并断开连接。新增 5 个单元测试覆盖。
2026-08-01 01:55:44 +08:00
qing dcfdbcb9f2 docs(waf): 更新 README 文档与代码实现对齐
- 新增「安全响应头」章节,列出 7 个 WAF 注入的响应头及说明
- 修正「已知限制」中响应体检测描述,明确响应头检测已启用
- 澄清拦截日志等级区分(WARNING 命中拦截 / ERROR 加载错误)及 extra 字段类型
- 补充规则 ID 分段表的 CRS 可选说明
- 更新目录结构列表补充 logclient 子包
- 请求处理流程新增 ModifyResponse 步骤
2026-07-30 11:49:10 +08:00
qing 91e6659dac docs(waf): 拦截日志章节更新为 logclient 推送 db Logs 表的说明 2026-07-30 11:01:34 +08:00
qing 751866d9c1 refix 2026-07-29 11:52:46 +08:00
qing 7803843155 ^-^ 2026-07-28 12:37:39 +08:00
qing 50f209e84a fix: X-Frame-Options/frame-ancestors 改为同源以修复条例弹窗空白 2026-07-28 11:53:35 +08:00
qing a5e581ef24 fix: CSP img-src 放行 blob:,修复验证码图片被拦截
登录页验证码用 URL.createObjectURL 生成的 blob: URL 显示,被 img-src 'self' data: 拦截导致图片无法加载;五处 CSP 定义(waf 边缘 + 四个 Flask 中间件副本)同步放宽。
2026-07-28 10:19:47 +08:00
qing b2ddd9e7e3 security: waf 边缘统一注入安全响应头
外部扫描发现站点缺少安全响应头。在 waf 反代/403/502 三个出站路径统一注入 XFO/nosniff/Referrer-Policy/Permissions-Policy/HSTS/CSP,下游同名头一律覆盖避免重复;static 补上漏调用的 apply_security_headers 做纵深防御。
2026-07-28 09:19:43 +08:00
qing 08021015b1 更新msg客户端 2026-07-27 09:21:06 +08:00
qing 49c0dca8cf waf log >> db.logs 2026-07-25 21:54:30 +08:00
qing b5c1be1b90 修改文档 2026-07-25 20:42:30 +08:00
qing 15a4bac484 waf规则文件拉取脚本 2026-07-25 11:22:51 +08:00
qing a9e50bb598 修 proxy.go 里 Director 的 X-Forwarded-For 带端口号问题。ServeHTTP 里已经有剥离端口的逻辑,Director 里复用同样的处理就行。 2026-07-25 10:21:51 +08:00
qing c5fc6f1076 fix up waf and gateway 2026-07-25 01:54:43 +08:00
qing 27c1021ad2 降级goy 2026-07-25 01:41:35 +08:00
qing b66c267268 keep fix 2026-07-25 01:38:42 +08:00
qing 76e3a06c97 fixx but can't connect 2026-07-25 01:36:15 +08:00
qing 7df0d51879 set proxy 2026-07-25 01:33:13 +08:00
qing 202f2804b2 增加waf模块 2026-07-25 01:27:08 +08:00