Skip to content

fix(cli): embed assembly metadata, manifest, and icon in Windows launcher - #23409

Closed
rizub wants to merge 1 commit into
stablyai:mainfrom
rizub:fix/windows-cli-launcher-pe-metadata
Closed

rizub wants to merge 1 commit into
stablyai:mainfrom
rizub:fix/windows-cli-launcher-pe-metadata

Conversation

@rizub

@rizub rizub commented Sep 27, 2026

Copy link
Copy Markdown

ELI5

Give the native Windows CLI launcher binary (orca.exe) standard metadata, an application manifest, and an application icon so Windows security tools and enterprise EDRs recognize it as a legitimate Orca application rather than flagging it as an anonymous malicious file.

What Changed

  • Added native/windows-cli-launcher/app.manifest specifying requestedExecutionLevel level="asInvoker" and Windows OS compatibility GUIDs (Windows 7/8/8.1/10/11).
  • Added standard assembly attributes (AssemblyTitle, AssemblyDescription, AssemblyCompany, AssemblyProduct, AssemblyCopyright, AssemblyVersion, AssemblyFileVersion) to native/windows-cli-launcher/OrcaCliLauncher.cs.
  • Updated config/scripts/build-windows-cli-launcher.mjs to pass /win32manifest and /win32icon to csc.exe when available, and factored the manifest mtime into shouldReuseCompiledWindowsCliLauncher.
  • Added unit test in config/scripts/build-windows-cli-launcher.test.mjs verifying that the compiled binary embeds the expected PE version information.

Why

