otel: redact sensitive query parameters before recording http.url
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/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
- observability, security
Hướng nghiên cứu
Start with otel/transport.go and the existing URL tests in otel/transport_test.go, then read sensitiveParams and sanitizeURL in github/github.go. Add coverage for query credentials and URL userinfo, ensuring the URL recorded in http.url is redacted without changing the request URL sent by the transport. Done means the span no longer exposes those secrets and the existing query free URL behavior remains covered.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The OpenTelemetry transport records the full request URL, including query string and userinfo, in the http.url span attribute. go-github already treats certain query parameters as sensitive and redacts them on error paths, but the OTel instrumentation bypasses that redaction, so those values are exported to tracing/APM backends.
Location
otel/transport.go:61-66(attribute set)github/github.go:1964(sensitiveParams)github/github.go:1966-1984(sanitizeURL)
At HEAD (2190e6a):
// Inject Attributes
span.SetAttributes(
attribute.String("http.method", req.Method),
attribute.String("http.url", req.URL.String()),
attribute.String("http.host", req.URL.Host),
)
Details
req.URL.String() is the raw request URL. For requests that carry credentials in the query string, or that include userinfo, the resulting span attribute contains the secret verbatim:
http.url = https://api.github.com/user/repos?access_token=ghp_abc123&page=1
http.url = https://user:[email protected]/user
The github package already classifies exactly these parameters as sensitive:
var sensitiveParams = []string{"client_secret", "access_token", "token"}
// sanitizeURL redacts sensitive parameters from the URL which may be
// exposed to the user.
func sanitizeURL(uri *url.URL) *url.URL {
...
for _, p := range sensitiveParams {
if len(params.Get(p)) > 0 {
params.Set(p, "REDACTED")
redacted = true
}
}
...
}
That helper is applied at github/github.go:1482, 1777, 1849, 1907, 1948 and 1949, i.e. only in error and redirect handling. The OTel transport is a separate package and never applies it. Note also that sanitizeURL handles query parameters only; it does not strip url.User, which URL.String() renders as user:password@host.
otel/transport_test.go asserts http.url for a query-free URL (https://api.github.com/users/google), so nothing currently guards this behavior.
Impact
Any application that wraps the go-github client with otel.NewTransport and calls endpoints that pass credentials via query parameters (for example OAuth token exchange with client_secret, or legacy calls passing access_token) writes those secrets into every span attribute set. Span attributes are typically exported to a tracing backend, sampled into logs, and retained for days, which turns a short-lived token into a long-lived copy in a third-party system. It also defeats the existing redaction guarantee, since the same URL appears redacted in an error message and unredacted in the span for the same request.
Signed URL parameters (for example pre-signed download links returned by some endpoints and then re-requested) are likewise recorded in full.
Suggested fix
Reuse one shared sanitation helper instead of duplicating the parameter list:
- Export a helper from the
githubpackage (for examplegithub.SanitizeURLor a smallgithub.RedactURLreturning a string) that appliessensitiveParamsand, ideally, also clearsurl.User. Have the existingsanitizeURLand the OTel transport both call it. - In
otel/transport.go, record the sanitized value, or record only scheme, host and path:
u := *req.URL
u.User = nil
u.RawQuery = "" // or apply the shared redaction helper
span.SetAttributes(
attribute.String("http.method", req.Method),
attribute.String("http.url", u.String()),
attribute.String("http.host", req.URL.Host),
)
Note that simply calling the existing sanitizeURL is not safe from otel: it mutates uri.RawQuery in place (see the open issue about this mutation), which would rewrite the request URL that is actually sent. Copy the URL first, or fix the mutation separately.
Also worth considering url.full from the current OpenTelemetry semantic conventions, which supersedes http.url, and documenting that recorded URLs are redacted.
Add a regression test:
req := httptest.NewRequest("GET", "https://api.github.com/user?access_token=secret", nil)
// ... RoundTrip, then assert:
// attrs["http.url"].AsString() == "https://api.github.com/user?access_token=REDACTED"
Verification
Static review only. I read otel/transport.go, otel/transport_test.go, and the sensitiveParams / sanitizeURL code in github/github.go at commit 2190e6a (2026-10-21). No runtime proof of concept was executed and no exporter was run; the exposure follows directly from req.URL.String() being placed into a span attribute with no redaction step.
- Ngôn ngữ chính
- Go
- Star
- 11.3k
- Fork
- 2.6k
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 38
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 google/go-github
-
Rate-limit retry replays a consumed request body for POST/PUT/PATCHCó thể đã có người làm @AdamMagued đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
google/go-github#4656 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Error() methods modify the request URL of the response they wrapCó thể đã có người làm @AdamMagued đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Discuss the future of this repoĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 5/100
google/go-github#4636 · 11 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
http.Client.Timeout is ignored by redirect-aware requestsCó thể đã có người làm @sb123sb123 đã nhận 31 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add Copilot content exclusion set/get enterprise and org set endpointsCó thể đã có người làm @Tens1des đã nhận 45 ngày trước. Đang mở
google/go-github#4526 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của google/go-github
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
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 84/100
praetorianer777/Dynamo#53 ·
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 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/engineering pulumi/pulumi-terraform Task Workflow Failure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
pulumi/pulumi-terraform#1261 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Controllers integration tests fail when port 8080 is in useCó thể đã có người làm @noahnut đã nhận hôm nay. Đang mởarea/cluster-autoscaler kind/bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kubernetes-sigs/cluster-autoscaler#236 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày