Skip to content

fix(runtimes): harden staging ownership, download deadlines, and async subprocess waits - #1199

Merged
PyRo1121 merged 1 commit into
mainfrom
fix/runtime-staging-deadlines-async-subproc
Dec 2, 2026
Merged

PyRo1121 merged 1 commit into
mainfrom
fix/runtime-staging-deadlines-async-subproc

Conversation

@PyRo1121

@PyRo1121 PyRo1121 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Addresses the four source-confirmed Rust runtime audit findings on top of main (629b5be8):

  1. Staging ownership across spawn_blocking (src/runtimes/common.rs + all 13 staged runtime installers):
    • Added extract_tar_gz_staged, extract_tar_gz_staged_with_budget, extract_tar_xz_staged, and extract_zip_staged which transfer tempfile::TempDir ownership into tokio::task::spawn_blocking and return Result<tempfile::TempDir>.
    • Cancelling/dropping an async install future can no longer delete the staging directory while blocking extraction is still writing (or leave an orphaned staging directory behind).
  2. Gzip/XZ task outcome reporting on errors (src/runtimes/common.rs):
    • Shared ExtractTaskGuard across gzip, xz, and zip extraction so errors report Outcome::Failed on drop and never report Outcome::Done.
    • Removed the duplicate outer extract_task + unconditional task.finish(Outcome::Done) wrappers in extract_tar_gz_with_budget and extract_tar_xz.
  3. Overall deadlines across redirects and slow artifacts (src/core/http.rs, src/runtimes/common.rs):
    • fetch_public_download_with_options computes a single Instant deadline before the redirect loop and clamps DNS lookup, connect/read, and per-hop timeouts to the remaining budget instead of resetting per hop.
    • stream_runtime_download_to_temp_with_limits enforces an overall wall-clock deadline (DOWNLOAD_OVERALL_TIMEOUT = 20m) across attempts/chunks and fails cleanly on final-attempt low-speed stalls instead of hanging indefinitely.
  4. Blocking subprocess waits off Tokio threads (src/runtimes/tool_artifacts.rs, src/runtimes/erlang.rs, src/runtimes/php.rs):
    • Added tool_artifacts::run_with_timeout_async wrapping tokio::task::spawn_blocking.
    • Updated erlang.rs (run_install_script, smoke_erl) and php.rs (smoke_php_async) to await it instead of blocking Tokio worker threads.

Verification

  • Verified locally in Ubuntu 24.04 WSL (Rust 1.95.0, --no-default-features) with 0 compiler warnings and 370 unit tests passed, 0 failed across core::http, runtimes::common, runtimes::tool_artifacts, runtimes::erlang, runtimes::php, runtimes::github_tool, and all 10 other updated runtime modules.
  • Added 4 focused regression tests:
    • core::http::metadata_limit_tests::fetch_public_download_with_timeout_enforces_overall_deadline_across_redirects
    • runtimes::common::entry_budget_tests::extract_tar_gz_staged_transfers_ownership_and_cleans_up_on_cancel
    • runtimes::common::entry_budget_tests::stream_runtime_download_enforces_overall_deadline_on_trickle
    • runtimes::tool_artifacts::tests::run_with_timeout_async_does_not_block_tokio_worker

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@snyk-io

snyk-io Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@PyRo1121
PyRo1121 force-pushed the fix/runtime-staging-deadlines-async-subproc branch 5 times, most recently from 3b1ba47 to 8d1d749 Compare December 1, 2026 22:59
@PyRo1121
PyRo1121 force-pushed the fix/runtime-staging-deadlines-async-subproc branch from 8d1d749 to 4391b1b Compare December 1, 2026 23:57
@PyRo1121
PyRo1121 merged commit 4888957 into main Dec 2, 2026
66 of 68 checks passed
@PyRo1121
PyRo1121 deleted the fix/runtime-staging-deadlines-async-subproc branch December 2, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants