Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

fix(desktop): resolve bundled Remotion libraries under hardened runtime

Leggettc52964287e23
diff --git a/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs b/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs
index 5b1c12ce..36be5cd0 100644
--- a/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs
+++ b/apps/desktop/scripts/sign-creator-runtime-after-pack.mjs
@@ -9,7 +9,7 @@ import {
writeFileSync
} from 'node:fs';
import { createHash } from 'node:crypto';
-import { join, relative, resolve } from 'node:path';
+import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
import { spawnSync } from 'node:child_process';
import { verifyCreatorRuntime } from './creator-runtime-contract.mjs';
@@ -52,6 +52,7 @@ export async function signRemotionComponent(runtimeRoot, env = process.env, opti
const browserExecutable = resolve(runtimeRoot, manifest.browserExecutable);
const signBinary = options.signBinary ?? signMachOBinary;
for (const path of binaries) {
+ if (isMachOBinary(path)) normalizeRemotionLibraryPaths(path, runtimeRoot);
// Chromium's V8 needs JIT permissions when hardened runtime is enabled.
// Keep these permissions scoped to the browser executable.
if (resolve(path) === browserExecutable) {
@@ -64,6 +65,31 @@ export async function signRemotionComponent(runtimeRoot, env = process.env, opti
});
}
+export function normalizeRemotionLibraryPaths(path, runtimeRoot, options = {}) {
+ const runTool = options.runTool ?? ((command, args) => {
+ const result = spawnSync(command, args, { encoding: 'utf8', timeout: 60_000 });
+ if (result.error || result.status !== 0) {
+ throw new Error(`Unable to prepare Remotion library paths for ${path}: ${result.stderr || result.error?.message}`);
+ }
+ return result.stdout;
+ });
+ const dependencies = runTool('otool', ['-L', path]);
+ for (const match of dependencies.matchAll(/^\s+(.+?) \(compatibility version .+\)$/gm)) {
+ const dependency = match[1];
+ if (dependency.startsWith('@') || isAbsolute(dependency)) continue;
+ const library = resolve(dirname(path), dependency);
+ const inside = relative(resolve(runtimeRoot), library);
+ if (inside === '..' || inside.startsWith(`..${sep}`) || isAbsolute(inside) || !existsSync(library)) {
+ throw new Error(`Remotion relative library is not bundled: ${dependency}`);
+ }
+ // Hardened runtime rejects bare relative library names, even when signed.
+ const replacement = `@loader_path/${dependency}`;
+ runTool('install_name_tool', library === resolve(path)
+ ? ['-id', replacement, path]
+ : ['-change', dependency, replacement, path]);
+ }
+}
+
export async function signDaemonRuntimeBundle(context, options = {}) {
return signPackagedRuntime(context, options, {
name: 'Daemon Runtime',
diff --git a/apps/desktop/test/creator-runtime-signing.test.mjs b/apps/desktop/test/creator-runtime-signing.test.mjs
index 20c3ad8d..658f28d0 100644
--- a/apps/desktop/test/creator-runtime-signing.test.mjs
+++ b/apps/desktop/test/creator-runtime-signing.test.mjs
@@ -16,6 +16,7 @@ import {
signCreatorRuntimeBundle,
signStickmanRuntimeBundle,
signRemotionComponent,
+ normalizeRemotionLibraryPaths,
updateManifestHashes
} from '../scripts/sign-creator-runtime-after-pack.mjs';
@@ -28,6 +29,35 @@ afterEach(() => {
});
describe('Creator Runtime Developer ID signing', () => {
+ it('binds relative Remotion libraries to their packaged loader directory', () => {
+ const fixture = createStickmanFixture();
+ const browser = fixture.binaryPaths[0];
+ const library = join(dirname(browser), 'libavdevice.dylib');
+ writeFileSync(library, 'library');
+ const runTool = vi.fn(() => `${browser}:\n\tlibavdevice.dylib (compatibility version 61.0.0, current version 61.3.100)\n\t/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)\n\t@rpath/libother.dylib (compatibility version 1.0.0, current version 1.0.0)\n`);
+ normalizeRemotionLibraryPaths(browser, fixture.runtimeRoot, { runTool });
+ expect(runTool.mock.calls).toEqual([
+ ['otool', ['-L', browser]],
+ ['install_name_tool', ['-change', 'libavdevice.dylib', '@loader_path/libavdevice.dylib', browser]]
+ ]);
+ });
+
+ it('normalizes the install name of a bundled Remotion dynamic library', () => {
+ const fixture = createStickmanFixture();
+ const library = join(dirname(fixture.binaryPaths[0]), 'libavdevice.dylib');
+ writeFileSync(library, 'library');
+ const runTool = vi.fn(() => `${library}:\n\tlibavdevice.dylib (compatibility version 61.0.0, current version 61.3.100)\n`);
+ normalizeRemotionLibraryPaths(library, fixture.runtimeRoot, { runTool });
+ expect(runTool).toHaveBeenCalledWith('install_name_tool', ['-id', '@loader_path/libavdevice.dylib', library]);
+ });
+
+ it('rejects relative Remotion libraries missing from the bundle', () => {
+ const fixture = createStickmanFixture();
+ const runTool = vi.fn(() => '\tmissing.dylib (compatibility version 1.0.0, current version 1.0.0)\n');
+ expect(() => normalizeRemotionLibraryPaths(fixture.binaryPaths[0], fixture.runtimeRoot, { runTool })).toThrow('Remotion relative library is not bundled: missing.dylib');
+ expect(runTool).toHaveBeenCalledTimes(1);
+ });
+
it('signs the independent Remotion component using its prepared keychain and refreshes final hashes', async () => {
const fixture = createStickmanFixture();
const findIdentity = vi.fn(() => 'Developer ID Application: Junxi YIN (NVRH5R5DJ5)');