Skip to content

fix(security): change default encryption engine from AES-CBC to AES-GCM#7

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1782801528-fix-sqlalchemy-utils-encryption-vuln
Open

fix(security): change default encryption engine from AES-CBC to AES-GCM#7
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1782801528-fix-sqlalchemy-utils-encryption-vuln

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Addresses the sqlalchemy-utils EncryptedType static-IV vulnerability (Safety DB 42194 / PVE-2021-42194). Fixes #2.

Why a version bump doesn't work: The vulnerability affects all sqlalchemy-utils versions >=0.27.0. The upstream fix (PR kvesteri/sqlalchemy-utils#499) has remained unmerged since Feb 2021. The latest release (0.42.1) is still affected. The Safety DB's "upgrade to 0.1" recommendation is erroneous.

What this PR does instead: Changes DEFAULT_ENCRYPTION_ENGINE_NAME from "aes" (AES-CBC with a static IV — the vulnerable default) to "aes-gcm" (AES-GCM with os.urandom IVs + authenticated encryption). This directly eliminates the vulnerability for any deployment that doesn't explicitly override the engine.

- DEFAULT_ENCRYPTION_ENGINE_NAME = "aes"
+ DEFAULT_ENCRYPTION_ENGINE_NAME = "aes-gcm"

Compatibility considerations:

  • Deployments already setting SQLALCHEMY_ENCRYPTED_FIELD_ENGINE = "aes" explicitly are unaffected (they keep AES-CBC).
  • Deployments relying on the implicit default will now encrypt new secrets with AES-GCM. Existing AES-CBC ciphertext becomes unreadable unless migrated.
  • Migration path: run superset re-encrypt-secrets --previous-secret-key <KEY> (the SecretsMigrator in this file already handles CBC→GCM transitions).
  • Alternatively, set SQLALCHEMY_ENCRYPTED_FIELD_ENGINE = "aes" to explicitly opt back into the previous behavior.

Link to Devin session: https://app.devin.ai/sessions/ba8cecfc1286455f99d874887af73fa2
Requested by: @noahlin17

The EncryptedType in sqlalchemy-utils uses AES-CBC with a static IV by
default (Safety DB 42194 / PVE-2021-42194). This vulnerability affects
all versions >=0.27.0 and has no upstream fix (PR apache#499 remains unmerged).

Rather than a version bump (which cannot resolve the issue), this changes
Superset's default encryption engine from 'aes' (AES-CBC, static IV) to
'aes-gcm' (AES-GCM, random IV + authenticated encryption).

Existing deployments that relied on the implicit 'aes' default must either:
- Set SQLALCHEMY_ENCRYPTED_FIELD_ENGINE='aes' explicitly to retain the
  previous behavior, or
- Run 'superset re-encrypt-secrets' to migrate stored ciphertext to AES-GCM.

Closes #2

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@noahlin17 noahlin17 self-assigned this Jun 30, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] sqlalchemy-utils >=0.27.0 vulnerable, full declared range affected

1 participant