-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The /cron route uses commonHandler. /user uses adminHandler.\n\nNezha's dashboard router maps each route to a handler wrapper that pins the role required to call it. Reading the table top to bottom is reading the project's intuition about which capabilities belong to which role.\n\n```go\nauth.GET(\"/user\", adminHandler(listUser))\nauth.POST(\"/user\", adminHandler(createUser))\nauth.POST(\"/batch-delete/user\", adminHandler(batchDeleteUser))\n...\nauth.POST(\"/cron\", commonHandler(createCron))\nauth.PATCH(\"/cron/:id\", commonHandler(updateCron))\nauth.GET(\"/cron/:id/manual\", commonHandler(manualTriggerCron))\nauth.POST(\"/batch-delete/cron\", commonHandler(batchDeleteCron))\n...\nauth.PATCH(\"/setting\", adminHandler(updateConfig))\nauth.POST(\"/maintenance\", adminHandler(runMaintenance))\n```\n\nUser management is admin-only. So is the global config switch and the maintenance toggle. Cron is not. The intent is legible: a RoleMember should be able to schedule a script on a server they own. The gate that is supposed to enforce \"on a server they own\" is the second line of `createCron`:\n\n```go\nfunc createCron(c *gin.Context) (uint64, error) {\n var cf model.CronForm\n if err := c.ShouldBindJSON(&cf); err != nil {\n return 0, err\n }\n\n if !singleton.ServerShared.CheckPermission(c, slices.Values(cf.Servers)) {\n return 0, singleton.Localizer.ErrorT(\"permission denied\")\n }\n ...\n cr.UserID = getUid(c)\n cr.Servers = cf.Servers\n cr.Cover = cf.Cover\n ...\n}\n```\n\nOne line decides whether a member is allowed to write a cron against the server IDs they submitted. The function it calls is a generic over a typed map class. The function is shared by twelve call sites in this controller.\n\n## CheckPermission over an empty sequence returns true\n\n`CheckPermission` is a method on a generic container class in `service/singleton/singleton.go`. It accepts an `iter.Seq[K]` of IDs and returns true if every ID the caller named is one the caller is allowed to address.\n\n```go\nfunc (c *class[K, V]) CheckPermission(ctx *gin.Context, idList iter.Seq[K]) bool {\n c.listMu.RLock()\n defer c.listMu.RUnlock()\n\n for id := range idList {\n if s, ok := c.list[id]; ok {\n if !s.HasPermission(ctx) {\n return false\n }\n }\n }\n return true\n}\n```\n\nThe function's contract, in English, is \"find an ID the caller does not own; if you find one, say no.\" That is what the code says. The code does not say \"verify that every ID the caller listed is owned by them.\" The two contracts are equivalent over non-empty input. They diverge over empty input. The first short-circuits to true. The second short-circuits to false. Go's universal quantifier over an empty sequence is the first.\n\nThe caller is `slices.Values(cf.Servers)`. `cf.Servers` is `[]uint64{}` when the request body is `{\"servers\": []}`. `slices.Values` on an empty slice returns an `iter.Seq[uint64]` that yields zero elements. The `for id := range idList` loop runs zero times. The function returns true.\n\nAn empty Servers list does not mean \"this request affects no servers.\" It means the predicate ran out of work before it could find a violation. Those are not the same answer, and `createCron` is built on the second.\n\nOnce `CheckPermission` returns true, the function falls through to the database insert. The stored cron has `UserID = getUid(c)`, the RoleMember's user ID, and `Servers = []`, the empty list the caller submitted, and `Cover = 1`, the value the caller chose for the mode field. The cron is now registered. The scheduler reads the row.\n\n## CronTrigger iterates every server in the dashboard\n\n`CronTrigger` in `service/singleton/crontask.go` is the closure the scheduler invokes when a cron fires. The pre-patch version is the source of the cross-tenant primitive that became CVE-2026-46716.\n\n```go\nfunc CronTrigger(cr *model.Cron, triggerServer ...uint64) func() {\n crIgnoreMap := make(map[uint64]bool)\n for _, server := range cr.Servers {\n crIgnoreMap[server] = true\n }\n return func() {\n ...\n for _, s := range ServerShared.Range {\n if cr.Cover == model.CronCoverAll && crIgnoreMap[s.ID] {\n continue\n }\n if cr.Cover == model.CronCoverIgnoreAll && !crIgnoreMap[s.ID] {\n continue\n }\n if s.TaskStream != nil {\n s.TaskStream.Send(&pb.Task{\n Id: cr.ID,\n Data: cr.Command,\n Type: model.TaskTypeCommand,\n })\n }\n ...\n }\n }\n}\n```\n\n`cr.Cover` is the user-supplied mode field. `CronCoverAll` is the iota constant `1` and means \"run on all servers except those in the Servers list.\" `crIgnoreMap` is the lookup the loop uses to skip excluded servers.\n\nWith `cr.Servers = []`, `crIgnoreMap` is empty. The `continue` branch never fires. `ServerShared.Range` is the global server registry across every tenant on the dashboard. The loop calls `s.TaskStream.Send` against every agent in the system. Each agent reads `pb.Task{Data: cr.Command, Type: model.TaskTypeCommand}` and executes the command. `cr.Command` is the attacker's shell string from the form.\n\nThe chain is three writes: the auth gate accepts a RoleMember, the permission check accepts the empty Servers list, the dispatcher iterates the global registry. At the end of it every agent in the deployment is executing the attacker's command. The attack request is one POST.\n\n```bash\ncurl -X POST https://dashboard.example/api/v1/cron \\\n -H 'Authorization: Bearer ' \\\n -H 'Content-Type: application/json' \\\n -d '{\"task_type\":0,\"name\":\"x\",\"scheduler\":\"*/1 * * * * *\",\"command\":\"id\",\"servers\":[],\"cover\":1,\"push_successful\":true,\"notification_group_id\":0}'\n```\n\nThe cron fires every second. Every agent in the deployment runs `id` and the result returns via the same gRPC stream that delivered the command. Replace `id` with anything.\n\nThe cross-tenant boundary is the global `ServerShared` map. Nezha's deployment model is one dashboard, many tenants, each tenant's agents reporting back over a gRPC stream the dashboard owns. The dashboard is the single point that holds every tenant's agents in one in-memory registry. The cron dispatcher reaches every entry in that registry.\n\n## The patch closes the dispatcher and leaves the gate\n\nThe fix for CVE-2026-46716 shipped on May 10 as commit `d7526351cf97`, titled `fix(cron): restrict task delivery by owner`. It adds one helper and three call sites inside `crontask.go`.\n\n```diff\n for _, s := range ServerShared.Range {\n+ if !cronCanSendToServer(cr, s) {\n+ continue\n+ }\n if cr.Cover == model.CronCoverAll && crIgnoreMap[s.ID] {\n continue\n }\n```\n\n```go\nfunc cronCanSendToServer(cr *model.Cron, server *model.Server) bool {\n return cr.UserID == server.UserID || userIsAdmin(cr.UserID)\n}\n```\n\nA RoleMember's cron, whose `cr.UserID` is the member's ID, now skips any server whose `UserID` is not their own. The cross-tenant RCE primitive is closed at the delivery layer.\n\nWhat the patch does not touch:\n\n- The `/cron` route still uses `commonHandler`. A RoleMember can still POST a cron with `\"servers\": []` and `\"cover\": 1`.\n- `CheckPermission` over an empty sequence still returns true. The validator at the front of `createCron` still says yes.\n- The stored cron still has `Cover: CronCoverAll` and `Servers: []` in the database. The scheduler still fires it.\n\nA RoleMember submitting the same payload after the patch receives `200 OK` and a stored row whose trigger function will silently skip every server it would have hit. The validator that said the request was authorized never learned anything. The fix moved the boundary from \"we will not let you write this cron\" to \"we will let you write the cron and not deliver it.\" Those are not the same boundary, and the front of the function is still the wrong answer.\n\n## CheckPermission is called twelve times in this controller\n\nThe generic helper is not exclusive to `/cron`. `grep -n CheckPermission cmd/dashboard/controller/` returns twelve call sites:\n\n- `cron.go` (createCron, updateCron, batchDeleteCron)\n- `server.go` (createServer DDNS-profile list, batch-delete server, batch-move server)\n- `server_group.go` (createServerGroup, updateServerGroup, listServerGroup edge case)\n- `notification.go` (batchDeleteNotification)\n- `ddns.go` (batchDeleteDDNS)\n- `nat.go` (batchDeleteNAT)\n\nEach call site passes an `iter.Seq` derived from a user-supplied list. Each call site treats a true return as \"you may proceed.\" Each call site, given an empty input, will accept \"proceed.\"\n\nSeveral of those routes are admin-only, so the empty-as-wildcard collapse means nothing in practice. An admin is already allowed everywhere. The member-accessible ones, `batchDeleteServer`, `batchMoveServer`, `createServerGroup` with `[]Servers`, `batchDeleteNAT` over IDs the member named, are the places to look next. A `cronCanSendToServer`-style filter at the delivery layer rescues each of those only if somebody writes it, by hand, per call site. There is no rescue at the helper.\n\nThis is the empty-filter-is-wildcard pattern at the authorization layer. We have covered the same shape at WordPress's query layer. [Elementor's Temporary Login plugin shipped it at `meta_value`](https://nefariousplan.com/posts/temp-login-token-field-is-a-filter), where an empty filter passed through `sanitize_key` became a `get_users` wildcard over every temporary administrator the plugin ever created. The interpreter differs; the function whose universal quantifier over the empty set returns the answer the caller wanted to hear is the same.\n\n## The three components were each correct in their own scope\n\nCVE-2026-46716 is an emergent primitive. No component in this chain is wrong in isolation. The auth gate's authors believed a RoleMember should be able to schedule a cron. They were right; a member needs to schedule scripts on the servers they own. The `CheckPermission` helper's author wrote a clean Go generic that iterates IDs and rejects on the first one the caller does not own. Read in isolation, the function does what its name implies. The `CronTrigger` author wrote a dispatcher that walks the global server registry and skips the ignore-list when `Cover == CronCoverAll`. Read in isolation, that is what the mode field promises.\n\nEach component is correct under the threat model its author was holding. The threat model that fails is the one that spans them, the one where the authorization-list semantics (\"you have permission to these IDs\") meets the dispatch semantics (\"run on everything except these IDs\") through the same empty slice. No author wrote a check at that intersection because no author owned that intersection. The primitive lives in the composition. The CVE record names the cron endpoint because that is the call site where it surfaced; the helper that produced it is still in the binary, waiting for the next call site that does not have a `cronCanSendToServer` of its own.\n\nPoC: [GHSA-99gv-2m7h-3hh9](https://github.com/advisories/GHSA-99gv-2m7h-3hh9)","closing_line":"The patch fixes the dispatcher. The validator that said yes is untouched.","hook_md":"Nezha's permission helper is a Go generic over a sequence of IDs. It iterates each ID the caller named, calls `HasPermission` on each, and returns `false` on the first miss. Over an empty sequence the loop body never runs and the function falls through to `return true`. A RoleMember user who posts a cron with `\"servers\": []` and `\"cover\": 1` is asking the dashboard to run a shell command on every server in the deployment minus the servers in that empty list, and the permission check that should have rejected the request has nothing to iterate. The patch for CVE-2026-46716, shipped May 10, fixes the dispatcher. The validator that said yes is untouched.","post_id":449,"slug":"nezha-cve-2026-46716-empty-list-returned-true","title":"CVE-2026-46716: Nezha's Permission Check Said Yes to an Empty Servers List. The Dispatcher Ran the Cron on Every Tenant.","type":"initial","unreadable_sentence":"CheckPermission over an empty sequence does not return \"permission to nothing.\" It returns \"permission to everything.\""} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCanDp8wAKCRDeZjl4jgkQ JkjHAP4ig2IDKvruYdmZOoYQwDhRdD99B6V5OP/kUfgJZjWnLgEAvHbV0wHE0+m4 cpsaOIKhVsLqPJjcmJPFNlDVxL1qTQo= =PUEF -----END PGP SIGNATURE-----