CodeQL flags r.Host reaching slog in the forward proxy's debug/warn lines
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 70/100
Hướng nghiên cứu
Start in core/listener/forwardproxy/server.go and inspect the listed slog call sites around lines 546, 739, 742, 820, 848, 2045, 2049, 2099, 2163, 2261 and 2340. Add a sanitizedHost(r) helper that removes newlines and carriage returns from r.Host, then use it at each logging site. Run the forwardproxy package tests, e.g. go test ./core/listener/forwardproxy, and confirm every flagged call now logs the sanitized host.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
CodeQL (go/log-injection, medium) flags r.Host reaching slog.* calls in core/listener/forwardproxy/server.go. The alert surfaced on #1599 (alert #323) but the flagged flow is pre-existing — the PR's changes shifted line numbers; the vulnerable statements are unchanged.
Call sites on main where r.Host is passed as a log attribute without sanitization:
core/listener/forwardproxy/server.go:546(buffered request body):739(client went away before the upstream answered):742(upstream request failed):820(text/event-stream responses will use the buffered path):848(text/event-stream response with a ReadsBody plugin that is not a StreamingResponder):2045(response body read error):2049(response body too large):2099(streaming response ended by client hangup):2163(ResponseWriter does not support flushing):2261(streaming write error):2340(streaming write error)
r.Host on an HTTP request is set from the Host header (or request-line authority for CONNECT), so a client can embed newlines or other control characters and inject forged log lines.
Status
CodeQL only reports flows that pass through PR-changed lines, so these alerts fire sporadically — any PR that edits code on a path to one of these log sites will raise them again. Same mechanic as #1533, different source and sink.
Fix
Either:
- Sanitize at the source — a
sanitizedHost(r)helper that strips\n/\rfromr.Host, used at every log site. CodeQL recognisesstrings.ReplaceAllas a log-injection sanitizer (per #1533). - Add a path-scoped
query-filtersentry in.github/codeql/codeql-config.ymlwith a written reason, if the maintainers judge the sites low-risk enough to suppress.
Option 1 is the honest fix and keeps the alerts from recurring.
Found while reviewing CodeQL alert #323 on #1599.
- Ngôn ngữ chính
- Go
- Star
- 21
- Fork
- 43
- Merge trung bình
- 13 giờ 32 phút
- Pull request đã merge (30 ngày)
- 256
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rossoctl/cortex
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
UI shows costs for all sessions even when drilled into a sessionCó thể đã có người làm @esnible đã nhận 18 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
rossoctl/cortex#1116 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 Hơn một tuần Mức phù hợp với người mới 18/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Cost/session layering: ledger snapshot logic in the HTTP layer; import edges point both waysĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rossoctl/cortex
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 2 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
kagent-dev/kagent#3462 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
netrc credential source accepts a password with an embedded CR/LF that every other source rejectsĐang mởagent-butler-finding bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jordansmall/spindrift#6268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 7 ngày