Skip to content

fix(plugins): bound package downloads and ZIP expansion - #5634

Open
Tobechukwu-Njoku wants to merge 1 commit into
Silo-Server:mainfrom
Tobechukwu-Njoku:fix/plugin-ingestion-bounds
Open

Tobechukwu-Njoku wants to merge 1 commit into
Silo-Server:mainfrom
Tobechukwu-Njoku:fix/plugin-ingestion-bounds

Conversation

@Tobechukwu-Njoku

@Tobechukwu-Njoku Tobechukwu-Njoku commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Tobechukwu Njoku

Problem

Closes #2780

Validation tasks: #1224 C1, #1225 C1

Other clients: N/A (plugin installation is a web admin and server operation)

A plugin download can consume server memory as long as its host keeps sending data. ZIP packages can also expand far beyond their download size. Silo now refuses packages that exceed the ingestion limits and reports which limit they hit.

Approach

Plugin downloads are capped at 256 MiB, matching the upload limit. Checksum files are capped at 1 MiB. ZIP archives can contain up to 4,096 entries, with up to 256 MiB per entry and 512 MiB overall after decompression. Silo checks the ZIP budget on new installs, replacements, and stored-archive recovery.

The update order from #4330 still applies. Silo checks the replacement package before stopping the installed plugin or replacing its recovery archive.

Validation

  • go test ./internal/plugins/ and go vet ./internal/plugins/ pass on c0769abc7, rebased onto current main.
  • The full make test-go run has failures that also occur on main (session sync, thin node, ffprobe/transcode timing). None of them are in the plugin packages.
  • The local linter can't read Go 1.27 export data, so lint relies on CI.

Evidence

Nothing changes on screen unless a package exceeds a limit. In that case the existing install error shows the new message, for example "The download of exceeds the 256 MiB size limit." I checked the change with the focused tests on c0769abc7:

$ go test -count=1 -v -run 'Limit|TooLarge|Bound|Oversize|Expan' ./internal/plugins/
--- PASS: TestPluginDownloadSizeLimit (0.00s)
--- PASS: TestPackageDownloadLimitsUnknownLength (0.00s)
--- PASS: TestPluginArchiveLimits (0.00s)
ok  	github.com/Silo-Server/silo-server/internal/plugins	0.607s

These tests refuse an oversized download, whether or not it declares a Content-Length. They refuse ZIP archives over the entry-count, per-entry and total limits, using synthetic entry metadata so no large archive is inflated. They also check that a normal remote install still succeeds and that a refused replacement leaves the installed plugin running.

Risks

A package above any limit is refused, including a previously stored oversized archive if Silo needs to rehydrate it.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Codex in T3 Code
  • Tool(s): Codex tools, Git, GitHub CLI, Go, and golangci-lint
  • Model(s): gpt-6.2-sol (low effort)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: Claude Code in T3 Code, model Claude Opus 5.5 (claude-opus-5-5, low effort)

Note

Bound plugin package downloads at 256 MiB and ZIP expansion at 4096 entries

  • Adds checkPluginArchiveLimits in archive_cache.go: archives are rejected past 4096 entries, 256 MiB per entry uncompressed, or 512 MiB total uncompressed. Checks run in openPluginArchive before content validation, and in ArchiveCache.rehydrate where oversized stored archives fail without legacy binary-archive recovery.
  • Caps package-resource fetches at 256 MiB and checksum fetches at 1 MiB. Responses with a declared Content-Length over the limit are rejected before the body is read; streaming reads still enforce the limit when no length is declared. Binary downloads default to a 256 MiB limit unless verification is required, in which case the provision limit applies.
  • Oversized downloads and archives surface as package errors that include the specific limit reason.
  • Behavioral Change: archives and downloads exceeding these limits are now rejected as non-transient package errors; a normal archive still installs end-to-end per the new TestInstallerAcceptsNormalPluginArchive.

Macroscope summarized c0769ab.

Co-Authored-By: gpt-6.2-sol <noreply@openai.com>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 30, 2026
@silo-kody

