Repository navigation
fix: supervise external archive decoders and bound staging resources - #186
Merged
Merged
Conversation
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This was referenced Nov 22, 2026
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…imits Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…tion Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Security re-review and corrective follow-up for #76. This PR builds on the ZIP budget from #179 and archive metadata preflight from #183.
Changes
7za,7z, andunrarwith argument-arrayproc_open, periodic staging-space/entry checks, and a configurable wall-clock timeout.exec()archive listings with bounded-memory, deadline-controlled subprocess capture (16 MiB of listing output, 20-second deadline).setsidand POSIX APIs are available, supervise a separate process group and terminate remaining children, including after the immediate decoder exits.RarEntry::extract()calls with app-controlled streams, cumulative quota checks, per-entry byte limits, a wall-clock deadline between reads, and CRC32 verification.Architecture and testability
ExtractionServiceis now a compact, backwards-compatible facade exposing the sameextractZip(),extractRar()andextractOther()signatures.ZipExtractor,PhpRarExtractorandCliArchiveExtractor. All preserve the previous parser selection, external commands and application-level errors.ArchiveSafetyValidatorcentralizes path and special-file validation.ExtractionLimitscentralizes configuration and available-space budgets.BoundedStreamCopieris shared by ZIP and PHP RAR to enforce cumulative byte budgets, optional declared-size/deadline checks and CRC32 verification. It retains ZIP overwrite versus RAR exclusive-create behavior.ResourceLimitedProcess,DecoderProcessandStagingBudgetInspectorremain independently testable; no new runtime dependency, background service or additional filesystem pass per poll was introduced.Verification
040d58d8: 26 checks passed, 3 checks intentionally skipped, no failures or pending checks. This includes PHPUnit for PHP 8.3–8.5, Psalm/static analysis, syntax/style checks, release packaging, and Nextcloud 33/34/35 Playwright integration. The tests do not constitute a kernel-level sandbox verification or an integration run with the optional PHPrarextension installed.Important security limits
This remains best-effort resource supervision, not a strict security sandbox. Polling can allow short-lived resource overruns, and archive metadata checks cannot eliminate every time-of-check/time-of-use window. Isolated process groups depend on host facilities. Deployments processing hostile archives still need operating-system-enforced storage/resource isolation. The PHP
rarextension streaming implementation needs integration testing on a system with that extension installed; its C-level read operations cannot be preempted by a PHP deadline during an individual blocking read.The PR must not be treated as automatically resolving the entire security issue. No issues or releases were changed, and no merge is requested as part of this update.