//nefariousplan

CVE-2026-47724: nebula-mesh's API Layer Documented the Authorization Gap. The Web Layer Had the Check.

vendor

patterns

cve

proof of concept

A comment at internal/api/hosts.go:384 of nebula-mesh v0.3.0 reads: "API trusts the bearer token for authorisation; per-CA ownership is enforced only in the Web layer (handleHostUpdate). Matches handleCreateHost/handleDeleteHost behaviour." The Web layer's handleHostUpdate does have the check. The API layer's does not. CVE-2026-47724 is what happens in the four lines of comment between writing it and removing it.

The internal/api/hosts.go file in nebula-mesh v0.3.0 contains a comment at line 384.

// API trusts the bearer token for authorisation; per-CA ownership is
// enforced only in the Web layer (handleHostUpdate). Matches
// handleCreateHost/handleDeleteHost behaviour.

The comment sits inside handleUpdateHost, the handler that lets the caller change which network a host belongs to, which IP it claims, and which firewall rules apply. The function it names, handleHostUpdate, exists in a different package, internal/web/handlers.go, and looks like this at line 940:

if op.Role != "admin" {
    network, err := w.store.GetNetwork(r.Context(), host.NetworkID)
    if err != nil {
        http.Error(rw, "Internal Server Error", http.StatusInternalServerError)
        return
    }
    ca, err := w.store.GetCA(r.Context(), network.CAID)
    if err != nil || ca.OwnerOperatorID != op.ID {
        http.Error(rw, "Unauthorized", http.StatusForbidden)
        return
    }
}

Two packages. Same Postgres rows. Same multi-tenant invariant, that an operator can only modify hosts under a CA they own. The Web layer reads cas.owner_operator_id and compares it against the session operator. The API layer reads the bearer token and trusts it.

The maintainer wrote the comment that explained why, and shipped the gap that the comment explained. CVE-2026-47724 is what that gap let through.

The bearer token

nebula-mesh is the open-source control plane for Slack's Nebula mesh VPN. An operator runs it to sign certificates for hosts (laptops, phones, servers) joining a private overlay. v0.3.0 introduced multi-tenant operation: a single deployment can host multiple CAs, each owned by a different operator, and the ownership column cas.owner_operator_id is the line between "your CA" and "someone else's CA."

The browser-facing Web UI gates every CA-scoped operation against that column. The HTTP API does not.

