Skip to content

Commit 9dcb2ac

Browse files
waleedlatif1claude
andcommitted
fix: specify authTagLength on createCipheriv calls for AES-GCM consistency
Complements #3881 by adding explicit authTagLength: 16 to the encrypt side as well, ensuring both cipher and decipher specify the tag length. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 84fe778 commit 9dcb2ac

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

apps/sim/lib/api-key/crypto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function encryptApiKey(apiKey: string): Promise<{ encrypted: string
3636
}
3737

3838
const iv = randomBytes(16)
39-
const cipher = createCipheriv('aes-256-gcm', key, iv)
39+
const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
4040
let encrypted = cipher.update(apiKey, 'utf8', 'hex')
4141
encrypted += cipher.final('hex')
4242

apps/sim/lib/core/security/encryption.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function encryptSecret(secret: string): Promise<{ encrypted: string
2121
const iv = randomBytes(16)
2222
const key = getEncryptionKey()
2323

24-
const cipher = createCipheriv('aes-256-gcm', key, iv)
24+
const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
2525
let encrypted = cipher.update(secret, 'utf8', 'hex')
2626
encrypted += cipher.final('hex')
2727

packages/db/scripts/migrate-block-api-keys-to-byok.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function getEncryptionKeyBuffer(): Buffer {
125125
async function encryptSecret(secret: string): Promise<string> {
126126
const iv = randomBytes(16)
127127
const key = getEncryptionKeyBuffer()
128-
const cipher = createCipheriv('aes-256-gcm', key, iv)
128+
const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
129129
let encrypted = cipher.update(secret, 'utf8', 'hex')
130130
encrypted += cipher.final('hex')
131131
const authTag = cipher.getAuthTag()

0 commit comments

Comments
 (0)