You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Malformed RPC payload throws ParseError inside scope resolution, producing a defect report instead of a 403 #26491
requiredScopesForRpcCall (packages/contracts/src/clientRpcPermissions.ts ~71-84) decodes payloads with Schema.decodeUnknownSync to pick a dynamic scope, and runs synchronously from the middleware factory (apps/server/src/auth/RpcAuthorization.ts ~229-279) before any authorization decision. A malformed payload to serverUpdateSettings, projectsMutate, assetsCreateUrl, gitRunStackedAction, or gitPreparePullRequestThread throws there, and Effect RPC surfaces it as a server defect (the connection survives with disableFatalDefects, but a defect report is emitted).
Any authenticated session, including a deliberately narrow read-only one, can loop malformed calls and generate unbounded defect reports and log noise, and receives an ambiguous internal error rather than a clean invalid-request/403.
Expected: decode with Schema.decodeUnknownEither and return a typed failure (invalid request) on parse failure, failing closed. Do not fall back to the static table scope on decode failure; serverUpdateSettings can require providers:manage beyond settings:write, so a fallback would under-authorize.
I plan to submit a focused fix (Either-based decode with typed failure, with a test).
Thanks for the detailed write-up. I tested this on main at 5211acf, and malformed payloads never reach requiredScopesForRpcCall.
Effect RPC's RpcServer.make decodes each request's payload against the RPC's payloadSchema before it calls the handler or any middleware. A failed decode is answered at that point with that request's own failure. RpcScopeAuthorization only ever receives payloads that already decoded. The five RPCs you list (server.updateSettings, projects.mutate, assets.createUrl, git.runStackedAction, git.preparePullRequestThread) declare the same schemas that the scope resolver decodes again, so a payload that gets through the first decode also gets through the second.
What I ran: a vp run dev server with a fresh database, a bearer session issued with only orchestration:read, and raw RPC frames over /ws:
Malformed payloads to all five RPCs: each came back as its own request's failure with the schema message, for example Expected object at ["patch"] or Missing key at ["cwd"]. The server logged no Unhandled defect, and the socket stayed open. A server.probe sent afterwards succeeded.
A valid but unauthorized server.updateSettings (defaultRuntimeMode: "full-access") returned EnvironmentAuthorizationError for settings:write.
With temporary logging inside requiredScopesForRpcCall, only the three valid calls reached it; none of the malformed calls did.
So scope resolution doesn't throw here, and no defect report is emitted. Closing as not a bug. If you have a payload that does get past the RPC's own decode and then throws in the scope resolver, please reopen with the frame and we'll look again.
Activity
juliusmarminge commentedon Oct 28, 2026
Thanks for the detailed write-up. I tested this on
mainat 5211acf, and malformed payloads never reachrequiredScopesForRpcCall.Effect RPC's
RpcServer.makedecodes each request's payload against the RPC'spayloadSchemabefore it calls the handler or any middleware. A failed decode is answered at that point with that request's own failure.RpcScopeAuthorizationonly ever receives payloads that already decoded. The five RPCs you list (server.updateSettings,projects.mutate,assets.createUrl,git.runStackedAction,git.preparePullRequestThread) declare the same schemas that the scope resolver decodes again, so a payload that gets through the first decode also gets through the second.What I ran: a
vp run devserver with a fresh database, a bearer session issued with onlyorchestration:read, and raw RPC frames over/ws:Expected object at ["patch"]orMissing key at ["cwd"]. The server logged noUnhandled defect, and the socket stayed open. Aserver.probesent afterwards succeeded.server.updateSettings(defaultRuntimeMode: "full-access") returnedEnvironmentAuthorizationErrorforsettings:write.requiredScopesForRpcCall, only the three valid calls reached it; none of the malformed calls did.So scope resolution doesn't throw here, and no defect report is emitted. Closing as not a bug. If you have a payload that does get past the RPC's own decode and then throws in the scope resolver, please reopen with the frame and we'll look again.