silo-kody Bot commented Nov 30, 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 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Plugin ingestion now limits downloaded package, binary, and checksum sizes. ZIP processing enforces entry-count and uncompressed-size limits. Limit failures return package errors, and tests cover rejection boundaries and successful remote installation.

Changes: Plugin ingestion limits

Layer / File(s) Summary
Bound downloaded resources
internal/plugins/package_error.go, internal/plugins/installer.go, internal/plugins/catalog_service.go, internal/plugins/ingestion_limits_test.go
Package downloads are limited to 256 MiB, and checksum downloads to 1 MiB. Binary downloads use the configured plugin or provision limit. Declared response sizes are rejected before reading when they exceed the limit. Tests cover oversized responses and unknown-length responses at and above the limit.
Bound archive expansion and installation
internal/plugins/archive_cache.go, internal/plugins/installer.go, internal/plugins/ingestion_limits_test.go, internal/plugins/package_error_test.go
ZIP archives are limited to 4,096 entries, 256 MiB uncompressed per entry, and 512 MiB total. Installer paths return archive-limit errors as package errors. Stored-archive recovery stops on this error instead of attempting legacy-binary recovery. Tests cover archive limits and successful installation of a normal archive.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PluginInstaller
  participant PackageFetcher
  participant ArchiveReader
  PluginInstaller->>PackageFetcher: Request plugin package with byte limit
  PackageFetcher-->>PluginInstaller: Return bounded package bytes
  PluginInstaller->>ArchiveReader: Open package archive
  ArchiveReader-->>PluginInstaller: Return archive or limit error
Loading

Possibly related PRs

  • Silo-Server/silo-server#4330: This PR changes the same plugin replacement path and establishes the prepare-before-stop flow referenced by this change.

Suggested reviewers: quick104, rhainland

Merge Risk: Minimal · up to c0769

Plugin downloads and ZIP expansion are now bounded, and oversized packages are refused with a clear error. No concrete merge-blocking defect was found in this review.

Security architecture risk: Low · up to c0769

The new limits protect the server from oversized downloads and ZIP expansion. An oversized replacement is rejected before it disrupts the installed copy, but a previously accepted archive that exceeds the new limits can no longer restore its plugin on a node without a usable local copy.

Retained concerns

  • Trivial · reliability · observed: Previously accepted archives that exceed the new ZIP limits can no longer rebuild the local plugin cache. On a fresh node or after cache loss, the affected plugin cannot launch and its configuration restore can fail at manifest loading. Retrying with the same archive does not resolve the failure. The rejection does not delete the stored archive or clear existing local files.

View findings in the submitted review

Security review details

Security Blast Radius

  • inferred — A package host selected through the existing installation or update flow controls the response bytes reaching the server. The change reduces resource exposure per fetch and per archive; it does not establish an aggregate server memory budget across concurrent operations.

Trust Boundaries and Controls

  • observed — The byte cap runs at the HTTP response boundary: an oversized declared length is rejected immediately, and a bounded read enforces the cap even without a usable length header. This adds a resource check without changing the existing request transport or the binary checksum comparison.

Resilience and Maintainability Implications

  • observed — A rehydration refusal is contained during startup: preload logs the affected plugin and continues. A subsequent launch still returns the recovery error before starting the plugin process.

Hardening Proposals

  • proposed — Before rollout, check stored archives against the new ZIP limits without extracting entries. Replace any incompatible archives with supported packages while usable local copies are still available, then verify recovery on a clean node without bypassing the limits.
Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#2780] Implemented at head: (1) package_error.go caps plugin package downloads at maxPluginDownloadBytes (256 MiB) through fetchPackageResource, and fetchPackageResourceWithIdle rejects a declared Co… Confirm whether the catalog JSON fetch path calls fetchPackageResource or fetchPackageResourceWithIdle with a byte limit at head, and show a test or code path that bounds catalog JSON bytes. Confirm that the budget is documented and that st…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title 'fix(plugins): bound package downloads and ZIP expansion' matches the main change: plugin download caps (256 MiB), checksum cap (1 MiB), and ZIP entry, per-entry and total expansion limits a…
Description check Passed The description explains the problem (unbounded plugin downloads and ZIP expansion), the approach (256 MiB download cap, 1 MiB checksum cap, 4,096 entries, 256 MiB per entry, 512 MiB total), validatio…
Out of Scope Changes check Passed All changed hunks in package_error.go, catalog_service.go, archive_cache.go, installer.go and their tests implement the ingestion byte and ZIP limits named in #2780. The new constants and helpers (max…
Full details: Title check

