Repository navigation
fix(plugins): contain lifecycle paths derived from metadata - #2781
Conversation
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Visible behavior lacks evidence matching the user-facing effects. The linked page is described as covering internal path checks; it should also show:
Suggested fix: No diff; add the matching before-and-after evidence to the linked page. Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Quick104
left a comment
There was a problem hiding this comment.
Review of 68524c6. The fix is right and needed: on base, a stored plugin ID of .. makes a proxy node's archive cache write outside its root and then prune directories under the root's parent. I reproduced that on ed40fa20f with a temporary-directory test, and it is refused on this head at manifest validation. Valid first-party IDs and versions (silo.tmdb, silo.requests.arr, 1.2.26, 1.0.0+build.7) and the builtin row keep their paths.
The four findings below are low severity. I'm fixing all of them in commits on this branch, so there's no need to change anything yourself. A summary with the scores follows once the fixes are pushed and verified.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Suggested line: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
Review summaryReviewed head: 4c38249 (rerun of /silo review; the first pass reviewed f338071). The branch was rebased onto main, so earlier commit IDs changed. The change fixes a real defect at the right place. On base, uploads with plugin ID Addressed in this pass
End-to-end run through the admin APIThis was the open condition from the first pass. It ran on a local server against a throwaway Postgres database, not a sandbox. The same database and plugin directory went through three builds. Base admitted the A replacement package naming a different plugin ID can't be sent through the admin API. Uploads look up the existing row by the package's own ID, and catalog installs refuse a mismatched binary earlier in Remaining for the maintainers
Verification
Validated featuresNone reached. No case on the plugin tasks (#1224, #1225) or node tasks (#1177, #1178) is recorded as passed. Valid identities keep their install, update, uninstall and proxy cache paths. The PR body now says Other checks
VerdictFit: 8/10 · Readiness: 9/10 — conditional (assuming CI is green) Fit: it closes a path-traversal hole in the package that owns plugin installs, with no new setting or API surface. Only admins and a trusted catalog can supply the bad input, so this is hardening, and it adds error handling to six read paths for rows that admission now blocks; that holds the score at 8. Readiness: the defect and the list regression are both shown live and by tests that fail without their fixes, and the end-to-end condition is met. The verdict follows the lower score. Posted by Claude Code ( |
Quick104
left a comment
There was a problem hiding this comment.
Review of f338071, including the end-to-end run through the admin API that the last summary left open. Four findings below. I'm fixing all four in commits on this branch, so there's no need to change anything yourself.
Posted by Claude Code (claude-opus-5-5) running /silo review for the PR author.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Implemented with Codex in T3 Code (gpt-6.1-sol).
Uninstalling a row whose stored identity is invalid deleted the row and then returned an error, so the handler took its failed-delete branch: it tried to restart the deleted installation, skipped the lifecycle refresh and answered 500. The release directory is always the install-* directory the host created, so remove it for every identity, as before. A replacement package that names another plugin is now a package error (422) rather than an unclassified 500. Replace the test-only database and filesystem seams with a temporary-directory regression test at the archive cache boundary. It fails on the parent commit, where a stored ".." plugin ID rehydrates beside the cache root and prunes directories under its parent. Pruning keeps one guard: the keep directory must be the release LocalInstallPath derived. Co-Authored-By: Claude Opus 5.5 <[email protected]>
78db724 removed the identity check before uninstall and replacement cleanup. A legacy-layout row (<base>/<id>/<version>/plugin, no install-* directory) with plugin ID and version ".." makes the release directory the grandparent of the plugin root, so the unguarded RemoveAll could delete it. Check the identity again, and also refuse a path with no release directory. When the check refuses, log the installation and leave its files in place, but let Delete succeed: the row is gone, so the handler finishes the uninstall, runs the lifecycle refresh and answers 204. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A row admitted before the identity check failed every manifest read, so the admin installation list and the user plugin settings list answered 500 and the admin could not reach the row to uninstall it. The identity error now wraps ErrInvalidPluginIdentity: the admin list shows the row without manifest fields and the user list skips it. Compute the install path only where a running client needs it, so a lazy RPC to such a row reaches start, which records why it failed. List the two database-backed tests in db-contracts.txt so CI runs them, and describe in the admin API doc what clients see for such a row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…inary Main's replaceBinary takes the manifest JSON (#2502); after rebasing onto main the replacement identity test needs the extra argument to build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
37ce703 to
4c38249
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8dcae864-dad0-40f8-b9ec-971998affadd
Files selected for processing: 10-
docs/admin-api.mdinternal/api/handlers/plugins.gointernal/api/handlers/plugins_builtin_test.gointernal/plugins/archive_cache.gointernal/plugins/installation.gointernal/plugins/installation_paths.gointernal/plugins/installation_paths_test.gointernal/plugins/installer.gointernal/plugins/service.goscripts/ci/db-contracts.txt
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
| @@ -1170,6 +1170,12 @@ func (h *PluginHandler) ListUserPluginSettings(ctx context.Context) ([]PluginUse | |||
| continue | |||
| } | |||
| manifest, err := plugins.LoadManifestFile(plugins.InstalledManifestPath(installation.InstallPath)) | |||
| if errors.Is(err, plugins.ErrInvalidPluginIdentity) { | |||
There was a problem hiding this comment.
🔎 Supported by static analysis
-
Script executed:
sed -n '1150,1200p' internal/api/handlers/plugins.go rg -n 'ErrInvalidPluginIdentity|func \(s \*Service\) (readInstalledManifest|ensureLoadedInstallation|localInstallPath|LoadInstalledManifest)' internal/plugins sed -n '76,150p' internal/plugins/archive_cache.go sed -n '1105,1150p' internal/plugins/service.go
Repository: Silo-Server/silo-server
Length of output: 7954
Script executed:
set -eu printf '%s\n' '--- handler ---' nl -ba internal/api/handlers/plugins.go | sed -n '1168,1198p' printf '%s\n' '--- manifest/path helpers ---' nl -ba internal/plugins/manifest.go | sed -n '1,180p' nl -ba internal/plugins/installation_paths.go | sed -n '1,100p' printf '%s\n' '--- service path and manifest loaders ---' nl -ba internal/plugins/service.go | sed -n '590,635p;1105,1150p' printf '%s\n' '--- archive cache ensure path ---' nl -ba internal/plugins/archive_cache.go | sed -n '105,180p'
Repository: Silo-Server/silo-server
Length of output: 18329
Validate the stored identity before reading the manifest.
ListUserPluginSettings calls plugins.LoadManifestFile directly with installation.InstallPath. It does not use the service path that validates PluginID and Version. For an enabled legacy installation with Version == ".." and a missing manifest, the call can return a file-not-found error. The handler then returns HTTP 500 instead of skipping the invalid installation.
The cache and no-cache service paths validate the identity before reading the manifest. ArchiveCache.ensure wraps that validation error with %w, so errors.Is still detects plugins.ErrInvalidPluginIdentity. Apply the same validation before the handler’s direct read and skip rows with invalid stored identities.
There was a problem hiding this comment.
🧹 Nitpick comments: 1
internal/api/handlers/plugins_invalid_identity_db_test.go: 1
83-86:Trivial · Maintainability & Code Quality · Quick win Assert that the user settings list omits the invalid installation.
The test checks only the HTTP 200 status. A response that includes the seeded
legacyIDwould pass. The test comment and the PR both state that this list leaves the row out. Decode the response and assert that the ID is absent.🧪 Suggested test change
rec = httptest.NewRecorder() h.HandleListUserPluginSettings(rec, httptest.NewRequest(http.MethodGet, "/api/v1/settings/plugins", nil)) if rec.Code != http.StatusOK { t.Fatalf("user settings list status = %d, want 200; body=%s", rec.Code, rec.Body.String()) } + var settings pluginUserSettingsListResponse + if err := json.Unmarshal(rec.Body.Bytes(), &settings); err != nil { + t.Fatalf("decode user settings: %v", err) + } + for _, inst := range settings.Installations { + if inst.ID == legacyID { + t.Errorf("user settings list included invalid installation %d", legacyID) + } + }

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
250b8961-55ad-4e33-b061-d005c299dad3
Files selected for processing: 9-
docs/admin-api.mdinternal/api/handlers/plugins.gointernal/api/handlers/plugins_invalid_identity_db_test.gointernal/plugins/archive_cache_test.gointernal/plugins/installation.gointernal/plugins/installation_paths_test.gointernal/plugins/installer.gointernal/plugins/service.goscripts/ci/db-contracts.txt
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
Problem
Closes #2779
Related issue: N/A
Validation tasks: none
Plugin metadata could select install and cache paths outside the root deriving them. This adds host checks at admission, installation, cache loading and pruning so invalid identity components cannot reach those filesystem operations.
Approach
Keep the existing identity mapping and SDK contract. Check every newly derived path for strict relative containment while preserving valid host-written stored paths, including legacy layouts and roots from earlier configurations or other replicas.
Invalid stored identities fail before cache reads. Such a row still appears in the admin installation list, without manifest fields, and the user settings list leaves it out, so one bad row doesn't fail either list. Uninstall and replacement cleanup leave the files of a row whose stored identity is refused, log it, and still succeed, so an uninstall removes the row and answers 204. A replacement that names another plugin ID is a package error (422). No configuration keys, sources, migrations, API schemas or client changes are needed. The existing manual procedures remain accurate.
Validation
ed40fa20f: a proxy cache rehydrating a stored archive with plugin ID..wrote beside its root, deleted a directory under the root's parent and pruned another plugin's cached release.TestArchiveCacheKeepsDotIdentitiesInsideItsRootcovers this in a temporary directory; it fails on base and passes on this head...and version..answer 201 and install beside and directly in the plugin root. On this head, with those rows present: both plugin lists answer 200 (the admin list includes the rows), the first-party catalog plugins install on first start, a valid upload installs and its update removes the old release,1.0.0+build.7installs, uploads with..answer 422, and deleting each bad row answers 204 and leaves its files.silo.tmdb1.2.26 installing from its catalog release, updating, rehydrating under a proxy-cache root and uninstalling on base and head.TestPluginListsKeepWorkingWithAnInvalidIdentityRowDBfails onf338071ac, where both lists answered 500, and passes now. It andTestInstallationStoreDeleteRemovesOnlyTrustedFilesare listed inscripts/ci/db-contracts.txtand pass under thedbpinsrunner.TestPluginPathReplacementRejectsDifferentPluginis that guard's only coverage.go test -race ./internal/plugins/ ./internal/pluginhost/, the plugin tests ininternal/apiv2andinternal/api/handlers, all test packages compiled,make lint-changed,make verify-local-pathsand a Windows cross-build pass on the branch rebased onto main.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-2779/
Risks
Containment is lexical against metadata. Local roots and host-written database paths are trusted; this does not protect against hostile local writers or symlink races. Native plugin execution remains unsandboxed. Existing rows with invalid identity components stop loading and show in the admin list without manifest fields; uninstalling one removes its row and leaves its files for the operator. Plugin IDs that differ only in
/,\,:or@still share one proxy cache directory (#2800, not changed here).Checklist
AI Disclosure
delegate_taskfor independent approach and background reviews; Modern Go Guidelines CLI for Go guidance.gpt-6.1-solimplemented and reviewed;claude-opus-5-5reviewed the approach and the final PR./siloreview in Claude Code (claude-opus-5-5, with Claude finder subagents and a Codexgpt-6.1-solcross-provider round) found four low-severity issues and fixed them in 78db724 and f338071; an automated security check caught a guard 78db724 had dropped, which f338071 restores. A second/siloreview (Claude Code,claude-opus-5-5, Claude finder subagents and a Codexgpt-6.1-solcross-provider round) ran the admin API end to end, found that a legacy row failed both plugin lists, and fixed that and three smaller findings in e3d015b; the branch was rebased onto main, and 4c38249 updates a test call for main'sreplaceBinarysignature.68524c6bafound no verified C48 findings and posted nothing. It read the production diff and owning paths, read the API contract in part, and did not independently read SDK or canonical/fit records. Configured model/effort selections do not independently attest effective provider execution.Note
Contain plugin lifecycle paths derived from metadata identities
plugins.pluginPathSegmentandplugins.pluginPathUnderin installation_paths.go. Plugin IDs and versions that sanitize to empty, dot, or dot-dot are rejected withplugins.ErrInvalidPluginIdentity, and derived paths must stay strictly below the configured root.plugins.ArchiveCache.LocalInstallPathnow returns an error, and service.go propagates it through startup, manifest loading, and asset resolution instead of using rawInstallPath.plugins.removeInstallationFilescentralizes file deletion; legacy rows with invalid identities have their database rows removed but files are left in place, and the user settings list in plugins.go skips such rows instead of failing.Macroscope summarized 37ce703.