Skip to content

Commit 84fe778

Browse files
committed
fix: specify authTagLength in AES-GCM decipheriv calls
Fixes missing authTagLength parameter in createDecipheriv calls using AES-256-GCM mode. Without explicit tag length specification, the application may be tricked into accepting shorter authentication tags, potentially allowing ciphertext spoofing. CWE-310: Cryptographic Issues (gcm-no-tag-length)
1 parent d581009 commit 84fe778

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
@@ -81,7 +81,7 @@ export async function decryptApiKey(encryptedValue: string): Promise<{ decrypted
8181
const authTag = Buffer.from(authTagHex, 'hex')
8282

8383
try {
84-
const decipher = createDecipheriv('aes-256-gcm', key, iv)
84+
const decipher = createDecipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
8585
decipher.setAuthTag(authTag)
8686

8787
let decrypted = decipher.update(encrypted, 'hex', 'utf8')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function decryptSecret(encryptedValue: string): Promise<{ decrypted
5454
const authTag = Buffer.from(authTagHex, 'hex')
5555

5656
try {
57-
const decipher = createDecipheriv('aes-256-gcm', key, iv)
57+
const decipher = createDecipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
5858
decipher.setAuthTag(authTag)
5959

6060
let decrypted = decipher.update(encrypted, 'hex', 'utf8')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async function decryptSecret(encryptedValue: string): Promise<string> {
146146
const iv = Buffer.from(ivHex, 'hex')
147147
const authTag = Buffer.from(authTagHex, 'hex')
148148

149-
const decipher = createDecipheriv('aes-256-gcm', key, iv)
149+
const decipher = createDecipheriv('aes-256-gcm', key, iv, { authTagLength: 16 })
150150
decipher.setAuthTag(authTag)
151151

152152
let decrypted = decipher.update(encrypted, 'hex', 'utf8')

0 commit comments

Comments
 (0)