Explanation

The title 'fix(plugins): bound package downloads and ZIP expansion' matches the main change: plugin download caps (256 MiB), checksum cap (1 MiB), and ZIP entry, per-entry and total expansion limits across internal/plugins. It is concise and specific, and it does not describe unrelated work.

Full details: Description check

Explanation

The description explains the problem (unbounded plugin downloads and ZIP expansion), the approach (256 MiB download cap, 1 MiB checksum cap, 4,096 entries, 256 MiB per entry, 512 MiB total), validation steps, and the risk of refusing oversized stored archives. It is directly related to the changeset.

Full details: Out of Scope Changes check

Explanation

All changed hunks in package_error.go, catalog_service.go, archive_cache.go, installer.go and their tests implement the ingestion byte and ZIP limits named in #2780. The new constants and helpers (maxPluginDownloadBytes, errPluginArchiveLimit, fetchPackageResourceLimited use) are used only by this limit logic. No unrelated plugin behavior, format, sandbox or playback change appears in the summary or the inspected hunks.

Full details: Linked Issues check

Explanation

[#2780] Implemented at head: (1) package_error.go caps plugin package downloads at maxPluginDownloadBytes (256 MiB) through fetchPackageResource, and fetchPackageResourceWithIdle rejects a declared Content-Length above the limit before reading the body. (2) catalog_service.go caps checksum files at 1 MiB and returns a PackageError naming the limit. (3) archive_cache.go openPluginArchive checks ZIP entry count (4,096), per-entry size (256 MiB) and total size (512 MiB) before reading entries, and rehydrate returns on errPluginArchiveLimit. (4) installer.go converts the archive-limit error into a package error and applies maxPluginDownloadBytes or maxProvisionBinaryBytes in downloadBinaryChecked. (5) ingestion_limits_test.go and package_error_test.go cover oversize downloads with and without Content-Length, ZIP limits, a normal remote install, and the too-many-entries case. Unresolved: the issue names catalog JSON responses as unbounded. The diff does not change the catalog JSON fetch. The reviewed diff does not show whether that fetch uses the capped helper or the uncapped path, so the catalog JSON bound is not established. The issue also asks for a documented resource budget and explicit startup and scheduled-check reporting. The diff shows no documentation change, and scheduled-check reporting is not shown beyond the rehydrate change. The PR description reports preservation of the running plugin on a refused replacement, supported by a test. Limits are supplied, as the issue allows a maintainer decision on them.

Resolution

Confirm whether the catalog JSON fetch path calls fetchPackageResource or fetchPackageResourceWithIdle with a byte limit at head, and show a test or code path that bounds catalog JSON bytes. Confirm that the budget is documented and that startup and scheduled checks report bounded-work failures explicitly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added bug Something isn't working priority: P2 Limited scope, workaround exists, or polish labels Nov 30, 2026

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

Architecture findings (1)

Advisory architecture findings (1)

  • Trivial — Previously accepted archives that exceed the new ZIP limits can no longer rebuild the local plugin cache. On a fresh node or after cache loss, the affected plugin cannot launch and its configuration restore can fail at manifest loading. Retrying with the same archive does not resolve the failure. The rejection does not delete the stored archive or clear existing local files.
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: c9a7af00-e007-4fed-829f-be8785495454
Commits

Reviewing files that changed from the base of the PR and between bc17dc0 and c0769ab.

Files selected for processing: 6

  • internal/plugins/archive_cache.go
  • internal/plugins/catalog_service.go
  • internal/plugins/ingestion_limits_test.go
  • internal/plugins/installer.go
  • internal/plugins/package_error.go
  • internal/plugins/package_error_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Plugin ingestion has no response-byte or expanded-archive bounds

1 participant