Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(cuda): pin the CUDA whisper binaries and verify their digests (#1372)

Gabriel Stein6f9c7f8c62e4
diff --git a/src/helpers/whisperCudaManager.js b/src/helpers/whisperCudaManager.js
index a77824cc5..38027d475 100644
--- a/src/helpers/whisperCudaManager.js
+++ b/src/helpers/whisperCudaManager.js
@@ -1,12 +1,24 @@
const GpuBinaryManager = require("./gpuBinaryManager");
-const GITHUB_RELEASE_URL = "https://api.github.com/repos/OpenWhispr/whisper.cpp/releases/latest";
+// Pinned so untested future binaries never auto-ship; bump together with the digests below
+const WHISPER_CPP_TAG = process.env.WHISPER_CPP_VERSION || "0.0.8";
+
+// sha256 per release tag; tags without an entry fall back to the API-reported digest
+const EXPECTED_DIGESTS = {
+ "0.0.8": {
+ "whisper-server-win32-x64-cuda.zip":
+ "ef6df3492b6e512ccfb04ce69e01ac26b2e12f3c90a665cdb35e7f1f471ed203",
+ "whisper-server-linux-x64-cuda.zip":
+ "8c71e63658fafd3efec39bb0ff3c0d15790ede0be87849dfbf9ad8a81e04b3d0",
+ },
+};
class WhisperCudaManager extends GpuBinaryManager {
constructor() {
super({
name: "CUDA whisper",
- releaseUrl: GITHUB_RELEASE_URL,
+ releaseUrl: `https://api.github.com/repos/OpenWhispr/whisper.cpp/releases/tags/${WHISPER_CPP_TAG}`,
+ expectedDigests: EXPECTED_DIGESTS[WHISPER_CPP_TAG],
assets: {
"win32-x64": {
assetName: "whisper-server-win32-x64-cuda.zip",
diff --git a/test/helpers/gpuBinaryManager.test.js b/test/helpers/gpuBinaryManager.test.js
index 7475c4446..e66513e88 100644
--- a/test/helpers/gpuBinaryManager.test.js
+++ b/test/helpers/gpuBinaryManager.test.js
@@ -76,6 +76,14 @@ const WhisperCudaManager = require("../../src/helpers/whisperCudaManager.js");
const LlamaVulkanManager = require("../../src/helpers/llamaVulkanManager.js");
const WhisperVulkanManager = require("../../src/helpers/whisperVulkanManager.js");
+// CUDA pins real release digests, which a stubbed archive can never hash to. Tests that
+// exercise shared pipeline behavior rather than integrity drop the pin to reach it.
+function cudaManagerWithoutDigestPin() {
+ const manager = new WhisperCudaManager();
+ manager.config.expectedDigests = undefined;
+ return manager;
+}
+
function makeRelease(assetName, overrides = {}) {
return {
tag_name: "test-tag",
@@ -114,7 +122,7 @@ test.afterEach(() => {
fs.rmSync(tempDir, { recursive: true, force: true });
});
-test("CUDA: resolves its exact asset from releases/latest and installs binary + companion libs", async () => {
+test("CUDA: resolves its exact asset from the pinned tag and installs binary + companion libs", async () => {
state.release = makeRelease("whisper-server-linux-x64-cuda.zip");
state.extractedFiles = {
"whisper-server-linux-x64-cuda": "binary",
@@ -122,10 +130,10 @@ test("CUDA: resolves its exact asset from releases/latest and installs binary +
"README.md": "doc",
};
- const manager = new WhisperCudaManager();
+ const manager = cudaManagerWithoutDigestPin();
await manager.download();
- assert.match(state.fetchedUrls[0], /OpenWhispr\/whisper\.cpp\/releases\/latest$/);
+ assert.match(state.fetchedUrls[0], /OpenWhispr\/whisper\.cpp\/releases\/tags\/0\.0\.8$/);
assert.equal(state.downloads[0].url, "https://dl/whisper-server-linux-x64-cuda.zip");
const binDir = path.join(userDataDir, "bin");
@@ -151,6 +159,14 @@ test("llama Vulkan: resolves asset by regex from the pinned tag", async () => {
assert.ok(fs.existsSync(path.join(userDataDir, "bin", "libvulkan.so.1")));
});
+test("CUDA: pinned digest rejects an asset that doesn't match (fail closed)", async () => {
+ state.release = makeRelease("whisper-server-linux-x64-cuda.zip");
+ state.extractedFiles = { "whisper-server-linux-x64-cuda": "binary" };
+
+ await assert.rejects(() => new WhisperCudaManager().download(), { message: /integrity check/ });
+ assert.equal(new WhisperCudaManager().isDownloaded(), false);
+});
+
test("whisper Vulkan: pinned asset, no companion libs, rejects a digest mismatch (fail closed)", async () => {
state.release = makeRelease("whisper-server-linux-x64-vulkan.zip");
state.extractedFiles = { "whisper-server-linux-x64-vulkan": "binary" };
@@ -262,7 +278,7 @@ test("guard: a second download while one is in flight throws", async () => {
};
state.extractedFiles = { "whisper-server-linux-x64-cuda": "binary" };
- const manager = new WhisperCudaManager();
+ const manager = cudaManagerWithoutDigestPin();
const first = manager.download();
await assert.rejects(() => manager.download(), { message: "Download already in progress" });
releaseDownload();
@@ -275,7 +291,7 @@ test("cleanup on failure: archive and extract dir removed, next download can sta
throw new Error("Extraction failed: corrupt");
};
- const manager = new WhisperCudaManager();
+ const manager = cudaManagerWithoutDigestPin();
await assert.rejects(() => manager.download(), { message: /Extraction failed/ });
assert.equal(fs.readdirSync(tempDir).length, 0, "temp artifacts removed");