Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix: refuse Windows locker writes that exceed the PasswordVault 512-character limit

fetw198f0e8dd4d5
diff --git a/packages/credential-store-os/runtime/windows-credential.ps1 b/packages/credential-store-os/runtime/windows-credential.ps1
index 0fc2fe38..ef0501d3 100644
--- a/packages/credential-store-os/runtime/windows-credential.ps1
+++ b/packages/credential-store-os/runtime/windows-credential.ps1
@@ -38,6 +38,9 @@ switch ($Operation) {
# Add replaces the same resource/account; do not destroy the old value before it succeeds.
$bytes = [Convert]::FromBase64String([string]$request.secret)
$secret = [System.Text.Encoding]::UTF8.GetString($bytes)
+ if ($secret.Length -gt 512) {
+ throw "PasswordVault cannot store a $($secret.Length)-character secret (limit 512). Select @hypit/credential-store-file for OAuth tokens."
+ }
$credential = New-Object Windows.Security.Credentials.PasswordCredential(
[string]$request.service,
[string]$request.account,
diff --git a/packages/credential-store-os/src/windows.ts b/packages/credential-store-os/src/windows.ts
index cc4ab6d4..1f8d0fcb 100644
--- a/packages/credential-store-os/src/windows.ts
+++ b/packages/credential-store-os/src/windows.ts
@@ -9,6 +9,19 @@ type WindowsCredentialResult = {
const windowsScript = fileURLToPath(new URL("../runtime/windows-credential.ps1", import.meta.url));
+/** PasswordVault password field; OAuth JSON routinely exceeds this. */
+export const windowsLockerPasswordLimit = 512;
+
+export function assertWindowsLockerSecret(secret: string, account: string): void {
+ if (secret.length > windowsLockerPasswordLimit) {
+ throw new Error(
+ `Windows Credential Locker cannot store the ${secret.length}-character secret for ${account}`
+ + ` (PasswordVault limit is ${windowsLockerPasswordLimit} characters).`
+ + " Select @hypit/credential-store-file for OAuth tokens.",
+ );
+ }
+}
+
/** The OS adapter owns this one child; Node owns its timeout, bounded output and termination. */
export function windowsCredential(
operation: "read" | "write" | "delete",
@@ -16,6 +29,7 @@ export function windowsCredential(
account: string,
secret?: string,
): Promise<WindowsCredentialResult> {
+ if (secret !== undefined) assertWindowsLockerSecret(secret, account);
return new Promise((resolve, reject) => {
const child = execFile("powershell.exe", [
"-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass",
diff --git a/packages/credential-store-os/test/windows-limit.test.ts b/packages/credential-store-os/test/windows-limit.test.ts
new file mode 100644
index 00000000..ef03a9db
--- /dev/null
+++ b/packages/credential-store-os/test/windows-limit.test.ts
@@ -0,0 +1,12 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { assertWindowsLockerSecret, windowsLockerPasswordLimit } from "../src/windows.js";
+
+test("Windows locker rejects OAuth-sized secrets before PasswordVault", () => {
+ assertWindowsLockerSecret("x".repeat(windowsLockerPasswordLimit), "hypihub.oauth");
+ assert.throws(
+ () => assertWindowsLockerSecret("x".repeat(windowsLockerPasswordLimit + 1), "hypihub.oauth"),
+ /513-character secret for hypihub\.oauth.*PasswordVault limit is 512.*credential-store-file/u,
+ );
+});