Skip to content

fix(speech): avoid system tar for Windows model extraction - #9571

Closed
boris-papevis wants to merge 2 commits into
stablyai:mainfrom
boris-papevis:fix/windows-speech-model-extraction-compact
Closed

boris-papevis wants to merge 2 commits into
stablyai:mainfrom
boris-papevis:fix/windows-speech-model-extraction-compact

Conversation

@boris-papevis

@boris-papevis boris-papevis commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On Windows, extract .tar.bz2 speech models in a worker thread instead of calling C:\Windows\System32\tar.exe.

The Windows bsdtar on the affected system did not finish extracting the Parakeet archive before Orca's 10-minute timeout. The streaming JavaScript extractor completed the same archive in about 113 seconds without blocking Electron's main thread.

macOS and Linux continue to use the existing system tar path.

Related issue: #9231

Screenshots

No visual change.

Testing

  • pnpm lint
    • The changed files pass oxlint.
    • The repository-wide command stops on existing switch-exhaustiveness errors in src/main/daemon/daemon-server.ts and src/renderer/src/components/skills/skill-freshness-group.tsx.
  • pnpm typecheck
  • pnpm test
    • The focused speech-model suite passes: 12 tests.
    • The full Windows suite has unrelated platform and baseline failures.
  • pnpm build
  • Added tests for successful .tar.bz2 extraction, path traversal rejection, and link rejection

A built-worker smoke test also extracted a real .tar.bz2 fixture from out/main/speech-model-archive-worker.js.

AI Review Report

The review checked Windows, macOS, and Linux behavior; Electron worker packaging; local and SSH compatibility; agent and integration compatibility; performance; cancellation cleanup; and archive security.

The implementation changes only the Windows extraction path. macOS and Linux retain their current tar command. Speech models live in Orca's local application cache, so remote repositories and SSH worktrees do not use this path. The change does not affect CLI agents, Git providers, integrations, shortcuts, labels, or UI behavior.

The review identified two main risks:

  • JavaScript bzip2 decompression could block Electron's main thread. The extractor runs in a worker thread.
  • Archive entries could escape the model directory or create links. The extractor rejects absolute paths, .. traversal, symbolic links, hard links, and unsupported entry types.

Cancellation terminates the worker before ModelManager removes partial files.

Security Audit

Orca verifies the downloaded archive against its catalog SHA-256 before extraction.

The extractor also:

  • rejects POSIX and Windows absolute paths
  • rejects path traversal after stripping the archive wrapper directory
  • rejects symbolic links, hard links, and special entries
  • avoids shell command construction on Windows
  • accepts archive and destination paths only through internal worker data

tar and unbzip2-stream are bundled into the worker, so the packaged application does not resolve them from an external runtime directory. This change does not handle credentials, authentication data, secrets, or external IPC.

Notes

Windows uses the worker-based extractor. macOS and Linux keep the existing system tar implementation.

No remote, SSH, agent, integration, Git-provider, or UI behavior changes.

X: No account

@boris-papevis
boris-papevis marked this pull request as ready for review July 20, 2026 14:07
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 14ffdf60-31a2-4b09-a64d-76bfffac1283

📥 Commits

Reviewing files that changed from the base of the PR and between bea8c6bf34454ff1bb9ba3bde2b180ec2cd6253e and 22f0ae6.

📒 Files selected for processing (1)
  • electron.vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • electron.vite.config.ts

📝 Walkthrough

Walkthrough

Adds secure tar.bz2 speech-model archive extraction through a worker thread, including path and entry-type validation. Model downloads now pass an AbortSignal and delegate Windows extraction to the worker. Runtime dependencies, TypeScript typings, and main-build bundling configuration are updated, with tests covering successful extraction, traversal rejection, unsupported links, and abort polling behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the main change: switching Windows speech model extraction away from system tar.
Description check ✅ Passed All required sections are present and sufficiently filled, including summary, testing, AI review, security audit, screenshots, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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 (2)
src/main/speech/speech-model-archive-worker.ts (2)

8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a comment explaining the entry type constraints.

As per coding guidelines, please add a concise comment explaining why this constraint exists.

// Why: prevent symlinks and hardlinks from being used as a directory traversal or arbitrary write primitive.
const ALLOWED_ENTRY_TYPES = new Set(['File', 'OldFile', 'Directory'])
💡 Proposed change
+// Why: prevent symlinks and hardlinks from being used as a directory traversal or arbitrary write primitive.
 const ALLOWED_ENTRY_TYPES = new Set(['File', 'OldFile', 'Directory'])

Source: Coding guidelines


10-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a comment explaining the stripped path logic.

As per coding guidelines, please add a concise comment explaining why the path constraint uses a stripped path.

// Why: tar is configured with strip: 1, so we must validate the path exactly as it will be written after the first directory segment is removed.
💡 Proposed change
 function assertSafeEntry(path: string, type: string): void {
   const normalized = path.replaceAll('\\', '/')
+  // Why: tar is configured with strip: 1, so we must validate the path exactly as it will be written after the first directory segment is removed.
   const stripped = normalized.split('/').slice(1).join('/')

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a2c0c7b2-9ce3-4fda-a800-641206a29c98

📥 Commits

Reviewing files that changed from the base of the PR and between d9d939a and f9d453ce45f723929675839f41998c552e5392f9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • electron.vite.config.ts
  • package.json
  • src/main/speech/model-manager.test.ts
  • src/main/speech/model-manager.ts
  • src/main/speech/speech-model-archive-worker.test.ts
  • src/main/speech/speech-model-archive-worker.ts

@boris-papevis
boris-papevis force-pushed the fix/windows-speech-model-extraction-compact branch from bea8c6b to 22f0ae6 Compare July 26, 2026 09:37
@nwparker

Copy link
Copy Markdown
Contributor

thanks @boris-papevis for brining attention here ! To avoid the extra dep I merged #10735

LMK if it has any issues

@nwparker nwparker closed this Jul 26, 2026
@boris-papevis
boris-papevis deleted the fix/windows-speech-model-extraction-compact branch July 26, 2026 22:03
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.

4 participants