The bearer-token middleware lives in internal/api/middleware.go. It hashes the Authorization: Bearer … value with SHA-256, looks the hash up in operator_api_keys, attaches the resolved operator to the request context, and calls the next handler. If the token resolves, you are the operator who owns the key. If you are any operator with any active API key, you are authenticated to the entire /api/v1/* surface.

There is also a legacy fallback. If the deployment still uses a config-file api.token, that token resolves to no operator, and the actorIsAdmin helper treats no-operator as admin.

Two ways into the API. One of them does not even resolve to a person.

What the API layer let through

I counted authorization calls across internal/api/*.go at v0.3.0. The pattern is unambiguous.

File canAccessCA / canAccessHost / actorIsAdmin calls
cas.go 7
settings.go 2
operators.go 1 (admin-only on create)
hosts.go 0
networks.go 0
firewall.go 0
mobile_bundle.go 0
audit.go 0

The author knew the pattern. cas.go uses it seven times. Every handler that touches a CA row reads canAccessCA first. The handlers that touch hosts, networks, firewall rules, mobile bundles, and audit logs do not.

Three exploit chains follow directly. The GHSA-598g-h2vc-h5vg advisory, which is the upstream half of CVE-2026-47724, calls each of them out by route.

1. Mint an admin API key for an admin you are not

POST /api/v1/operators/{id}/api-keys is handled by handleCreateOperatorAPIKey at internal/api/operators.go:118. The handler loads the target operator, generates 32 bytes of random key material, hashes it, persists the hash against the target operator, and returns the plaintext to the caller.

func (s *Server) handleCreateOperatorAPIKey(w http.ResponseWriter, r *http.Request) {
    id := chi.URLParam(r, "id")
    if _, err := s.store.GetOperator(r.Context(), id); err != nil {
        ...
    }
    var req createAPIKeyRequest
    if r.ContentLength > 0 {
        _ = json.NewDecoder(r.Body).Decode(&req)
    }

    keyBytes := make([]byte, 32)
    if _, err := rand.Read(keyBytes); err != nil {
        writeError(w, http.StatusInternalServerError, "failed to generate api key")
        return
    }
    plaintext := hex.EncodeToString(keyBytes)
    ...
}

There is no check that the caller is the target operator. There is no check that the caller is an admin. The peer handler one screen up, handleCreateOperator, has if !actorIsAdmin(r.Context()). The peer handler one screen down, handleRevokeOperatorAPIKey, does not.

$ curl -X POST -H "Authorization: Bearer $LOW_PRIV_KEY" \
    https://mesh.example.com/api/v1/operators/$ADMIN_ID/api-keys \
    -H "Content-Type: application/json" \
    -d '{"name":"audit"}'

{"key":"a1b2c3...","entry":{"id":"...","operator_id":"$ADMIN_ID",...}}

The returned key resolves through the bearer middleware as the admin operator. You now have admin.

2. Reenroll a host you do not own

POST /api/v1/hosts/{id}/reenroll mints a fresh enrollment token for a host. The token is short-lived and grants the bearer the right to register a Nebula identity for that host on next call-in.

func (s *Server) handleReenroll(w http.ResponseWriter, r *http.Request) {
    id := chi.URLParam(r, "id")
    host, err := s.store.GetHost(r.Context(), id)
    ...
    token, err := s.mintEnrollmentTokenForHost(r.Context(), host)
    ...
    writeJSON(w, http.StatusOK, map[string]string{"token": token})
}

No CA-ownership check. Any operator, or anyone holding the legacy config-file token, can mint an enrollment token for any host on the mesh: a laptop on the CTO's CA, a production database server on the platform CA, a field engineer's tablet on a customer CA. Redeem the token from a machine you control. The new identity inherits the host's network membership, IP, and firewall groups. The original host's next callback fails authentication.

3. Walk away with a mobile device's identity

POST /api/v1/hosts/{id}/mobile-bundle returns the YAML config plus a freshly generated private key for a mobile host, intended to be flashed onto the device during provisioning. The private key is not persisted on the server. The handler generates it, embeds it in the response, and forgets it.

func (s *Server) handleMobileBundle(w http.ResponseWriter, r *http.Request) {
    id := chi.URLParam(r, "id")

    host, err := s.store.GetHost(r.Context(), id)
    ...
    if host.Kind != models.HostKindMobile {
        writeError(w, http.StatusBadRequest, "host must be a mobile host")
        return
    }

    caMgr, err := s.caForHost(r.Context(), host)
    ...
    bundle, err := mobilebundle.Build(r.Context(), s.store, resolver, host)
    ...
    w.Header().Set("Content-Type", "application/yaml; charset=utf-8")
    w.WriteHeader(http.StatusOK)
    w.Write(bundle)
}

The only check is that the host's Kind is mobile. There is no check that the caller owns the CA that signed it. Any operator with an API key on the deployment can request the YAML bundle for any mobile host on the mesh, and the response is a complete, ready-to-flash Nebula identity for that device. The legitimate device, when it tries to provision later, gets a different identity from a later signing call; the attacker, having received the first one, has already joined the mesh as that host.

These three are not subtle. The Slack engineer who wrote the GHSA advisory wrote three exploit chains, and they were these three.

The Web layer had the check

The Web layer's version of host-update lives at internal/web/handlers.go:917. It does what the API comment said happens elsewhere:

func (w *WebServer) handleHostUpdate(rw http.ResponseWriter, r *http.Request) {
    ...
    host, err := w.store.GetHost(r.Context(), hostID)
    ...
    op := getOperatorFromSession(r)

    // Ownership check
    if op.Role != "admin" {
        network, err := w.store.GetNetwork(r.Context(), host.NetworkID)
        if err != nil {
            http.Error(rw, "Internal Server Error", http.StatusInternalServerError)
            return
        }
        ca, err := w.store.GetCA(r.Context(), network.CAID)
        if err != nil || ca.OwnerOperatorID != op.ID {
            http.Error(rw, "Unauthorized", http.StatusForbidden)
            return
        }
    }
    ...
}

Three rows. Host to network. Network to CA. CA to owner. If the owner is not the session operator, return Forbidden. The same chain appears in handleHostCreate, handleHostDelete, handleHostBlock, handleHostRotateCert, handleNetworkUpdate, handleFirewallRuleCreate. The Web layer is built on the assumption that an operator can only touch their own CA's hosts.

The API layer is built on the assumption that the Web layer is built on that assumption.

The function existed

internal/api/authz.go lands in nebula-mesh as a small file at v0.3.3, but the helpers it consolidates existed in earlier versions split across files. cas.go had canAccessCA. The same module that imports chi/v5 and uuid and bcrypt for handleCreateOperatorAPIKey could have imported canAccessCA. It did not.

The comment at hosts.go:384 was not a TODO. It was not // FIXME: add authz check later. It was a flat declarative sentence about where authorization happened. The API trusts the bearer token. Ownership is enforced in the Web layer. Matches sibling behaviour.

The sibling behaviour was the bug.

The fix is the comment, removed

Commit 8baaace landed on May 20, 2026, five days after v0.3.0 shipped. The commit message reads:

fix(api): enforce CA-ownership and admin gates on /api/v1/* (GHSA-598g-h2vc-h5vg)

New internal/api/authz.go consolidates per-handler authorisation. Mirrors internal/api/cas.go canAccessCA pattern. Discharge comment about per-CA ownership being Web-only removed.

The diff for handleUpdateHost deletes the four lines of comment and inserts three lines of call:

-    // API trusts the bearer token for authorisation; per-CA ownership is
-    // enforced only in the Web layer (handleHostUpdate). Matches
-    // handleCreateHost/handleDeleteHost behaviour.
+    ok, err := s.canAccessHost(r.Context(), host)
+    if err != nil || !ok {
+        writeError(w, http.StatusForbidden, "forbidden")
+        return
+    }

The comment occupied the lines where the call needed to be. The fix was to delete the comment and write the call.

The other twenty-three vulnerable handlers got the same treatment. handleCreateOperatorAPIKey gained an actorIsAdmin check. handleReenroll gained canAccessHost. handleMobileBundle gained canAccessHost. The diff is large and boring. The hard part was deciding that the API layer needed an authorization check at all, and the maintainer had decided against it in writing, in the file, with a comment that named the sibling handlers it was modeling itself on. The fix is not a feature. The fix is a reversal of a decision.

What the pattern is

The Web layer and the API layer are two packages in the same repository implementing the same contract over the same database. Both have a handleHostUpdate. Both call store.UpdateHost. Both produce HTTP responses. One imports the shared authorization helper from a sibling file in the same package. The other names the helper's call site in a comment and does not call it.

This is the parallel-implementation-gap pattern. The canonical module enforces the check. The divergent module exposes the same client-facing contract and does not. The CVE names the divergent module. CVE-2026-47724's affected-versions field is <= 0.3.0. The Web layer is not affected. The API layer is the entire CVE.

The within-pattern variant in nebula-mesh is unusual only in its explicitness. In most exhibits, Astro's Cloudflare adapter, mcp-atlassian's Bitbucket branch, MLflow's FastAPI surface, the divergent module never mentions the shared utility. The author of the divergent module has not, as far as the commit history reveals, ever read the code in the canonical module. The gap is silent.

In nebula-mesh the gap is documented. The maintainer wrote the comment. The maintainer named handleHostUpdate in the comment. The maintainer named handleCreateHost and handleDeleteHost as the siblings whose behaviour was being matched. Every authoring step that would normally signal "I should go look at the canonical module and check whether my divergent module agrees" was taken. The comment is the evidence that the lookup happened. The conclusion was that the divergent module would not enforce the check.

The pattern usually surfaces in code review as "did the second author know about the first author's check." Here the answer is yes. The second author was the first author. They knew. They wrote it down.

The deeper pattern, the one Arcane's CVE-2026-47125 named four weeks ago and that CVE-2026-47724 re-instances now, is design-debt-driver: when the authorization primitive is per-handler, when every handler has to remember to call canAccessHost, the recurring symptom is handlers that forget. The cas.go author remembered seven times. The hosts.go author named the primitive in a comment and did not call it. The natural home for an authorization check that applies to every CA-scoped endpoint is the middleware layer. nebula-mesh's middleware authenticates the bearer token and stops there. Every handler is on its own.

A reader who wants to know which handlers are gated has to read each handler. A maintainer adding a new endpoint has to remember to add the check. A reviewer auditing the surface has to count canAccessCA calls against route definitions and check that the count matches. The hosts.go comment is what it looks like when that audit happens, finds the gap, and decides the gap is fine.

What the comment was

The comment was the policy. It told future readers, including the future maintainer who would write the fix, exactly what the design was: API trusts the bearer token, per-CA ownership is Web-only, the siblings agree. The siblings did agree. The comment was an accurate description of the code.

CVE-2026-47724 is the description of why an accurate description of the code was not enough.

The comment was the policy. The fix was deleting the comment.