client-proxy: WARN "invalid host" spam from unroutable bare-IP Host requests (external probes)

Đang mở Phù hợp với người mới
#3,783 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@AdaAibaby đang làm issue này rồi.

Từ ngày 2/11/2026.

  • #3784 của @AdaAibaby — đang mở
  • #3785 của @AdaAibaby — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Thay đổi nằm trong nhánh ErrInvalidHost của handler() trong packages/shared/pkg/proxy/handler.go, nhánh này dùng isLocalRequestHost từ host.go và kiểm tra header định tuyến. Hãy đọc các hàm hỗ trợ đó trước, sau đó thêm unit test cho trường hợp Host chỉ là một IP, không có header E2b-Sandbox-Id/E2b-Sandbox-Port. Hoàn thành khi trường hợp này ghi log ở mức Debug, host tên miền sai định dạng vẫn ghi log ở mức Warn, và phản hồi 400 không thay đổi. Hãy xác nhận hướng tiếp cận với maintainer trước khi mở PR.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

client-proxy logs WARN "invalid host" for every inbound request whose Host is a bare IP address with no sandbox routing headers. On any proxy with a public endpoint these arrive continuously from external scanners, health probes, and stale clients still pointed at an old node IP, producing ~1 line/second of WARN noise that drowns real warnings.

Observed (client-proxy):

WARN  invalid host  {"service":"client-proxy","host":"118.196.30.209"}
WARN  invalid host  {"service":"client-proxy","host":"118.196.30.209"}
... (repeats every ~1s)
Why these are expected, not warnings

packages/shared/pkg/proxy/handler.go rejects the request with ErrInvalidHost and returns 400, which is correct. But a bare-IP Host cannot encode sandbox routing ({port}-{sandboxID}.{domain}) — as isLocalRequestHost in host.go documents, header-based routing is the only mechanism that can work for an IP host. So an IP Host that also carries no routing headers (E2b-Sandbox-Id / E2b-Sandbox-Port) is, by construction, unroutable. Rejecting it is the designed behavior; logging it at WARN on every hit just turns routine external traffic into log spam.

(Header-based routing for IP hosts — #2581 — is unaffected: an IP host with routing headers routes fine and never reaches this branch.)

Proposal

In the ErrInvalidHost branch of handler(), log at Debug when the host is a raw IP / localhost and no routing headers are present (isLocalRequestHost(r.Host) && !hasRoutingHeaders(r.Header)), and keep Warn for a genuinely suspect invalid host (a malformed domain host), which is rare and worth visibility. Status code stays 400 in both cases — this only changes log level, not behavior.

Environment

Reproduced on client-proxy main; the proxy sits behind a public ingress, so any internet host hitting the raw IP triggers it. Same code path in api (OpenAPI validator logs the same raw-IP / requests as 404 no matching operation), but the client-proxy WARN is the loudest.

Happy to send the PR (small, with a unit test) if the direction is acceptable.

Ngôn ngữ chính
Go
Star
1.8k
Fork
503
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của e2b-dev/runtime

Tất cả issue của e2b-dev/runtime

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.