Skip to content

fix(plugins): contain lifecycle paths derived from metadata - #2781

Merged
Quick104 merged 5 commits into
mainfrom
fix/plugin-path-containment
Oct 26, 2026
Merged

Quick104 merged 5 commits into
mainfrom
fix/plugin-path-containment

Conversation

@Quick104

@Quick104 Quick104 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Reproduced the defect on base 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. TestArchiveCacheKeepsDotIdentitiesInsideItsRoot covers this in a temporary directory; it fails on base and passes on this head.
  • Ran three local builds through the admin API against one throwaway Postgres database and plugin directory. On base, uploads with plugin ID .. 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.7 installs, uploads with .. answer 422, and deleting each bad row answers 204 and leaves its files.
  • An earlier run of the real installer, installation store and archive cache against a throwaway database showed silo.tmdb 1.2.26 installing from its catalog release, updating, rehydrating under a proxy-cache root and uninstalling on base and head.
  • TestPluginListsKeepWorkingWithAnInvalidIdentityRowDB fails on f338071ac, where both lists answered 500, and passes now. It and TestInstallationStoreDeleteRemovesOnlyTrustedFiles are listed in scripts/ci/db-contracts.txt and pass under the dbpins runner.
  • A replacement package naming a different plugin ID can't be sent through the admin API (uploads look up the row by the package's own ID, and catalog installs refuse a mismatched binary first), so TestPluginPathReplacementRejectsDifferentPlugin is that guard's only coverage.
  • go test -race ./internal/plugins/ ./internal/pluginhost/, the plugin tests in internal/apiv2 and internal/api/handlers, all test packages compiled, make lint-changed, make verify-local-paths and a Windows cross-build pass on the branch rebased onto main.
  • Not tested: Windows filesystem behavior, a running multi-node cluster, and the web admin page itself (the lists were checked through the API).

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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section documents the internal path checks; no UI layout or ordinary valid-identity flow changes.