In enterprise environments with endpoint detection and response (EDR) software (such as ByteDance SealSuite, Microsoft Defender for Endpoint), the nested Windows CLI launcher (resources/bin/orca.exe) was being quarantined as malware (reported in #23383 and discussion #23332).

Because the binary previously lacked PE assembly metadata, an embedded manifest, and an application icon, its compilation signature from csc.exe in %LOCALAPPDATA% closely matched dropper heuristics. Providing complete PE provenance and an explicit non-elevated asInvoker manifest mitigates these heuristic detections.

Linked Issue

Fixes #23383

Visual Proof

N/A (No visual or UI change; this modifies the PE headers, manifest, and icon metadata of the native Windows CLI launcher executable).

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Ran npx vitest run config/scripts/build-windows-cli-launcher.test.mjs on Windows 11:

  • All 4 test cases passed (including the new embeds assembly metadata and application manifest into compiled launcher test).
  • Verified via (Get-Item orca.exe).VersionInfo that CompanyName (Stably AI), ProductName (Orca), and FileDescription are properly populated in the PE headers.

AI Disclosure

Developed with pair programming assistance from Google Deepmind Antigravity.

Review

  • Cross-platform: build-windows-cli-launcher.mjs continues to guard execution for Windows only; manifest and icons are conditionally passed only when they exist.
  • Performance: Compile flags remain /optimize+ with reuse caching intact.
  • Security: Manifest explicitly declares asInvoker (no UAC elevation).

Notes

Cross-platform impact: None. Only the Windows CLI launcher compilation path is affected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…cher

Add standard PE assembly attributes, an application manifest with
requestedExecutionLevel=asInvoker, and the application icon to the native
Windows CLI launcher (orca.exe). This provides proper PE provenance and
OS compatibility declaration, mitigating heuristic malware detections by
enterprise EDR solutions (e.g. SealSuite, Defender) on unsigned builds.

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

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

  • Launcher PE metadata — adds standard Assembly* attributes to OrcaCliLauncher.cs so the compiled orca.exe carries Company/Product/FileDescription version info.
  • Embedded manifest and icon — new app.manifest (asInvoker, supportedOS GUIDs) plus /win32manifest and /win32icon passed to csc.exe when the files exist.
  • Rebuild predicate — shouldReuseCompiledWindowsCliLauncher now also treats a newer app.manifest as stale.
  • Integration test — a Windows-only test compiles the launcher and asserts VersionInfo Company/Product/Description.
  • Incidental — both .mjs files were rewritten from single-quote/no-semicolon style to double quotes/semicolons across the whole file.

ℹ️ Nitpicks

  • The new manifestPath branch in shouldReuseCompiledWindowsCliLauncher is not exercised by any test — the reuse test passes no manifestPath, and the metadata test exercises compilation rather than the predicate.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

import { existsSync, mkdirSync, statSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { pathToFileURL } from 'node:url'
import { spawnSync } from "node:child_process";

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.

This file (and build-windows-cli-launcher.test.mjs) was reformatted to double quotes and semicolons throughout, but .oxfmtrc.json sets singleQuote: true and semi: false. npx oxfmt --check fails on both files, so pnpm format or the lint-staged pre-commit hook will revert this churn — please re-run pnpm format so the diff isolates the functional change.

Technical details
# Formatter config conflict

## Affected sites
- `config/scripts/build-windows-cli-launcher.mjs` — imports/statements re-quoted with `"` and terminated with `;`
- `config/scripts/build-windows-cli-launcher.test.mjs` — same

## Required outcome
- Both files match `.oxfmtrc.json` (`singleQuote: true`, `semi: false`, `printWidth: 100`, `trailingComma: none`) and pass `oxfmt --check`.

['/nologo', '/target:exe', '/optimize+', '/warnaserror+', `/out:${outputPath}`, sourcePath],
{ cwd: repoRoot, stdio: 'inherit' }
)
if (existsSync(iconPath)) {

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.

The launcher now consumes resources/build/icon.ico as a compile input, but the reuse predicate only tracks sourcePath and manifestPath, so a changed icon will not force a rebuild — neither through the local reuse shortcut nor through the CI cache (the cache key hashes native/windows-cli-launcher/**, not resources/build/). Pass iconPath alongside manifestPath and add the icon to the cache-key hash.

Technical details
# Icon is not an invalidation input

## Affected sites
- `config/scripts/build-windows-cli-launcher.mjs:129` — `/win32icon` consumes `iconPath`, but `shouldReuseCompiledWindowsCliLauncher` never sees it
- `.github/workflows/pr.yml:1082` — cache key hashes `native/windows-cli-launcher/**` and the build script, not `resources/build/icon.ico`

## Required outcome
- A newer `resources/build/icon.ico` triggers recompilation, and the Actions cache is invalidated when it changes.

);

itWindows(
"embeds assembly metadata and application manifest into compiled launcher",

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.

The test name says it verifies the application manifest, but it only reads VersionInfo (Company/Product/FileDescription), which comes from the assembly attributes — it would still pass if /win32manifest were dropped. Either narrow the name or assert something manifest-specific (e.g. read the raw bytes for requestedExecutionLevel/asInvoker).

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The Windows CLI launcher source now includes assembly metadata, and a Windows application manifest was added. The build script checks the manifest timestamp when deciding whether to reuse an existing executable. When available, the build passes the manifest and icon to the compiler. Tests cover reuse decisions, compilation and runtime behavior, environment handling, and executable metadata.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to d8f02

An icon change may not appear in a rebuilt Windows launcher until its cached executable is replaced. This is bounded and does not block merging, but both reuse paths should be corrected.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d8f02

The launcher now requests the invoking user's privileges and gains identifying metadata, but the packaged executable is not always checked for the intended manifest and icon. The identified exposure is limited to Windows launcher packaging; no new runtime privilege or remote entrypoint is shown.

Retained concerns

  • Low · security · inferred: The intended launcher resources are not an invariant of the packaged executable: cached reuse checks only for an output, and the Windows cache key omits the icon. An icon-only change can therefore leave an older icon in the shipped launcher; other mismatches require an incorrectly supplied or reused output and were not observed.
Security review details

Security Blast Radius

  • inferred — The affected asset is the executable included in Windows packages, not a newly exposed service endpoint. The flagged public-entrypoint ranges are private test helpers with no established production dependents.

Security Findings and Attack Paths

  • inferred — A producer with control over a reused build output can cause packaging to accept it without checking its PE resources. The examined workflow key binds the normal cached output to source and manifest changes, limiting that scenario; no such substitution or mismatched binary was observed.

Trust Boundaries and Controls

  • observed — Source, manifest, icon, and restored build output are inputs to the packaged executable. The script checks source and manifest freshness for ordinary reuse, while cached reuse trusts the existing output and compilation includes each resource only if its file exists.

Resilience and Maintainability Implications

  • observed — A failed compiler invocation stops the immediate build path, but the new metadata test cannot establish that a successfully built or reused binary contains the requested asInvoker manifest.

Hardening Proposals

  • proposed — Include the icon in the launcher cache key and verify the packaged PE's manifest and icon after either compilation or cache restoration.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes implement the metadata and asInvoker manifest objectives in [#23383]. The build script passes /win32manifest and /win32icon to csc.exe, and the tests build the launcher and verify … Add resources/bin/orca.exe to the existing SignPath signing flow used for packaged helper binaries. Add or update automated coverage that verifies the launcher is included in the signing inputs.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary changes: embedding assembly metadata, an application manifest, and an icon in the Windows CLI launcher.
Description check ✅ Passed The description is complete and covers the change, rationale, linked issue, testing, security, cross-platform impact, and checklist. It omits the template's Agent skill upstream boundary section, but …
Out of Scope Changes check ✅ Passed The changed files add launcher provenance metadata, add the requested execution manifest and icon compilation options, update manifest-aware build reuse, and test the launcher build and metadata. Thes…
Full details: Linked Issues check

Explanation

The changes implement the metadata and asInvoker manifest objectives in [#23383]. The build script passes /win32manifest and /win32icon to csc.exe, and the tests build the launcher and verify PE metadata. The directly linked issue also requires bin/orca.exe to enter the SignPath code-signing flow. The PR changes contain no SignPath or launcher-signing integration, so that coding requirement remains unmet.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
config/scripts/build-windows-cli-launcher.test.mjs (1)

304-304: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert a field unique to app.manifest.

VersionInfo checks assembly metadata, not the embedded Win32 manifest. The expected version fields come from assembly attributes in OrcaCliLauncher.cs, so the test can still pass if /win32manifest is omitted. The compiler then embeds its default asInvoker manifest instead of the custom assembly identity and compatibility declarations.

Inspect the manifest resource and assert a unique value, such as StablyAI.Orca.CliLauncher or a supported OS declaration. The current build passes /win32manifest; this adds regression coverage for that integration.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: cd4c03c2-2a03-4f99-a86e-c85ef107a9d0

📥 Commits

Reviewing files that changed from the base of the PR and between 27b823f and d8f029f.

📒 Files selected for processing (4)
  • config/scripts/build-windows-cli-launcher.mjs
  • config/scripts/build-windows-cli-launcher.test.mjs
  • native/windows-cli-launcher/OrcaCliLauncher.cs
  • native/windows-cli-launcher/app.manifest

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

// does not preserve mtimes, so a hit would look stale and recompile anyway.
if (reuseCached) {
return true
return true;

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -n -C 8 'ORCA_REUSE_WINDOWS_CLI_LAUNCHER|windows-cli-launcher|app\.manifest|icon\.ico|hashFiles' .github/workflows

Repository: stablyai/orca

Length of output: 32369


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- tracked launcher files ---'
git ls-files native/windows-cli-launcher config/scripts/build-windows-cli-launcher.mjs .github/workflows/pr.yml | sort
printf '%s\n' '--- build script ---'
cat -n config/scripts/build-windows-cli-launcher.mjs
printf '%s\n' '--- workflow cache/build block ---'
sed -n '1076,1088p' .github/workflows/pr.yml

Repository: stablyai/orca

Length of output: 5731


Include the icon in the cached-launcher key.

The key already includes app.manifest. It does not include resources/build/icon.ico. When the icon changes, the cache can restore an executable with the old icon, and ORCA_REUSE_WINDOWS_CLI_LAUNCHER=1 reuses it.

🐛 Suggested fix
-          key: windows-cli-launcher-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('native/windows-cli-launcher/**', 'config/scripts/build-windows-cli-launcher.mjs') }}
+          key: windows-cli-launcher-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('native/windows-cli-launcher/**', 'resources/build/icon.ico', 'config/scripts/build-windows-cli-launcher.mjs') }}

if (
manifestPath &&
existsSync(manifestPath) &&
outputMtime < statSync(manifestPath).mtimeMs

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Invalidate ordinary reuse when the icon changes.

If only resources/build/icon.ico changes, this check still reuses the old executable. The next build therefore retains the old embedded icon. Pass iconPath into the reuse check and compare its modification time with the output, as you do for the manifest.

@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this — you diagnosed the right gap, and your diagnosis is what drove the fix that shipped. Closing because #23680 landed the equivalent change on main on Sep 28, before this could be merged, so this is now superseded and conflicting.

Credit where it's due: your issue report (#23383) and discussion #23332 identified both halves of the problem — the missing PE provenance and the unsigned nested binaries. The second half turned out to be the actual root cause: v1.4.214 and v1.4.215 shipped a signed installer wrapping unsigned inner binaries because the CI step that downloads signed artifacts from SignPath had continue-on-error: true and the signing approval timed out at 3600s. That failed silently green. #23680 closed both halves.

For the record, the deltas between this PR and what landed, in case they're useful to you:

  • Version attributes. This PR hardcodes AssemblyVersion("1.0.0.0") and AssemblyFileVersion("1.0.0.0"), so every build would report version 1.0.0.0. main derives them from package.json through a windowsCliLauncherVersionSource() helper with range validation. Version is one of the provenance signals reputation systems key on, so a real version matters here.
  • Reuse caching. This PR factors the manifest's mtime into the reuse check. Git doesn't preserve mtimes, so a fresh CI clone stamps every file at clone time and a cached orca.exe can appear newer than a genuinely changed manifest. main fingerprints a SHA-256 over source + manifest + icon + build script + version instead.
  • Conditional compiler flags. This PR passes /win32manifest and /win32icon only when existsSync() is true. A renamed or missing manifest would then silently produce exactly the anonymous-binary shape the change exists to prevent. main always passes both, so a missing file fails the build.

Current state: v1.4.217 signs every inner binary with SignPath Foundation — verified against the published installer asset, not just CI logs — and the evidence gate now names resources\bin\orca.exe explicitly and fails the release instead of warning. The PE metadata half of #23680 is still awaiting a release cut from current main; #23383 stays open until that ships.

We've also grouped every AV/EDR report by root cause in #23999. Thanks again for the thorough report — it was the most actionable one in the thread.

@nwparker nwparker closed this Sep 30, 2026
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.

[Fixed - Verifying] [Bug]: Windows CLI launcher (resources/bin/orca.exe) quarantined as malware by enterprise EDR

2 participants