Skip to content

fix(server-core): gate package and project plugin changes on a trusted folder - #386

Open
Exeloo wants to merge 3 commits into
mainfrom
fix/registry-trust-gate
Open

Exeloo wants to merge 3 commits into
mainfrom
fix/registry-trust-gate

Conversation

@Exeloo

@Exeloo Exeloo commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Closes #248

Package and project plugin changes now need a trusted folder, and they no longer follow links out of the project. The editor still ships @nanoforge-dev/registry 3.0.1, so these checks live in the editor server and are enough for #248 on their own.

  • Trust gate (registry.implementation.ts): restorePackages, installPackage, updatePackage, uninstallPackage and the project-scope installPlugin / uninstallPlugin call projects.assertTrusted, as the other trust-gated RPCs do. The order is localOnly → projects.get → assertTrusted. Listing packages and user-scope plugins stay open.
  • Link checks before a change (BAD_REQUEST "… is a symbolic link"): nf_modules, its scopes and their entries; nanoforge.packages.json, its lock and tsconfig.json; and every folder on the way to a project plugin (.nanoforge, plugins, scope, entry).
  • Packages dialog (plugins/packages): it showed "Packages can only be installed in a local editor." for every FORBIDDEN, which is wrong in an untrusted folder. It now shows the server's message, which names the right reason in a hosted editor and in an untrusted folder.
  • Docs: docs/docs/editor/plugins-and-packages.mdx and docs/docs/getting-started/create-your-first-project.mdx say that package and project plugin changes need a trusted folder.

The same nf_modules and project-file checks in the registry lib are in NanoForge-dev/CLI fix/registry-safety (NanoForge-dev/CLI#380), as defence in depth once the editor moves to that release.

How do you test this PR?

Test Before After
server-core test/rpc/registry.spec.ts "changes the packages and plugins of a trusted project only" promise resolved instead of rejecting passes
"never installs or removes project plugins through a symbolic link" (linked .nanoforge, plugins and scope, as junctions) promise resolved instead of rejecting passes
"never changes packages through a symbolic link in nf_modules" promise resolved instead of rejecting BAD_REQUEST, the folder outside is untouched
"never reads or writes the project files of packages through a symbolic link" (linked tsconfig.json, dangling tsconfig.json, linked list) promise resolved instead of rejecting refused, nothing outside read or written; registry spec 12/12
e2e marketplace.spec.ts "says a restricted folder must be trusted before its packages change" received "Packages can only be installed in a local editor." passes

Commands run from the worktree: pnpm build, pnpm typecheck, pnpm lint (after the build, so knip ran), server-core unit tests (133 passed on 0bd693d), packages plugin unit tests (2 passed). On cfcfdca: CHROME=… pnpm test (41/41 tasks, 1 skipped: editor-native.spec.ts, no .examples/) and Playwright marketplace, trust and project-plugins (7 passed, 0 skipped). No UI file changed after that e2e run.

Integration: a scratch branch with every editor branch of this sweep merged passed pnpm build, lint, typecheck, pnpm test --force (1014 passed, 1 skipped) and the full e2e suite with the engine (141/141, Chromium only).

Merge danger

Follow-up issues

Quality gate

Lane Result HEAD covered
Docs Updated: plugins-and-packages.mdx, create-your-first-project.mdx cfcfdca
Correctness Pass (round 1 findings: dialog message and docs, fixed in cfcfdca) first commit (before cfcfdca)
Performance Not recorded -
Accessibility Not recorded (the dialog shows a different error text in the same place) -
Security Round 1 re-review: Important (linked package files), fixed in 0bd693d cfcfdca
Style Pass (covered by the correctness reviewer) first commit

Last round 0bd693d: producer red→green, not re-reviewed.

…d folder

The registry RPCs that change a project (restore, install, update and
remove packages; install and uninstall project plugins) ran in
restricted mode too: a cloned project could have Restore packages
follow a link out of it. They now call assertTrusted, as the other
trust-gated RPCs do. Before a package change they also refuse a
symbolic link as nf_modules, one of its entries or a scope's entry,
and before a project plugin change one on the way to its folder
(.nanoforge, plugins, scope, entry). Listing the packages and
user-scope plugins stay open.

The editor still ships @nanoforge-dev/registry 3.0.1, which follows
those links: these checks fix it here. The same nf_modules check in
the registry lib (CLI branch fix/registry-safety) is defence in depth
until the catalog moves to the released version.

Closes #248
The Packages dialog turned every FORBIDDEN into "Packages can only be
installed in a local editor.", which is wrong in a restricted folder
now that package changes need a trusted folder. It shows the server's
message, which names the right reason in a hosted editor and in an
untrusted folder. The docs say that package and project plugin
changes need a trusted folder.

Refs #248
Registry 3.0.1 reads nanoforge.packages.json and its lock through a
symbolic link, and writes tsconfig.json through one, which copies JSON
from outside the project in and writes outside it. The changing package
RPCs now refuse a link as any of these three files, next to the
nf_modules check.

Refs #248
@Exeloo
Exeloo requested a review from Tchips46 as a code owner November 29, 2026 11:19
@github-actions github-actions Bot added documentation Improvements or additions to documentation apps:editor Related to Editor app packages:server-core Related to Server core package plugins:packages Related to Packages plugin labels Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps:editor Related to Editor app documentation Improvements or additions to documentation packages:server-core Related to Server core package plugins:packages Related to Packages plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A symlink in nf_modules lets Restore packages delete files outside the project

1 participant