[plugin-rsc] Dev server: unauthenticated invocation of arbitrary exports in 'use server' modules (no export-name validation in loadServerAction)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- react, typescript
调研方向
从 packages/plugin-rsc/src/core/rsc.ts 开始并检查 loadServerAction,然后阅读 plugin.ts:357-405 和 rsc/shared.ts:6-13,以追踪开发模式验证和模块加载。使用 starter example 以及报告中描述的 POST 请求重现该问题。当未注册的导出无法再被 dispatch,同时已注册的 server action 仍能正常工作,并且该重现被拒绝时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Disclosure draft: vitejs/vite-plugin-react (@vitejs/plugin-rsc)
Summary
@vitejs/plugin-rsc dev server allows unauthenticated remote invocation of any export of any module that contains a use server directive, because loadServerAction performs no export-name validation and the dev-mode module loader returns the full module namespace. This affects all frameworks built on plugin-rsc's RSC runtime (confirmed: Waku ≥0.24 / 1.0 betas; React Router v7 RSC mode; TanStack experimental RSC package) as well as direct plugin-rsc consumers.
Details
packages/plugin-rsc/src/core/rsc.ts:94-98:
export async function loadServerAction(id: string): Promise<Function> {
const [file, name] = id.split('#') as [string, string] // both fully attacker-controlled
const mod: any = await requireModule(file)
return mod[name]
}
The dev-mode validation gate (plugin.ts:357-405, rsc:reference-validation) only checks that the file is (or can be transformed into) a server-reference module — and helpfully transforms-and-registers any workspace file containing a use server directive on demand (plugin.ts:381-394), so the target module does not even need to be routed/rendered. After the file-level check, rsc/shared.ts:6-13 does import(id) and the full namespace is returned; mod[name] then reaches any own export, including plain helper exports that are not actions at all (e.g. exports of a server-component file that merely contains one function-level 'use server').
Production builds are not affected: the build-time virtual:vite-rsc/server-references module (plugin.ts:2154-2174) destructures only the scanned action exports, and reference keys are hashed.
Module ids in dev are plain project paths (e.g. /src/actions.ts), visible in served pages/chunks and trivially guessable.
Reproduction (verified end-to-end, plugin-rsc starter example)
Target module src/poc-target.ts (never routed):
export async function targetAction() {
'use server'
return 'target-ok'
}
export async function runShell(cmd: string) { // plain export, NOT an action
const cp = await import('node:child_process')
return new Promise((r) => cp.exec(cmd, (e, so) => r(String(so))))
}
Request (dev server):
POST /_.rsc HTTP/1.1
x-rsc-action: /src/poc-target.ts#runShell
Content-Type: text/plain
["touch /tmp/pwned"]
Result: 200, file /tmp/pwned created — unauthenticated remote command execution (the runShell export stands in for the dangerous-helper pattern; even without such an export, the flaw exposes every "hidden" action/helper the app never shipped to clients).
Waku inheritance (also verified live, [email protected]): POST /RSC/F/_/src/poc-target.ts/runShell.txt with the same body — same result. Waku's decodeFuncId (waku/dist/lib/utils/rsc-path.js:40-55) performs zero validation.
Boundary (all verified): node: builtins, modules without a genuine directive (AST-level prologue detection), and files outside the workspace (isFileLoadingAllowed) are all rejected.
Impact
- Any developer running
vite dev/waku dev(which binds all interfaces by default) with a project that has any dangerous export in ause server-containing module is exposed to unauthenticated RCE by same-machine processes, LAN attackers, or drive-by browser attacks (no-Origin requests are accepted; Waku's only check is an Origin match that allows absent Origin). - Even absent dangerous exports, attackers can invoke actions/helpers the application never exposed to clients (authorization-bypass class).
An ecosystem sweep of 64 public dependent repos found no ready-made dangerous export in dispatchable modules; the issue is reported as a framework-level design flaw (the primitive), not as a claim of in-the-wild RCE.
Suggested fix
- Validate the full
file#namepair against the scanned server-reference registry in dev (same semantics as the production virtual module), e.g. haveload()return a view exposing only registered export names. - Consider gating the on-demand
transformRequestregistration fallback to modules already in the graph. - Frameworks (Waku/RR7): validate the decoded func id against the registry before dispatch.
Affected versions
@vitejs/plugin-rsc 0.4.x–0.5.x (verified on latest as of 2026-08-10); waku ≥0.24 / 1.0.0-beta.9 (verified). React Router v7 RSC mode and TanStack experimental RSC inherit the plugin-rsc dispatch.
- 主要语言
- TypeScript
- 星标
- 1.2k
- 派生
- 287
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
vitejs/vite-plugin-react 的其他 Issue
-
plugin-rsc: a client reference's CSS is linked before the CSS of the chunks it imports (build)可能已有人在做 @wozhenbang2004 于 7 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
vitejs/vite-plugin-react#1570 ·
维护者通常 1 天内回复
-
[plugin-rsc] With two dev servers in one process, loadModule runs in the last server's environment未关闭
难度 4/5 3-5 天 新手友好度 57/100
vitejs/vite-plugin-react#1589 ·
维护者通常 1 天内回复
-
pending triage
难度 4/5 3-5 天 新手友好度 35/100
vitejs/vite-plugin-react#1581 ·
维护者通常 1 天内回复
-
[plugin-rsc] Build exits 0, but the app fails at runtime: a server action imported only by browser code is missing from the RSC build可能已有人在做 @NeilPant 于 4 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
vitejs/vite-plugin-react#1578 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
vitejs/vite-plugin-react#1577 ·
维护者通常 1 天内回复
查看 vitejs/vite-plugin-react 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
ardia-browser/ardia#4778 ·
维护者通常 1 天内回复
-
[M09] Silence parser misreads ffmpeg times in scientific notation (6.25e-05 → 6.25 s)可能已有人在做 @G-darshan-32 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
clipy-recorder/clipy#164 · 1 条评论 ·
-
bug from-app needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
nightly-labs/openbot#18462 ·
维护者通常 1 天内回复
-
Fast and light shell approval "Always allow" button shows raw English backticks and scrambles commands in Arabic可能已有人在做 @tylerbea 今天认领。 未关闭agent-ui bug p3
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug] Windows: Ctrl+C / Ctrl+V not working in chat input box可能已有人在做 @PranavTJ-05 今天认领。 未关闭comp/desktop desktop/chat desktop/shell os/windows P2 type/bug
难度 2/5 1-3 小时 新手友好度 76/100
NousResearch/hermes-agent#161023 · 2 条评论 ·
维护者通常 1 天内回复