T05 · Unauthorized Access and Privilege Escalation
- Location
cloud-api-worker/src/index.ts:260- Finding
Unauthenticated Public-Key Registration Enables Existing Vault Takeover
- Content
View full analysis
{ const body = await c.req.json<{ email: string; public_key: string; hostname?: string; os?: string; instance_id?: string }>(); if (!body.email) return c.json({ error: "email required" }, 400); const db = c.env.DB; const existing = await db.prepare("SELECT id FROM vaults WHERE email = ?").bind(body.email).first<{ id: string }>(); if (existing) { if (body.public_key) { const fp = await computeFingerprintAsync(body.public_key); const dup = await db.prepare("SELECT id FROM vault_keys WHERE vault_id = ? AND fingerprint = ? AND revoked_at IS NULL").bind(existing.id, fp).first(); if (!dup) await db.prepare("INSERT INTO vault_keys (id, vault_id, public_key, fingerprint, hostname, instance_id) VALUES (?, ?, ?, ?, ?, ?)").bind(crypto.randomUUID(), existing.id, body.public_key, fp, body.hostname || "", body.instance_id || "").run(); } return c.json({ vault_id: existing.id, status: "existing" }); } ``` ### Technical Analysis The public signup endpoint identifies an existing vault using only an email address. When a matching vault exists, it registers the submitted public key without verifying control of the email account or requiring a signature from an already authorized key. The endpoint also returns the existing vault ID. Consequently, the same unauthenticated request both discovers the target identifier and grants an attacker-controlled key access to it. This bypasses the otherwise meaningful Ed25519 signature checks on protected vault routes. ### Attack Path 1. An attacker obtains or guesses a victim's email address. 2. The attacker generates an Ed25519 key pair. 3. The attacker submits the victim's email and the attacker's public key to `POST /v1/signup`. 4. The endp ...[truncated 671 chars]- Remediation
View remediation