AI Disclosure

  • Harness: Codex in T3 Code; Claude Code in T3 Code for cross-provider review.
  • Tool(s): Codex implementation and native review agents; T3 delegate_task for independent approach and background reviews; Modern Go Guidelines CLI for Go guidance.
  • Model(s): gpt-6.1-sol implemented and reviewed; claude-opus-5-5 reviewed the approach and the final PR.
  • Involvement: AI-assisted; implementation and offline verification performed by agents under maintainer authorization.
  • Review: a /silo review in Claude Code (claude-opus-5-5, with Claude finder subagents and a Codex gpt-6.1-sol cross-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 /silo review (Claude Code, claude-opus-5-5, Claude finder subagents and a Codex gpt-6.1-sol cross-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's replaceBinary signature.
  • Adversarial review: Two Claude approach rounds led to the narrow identity guard, preservation of valid stored paths and distinct replacement/uninstall cleanup semantics. The rounds had recorded context omissions and unobservable effective effort. Three Codex source reviewers found no candidates across the assigned correctness, contract, failure, cleanup and convention angles; two separately read the full API contract. Validation mapping was unavailable. The final Codex sweep found no candidates. Claude background review at 68524c6ba found 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

  • Adds plugins.pluginPathSegment and plugins.pluginPathUnder in installation_paths.go. Plugin IDs and versions that sanitize to empty, dot, or dot-dot are rejected with plugins.ErrInvalidPluginIdentity, and derived paths must stay strictly below the configured root.
  • plugins.ArchiveCache.LocalInstallPath now returns an error, and service.go propagates it through startup, manifest loading, and asset resolution instead of using raw InstallPath.
  • Replacement operations in installer.go reject packages whose plugin ID differs from the existing installation, returning a package error before any filesystem or store mutation.
  • plugins.removeInstallationFiles centralizes 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.
  • Behavioral Change: manifests with dot/dot-dot identities now fail validation; invalid-identity legacy rows remain in the admin installation list but are omitted from user settings; replacement packages naming a different plugin are rejected. Documented in admin-api.md.

Macroscope summarized 37ce703.

@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 20, 2026
@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P2 Limited scope, workaround exists, or polish labels Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Plugin identity validation now rejects unsafe path segments and mismatched replacement IDs. Installation, cache, cleanup, and service operations use validated paths. API listings handle legacy installations with invalid identities.

Changes: Plugin lifecycle paths

Layer / File(s) Summary
Identity validation and path construction
internal/plugins/installation_paths.go, internal/plugins/manifest.go, internal/plugins/installation_paths_test.go
Plugin IDs and versions are rejected when sanitized segments are empty, . or ... Derived paths are checked against the configured root, and manifest validation uses the identity checks.
Installation, replacement, and deletion
internal/plugins/installer.go, internal/plugins/installation.go, internal/plugins/installation_paths.go, internal/plugins/installation_paths_test.go, docs/admin-api.md
Install and replacement flows use validated roots. Replacement packages must retain the installation’s plugin ID. Cleanup removes trusted release directories and leaves files in place when identity or layout checks fail.
Archive cache resolution and pruning
internal/plugins/archive_cache.go, internal/plugins/archive_cache_test.go, internal/plugins/installation_paths_test.go
Cache path resolution returns errors for invalid installations, archive identity must match the installation, and pruning uses the resolved installation directory.
Service path resolution
internal/plugins/service.go, internal/plugins/service_connection.go
Service operations resolve the local binary path before starting plugins, resolving assets, or loading installed manifests, and propagate path-resolution errors.
Invalid identity handling in API listings
internal/api/handlers/plugins.go, internal/api/handlers/plugins_invalid_identity_db_test.go, scripts/ci/db-contracts.txt, docs/admin-api.md
User settings omit installations with invalid identities. Admin installation responses can include them without manifest fields. Database-backed tests cover both listing endpoints.

Priority: High

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: High

Suggested reviewers: rhainland

Merge Risk: Moderate · up to 4c382

An enabled legacy plugin row with an invalid identity and a missing manifest can still make the entire user settings list fail. Handle that row before merging.

Security architecture risk: Low · up to 4c382

The change narrows metadata-driven filesystem access without establishing a new publicly reachable attack path. Stored installation paths remain trusted for compatibility, and protection against direct database or filesystem tampering has not been established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A corrupted valid-identity stored path can still direct cleanup outside the configured plugin root, bounded by the host process's filesystem permissions. That authority predates this PR; the new cleanup helper restricts it for invalid identities rather than expanding it.

Trust Boundaries and Controls

  • observed — The inspected installation mutation routes remain under acting-admin authorization. The HTTP update request exposes enabled and update_policy, not InstallPath, and deletion accepts an installation ID. These controls counter a direct public path-mutation attack, but do not establish database or host-local writer protections.

Resilience and Maintainability Implications

  • observed — Replacement archive publication still precedes installation-row publication, and cleanup follows the row update. These operations are not made atomic by this PR. The base comparison shows unchanged ordering, so interrupted or failed publication is an existing consistency limitation, not an established new security regression.

Hardening Proposals

  • proposed — Document and verify the database and host write permissions that uphold the trusted stored-path assumption. Any future provenance enforcement should preserve legitimate legacy and cross-replica layouts rather than assuming every stored path belongs beneath the current root.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 12 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: containing plugin lifecycle paths derived from metadata.
Description check Passed The description directly explains the path-containment fix, validation behavior, legacy-row handling, replacement checks, testing, and scope.
Linked Issues check Passed Issue #2779 requires root containment for install, replacement, cache hit, rehydration, and pruning paths. pluginIdentitySegments rejects empty, . and .. components. pluginVersionRoot and `plu…
Out of Scope Changes check Passed The changes stay within issue #2779. Installer, cache, service, store, handler, documentation, and regression-test changes support path containment, safe lifecycle cleanup, or the required invalid-row…
Full details: Linked Issues check

Explanation

Issue #2779 requires root containment for install, replacement, cache hit, rehydration, and pruning paths. pluginIdentitySegments rejects empty, . and .. components. pluginVersionRoot and pluginPathUnder enforce strict lexical descent below the configured root. ArchiveCache.LocalInstallPath validates stored identities before cache access, and pruning validates the retained directory before listing or removing releases. Replacement identity checks run before filesystem or store mutation. Invalid legacy rows remain manageable: list handlers skip only the invalid manifest, and removeInstallationFiles leaves their files in place while row deletion can succeed. The added tests cover identity validation, cache containment, replacement rejection, cleanup, and invalid-row list handling.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2779. Installer, cache, service, store, handler, documentation, and regression-test changes support path containment, safe lifecycle cleanup, or the required invalid-row behavior. The changes preserve existing identity mapping and trusted stored paths. They do not change configuration keys, source ownership, encrypted settings keys, archive-member containment, client schemas, or plugin sandbox scope. Cache-directory collisions covered by #2800 remain outside this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 12 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

Visible behavior lacks evidence matching the user-facing effects. The linked page is described as covering internal path checks; it should also show:

  • internal/plugins/manifest.go: before-and-after captures of the same catalog screen showing an invalid-identity entry removed, plus the install/upload error for that same package.
  • internal/plugins/archive_cache.go and internal/plugins/service.go: an affected installation or plugin-content request before and after an invalid stored identity causes the existing user-facing load/runtime error.
  • internal/plugins/installation.go: before-and-after DELETE response and installation-list state showing the cleanup error after the row is removed for an invalid stored identity.

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 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/plugins/installation_paths.go Resolved
Comment thread internal/plugins/installer.go Resolved
Comment thread docs/admin-api.md Resolved
Comment thread internal/plugins/installation.go Resolved
@silo-triage silo-triage Bot added size/L 200–499 added + deleted lines (all files); change volume, not priority. and removed size/XL 500–999 added + deleted lines (all files); change volume, not priority. labels Oct 20, 2026
@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

Validation tasks: should name affected cases or say none, not “unavailable.” I found #1225 C1/C2, both blocked on build 1258 · 3f171deb. C1’s valid catalog install/update and SHA-256 checks are unchanged: catalog identity/checksum validation already covers them, and valid IDs keep their paths. The new guards affect malformed identities and legacy stored rows, outside C1’s stated steps; C2’s catalog opt-in/tier surface is untouched. The server/provider cases I found (#1224, #1250, #1254 and the linked provider tasks) are Not run, so there is no recorded result to invalidate or unblock.

Suggested line: Validation tasks: none

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104

Quick104 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Review summary

Reviewed 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 .. or version .. install beside or directly in the plugin root, and a proxy node's archive cache that rehydrates such an archive writes beside its root and prunes other plugins' copies. This head refuses those identities at admission and again before any install or cache path is built.

Addressed in this pass

  • Legacy rows failed both plugin lists (medium). A row admitted before this PR with a . or .. identity made GET /api/v2/admin/plugins/installations and GET /api/v2/settings/plugins answer 500 (v1 too), so the admin couldn't see the row to uninstall it. Fixed in e3d015b: the identity error wraps ErrInvalidPluginIdentity, the admin list shows the row without manifest fields, and the user settings list skips it. A new database test fails on f338071 and passes now.
  • New database test never ran in CI (low). TestInstallationStoreDeleteRemovesOnlyTrustedFiles and the new list test are now in scripts/ci/db-contracts.txt.
  • Lazy start lost its failure reason (low). doEnsureClient computes the install path only where a running client needs it again, so a failed lazy start of such a row is recorded for the admin runtime state.
  • Contract text (low). docs/admin-api.md names the rule and says what each list and delete does for such a row.
  • Rebase onto main (would have broken the build on merge). The branch merged cleanly as text, but fix(plugins): install and start plugins whose manifest has fields the server doesn't know #2502 added a parameter to replaceBinary, so this PR's TestPluginPathReplacementRejectsDifferentPlugin didn't compile against main. 4c38249 passes the new argument.

End-to-end run through the admin API

This 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 .. packages (201). The unfixed head answered 500 on both lists while those rows existed. The fixed head lists them, installs a valid package, replaces it with a new version (old release removed), refuses the .. packages with 422, deletes each bad row by ID with 204 while leaving its files, and uninstalls the valid plugin with its files. The first-party catalog plugins installed on every build's first start.

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 checkCatalogIdentity. checkReplacementIdentity is defense in depth, covered by its unit test only.

Remaining for the maintainers

  • Proportionality of the read-path errors: they're mechanical, and the cross-provider round also judged them proportionate. The alternative, checking identities only at admission and under a cache root, would let legacy rows keep loading on the API server while proxy nodes refuse them, a split between nodes I'd avoid.
  • A refused .. upload says "The plugin archive couldn't be read.", the generic message openInstallArchive gives every manifest error. Naming the bad field would need a wider change to that message.
  • [bug] Plugin IDs that differ only in / \ : @ share a proxy cache directory and prune each other #2800 (plugin IDs that differ only in /, \, : or @ share a proxy cache directory) touches the same pruning code and should follow this PR.
  • The plugin SDK's manifest validator still accepts . and .., and no SDK issue exists yet. Adding the rule there would let catalog CI catch it before the server does.
  • From the first pass, not filed: replacing a legacy-layout row at the same version removes the new release's parent directory (same as main), and on shared install storage a replacement removes the old release while another replica may still use it.

Verification

  • TestArchiveCacheKeepsDotIdentitiesInsideItsRoot fails on base ed40fa2 and passes here. TestPluginListsKeepWorkingWithAnInvalidIdentityRowDB fails on f338071 and passes here. Both database tests pass under the dbpins runner.
  • On the rebased branch: go test -race for internal/plugins and internal/pluginhost, the plugin tests in internal/apiv2 and internal/api/handlers, all test packages compiled, make lint-changed, make verify-local-paths, and a Windows cross-build.
  • Not run: a multi-node cluster, Windows filesystem behavior, and the web admin page (the lists were checked through the API).

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2779/

Validated features

None 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 Validation tasks: none.

Other checks

  • User manual: unaffected. The plugins page covers uploading, updating and uninstalling, and says nothing about ID or version rules.
  • Apple, Android and jellycompat: no client-visible change beyond a 422 for malformed packages and a legacy row appearing without manifest fields in the admin list; no follow-up needed.
  • Cross-provider round: Codex (gpt-6.1-sol) independently found the list failure and the CI gap.

Verdict

Fit: 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 (claude-opus-5-5) running /silo review for the PR author.

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/plugins/archive_cache.go Resolved
Comment thread internal/plugins/service.go Resolved
Comment thread docs/admin-api.md Resolved
@silo-triage silo-triage Bot added size/XL 500–999 added + deleted lines (all files); change volume, not priority. and removed size/L 200–499 added + deleted lines (all files); change volume, not priority. labels Oct 26, 2026
@silo-kody

silo-kody Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Quick104 and others added 5 commits October 26, 2026 11:49
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]>
@Quick104
Quick104 force-pushed the fix/plugin-path-containment branch from 37ce703 to 4c38249 Compare October 26, 2026 15:51
@silo-kody

silo-kody Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Commits

Reviewing files that changed from the base of the PR and between 68524c6 and 37ce703.

Files selected for processing: 10
  • docs/admin-api.md
  • internal/api/handlers/plugins.go
  • internal/api/handlers/plugins_builtin_test.go
  • internal/plugins/archive_cache.go
  • internal/plugins/installation.go
  • internal/plugins/installation_paths.go
  • internal/plugins/installation_paths_test.go
  • internal/plugins/installer.go
  • internal/plugins/service.go
  • scripts/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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Stability & Availability · Quick win

🔎 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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 legacyID would 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
Commits

Reviewing files that changed from the base of the PR and between 37ce703 and 4c38249.

Files selected for processing: 9
  • docs/admin-api.md
  • internal/api/handlers/plugins.go
  • internal/api/handlers/plugins_invalid_identity_db_test.go
  • internal/plugins/archive_cache_test.go
  • internal/plugins/installation.go
  • internal/plugins/installation_paths_test.go
  • internal/plugins/installer.go
  • internal/plugins/service.go
  • scripts/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.

@Quick104
Quick104 merged commit 8cbc820 into main Oct 26, 2026
33 checks passed
@Quick104
Quick104 deleted the fix/plugin-path-containment branch October 26, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Plugin lifecycle paths lack root containment checks

1 participant