You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/08/11 20:06:45 UTC
(superset) 01/01: test(encrypt): pin trailing-asterisk corruption in encrypted secrets
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch tdd/encrypted-field-trailing-asterisk-32664
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 66d4119e636ec2e6e1eaebd18574ce1f2f9933a1
Author: rusackas <ev...@rusackas.com>
AuthorDate: Tue Aug 11 13:06:31 2026 -0700
test(encrypt): pin trailing-asterisk corruption in encrypted secrets
apache/superset#32664 (reopened): the default AES-CBC EncryptedType field
(used for Database.password, among other secrets) relies on
sqlalchemy_utils' "naive" padding scheme, which pads short plaintext with
literal '*' bytes and unpads on decrypt by unconditionally stripping every
trailing '*' (NaivePadding.unpad -> value.rstrip(b"*")). A password or
token whose real value happens to end in '*' gets that character stripped
right along with the padding, silently corrupting the secret the next
time it's read back.
This is a different root cause than the original report (fixed by
#30532, which addressed the connection-string encoding used at
database-creation time). The issue was closed assuming that fix covered
it, but the underlying storage-layer corruption was never addressed;
two independent users confirmed reproducing it on 6.1.0 after the close.
Verified directly against Superset's own field factory
(SQLAlchemyUtilsAdapter, not just raw sqlalchemy_utils):
'mypassword*' round-trips through process_bind_param/process_result_value
as 'mypassword'.
Test-only: a real fix needs care. Naive padding is sqlalchemy_utils'
historical default (kept for backwards compatibility with existing
ciphertext), and switching padding schemes on an existing deployment has
the same re-encryption hazard already documented in
superset/utils/encrypt.py for the AES-CBC -> AES-GCM engine switch --
old encrypted values could become unreadable if the padding scheme just
changes under them without a migration path.
Fixes #32664
---
tests/unit_tests/utils/encrypt_test.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tests/unit_tests/utils/encrypt_test.py b/tests/unit_tests/utils/encrypt_test.py
index 2fc65f2cebb..0a3a939fc00 100644
--- a/tests/unit_tests/utils/encrypt_test.py
+++ b/tests/unit_tests/utils/encrypt_test.py
@@ -75,6 +75,30 @@ def test_default_engine_is_aes_cbc() -> None:
assert isinstance(field.engine, AesEngine)
+def test_trailing_asterisk_survives_round_trip() -> None:
+ """A secret ending in a literal '*' must not be truncated on decrypt.
+
+ Reported in apache/superset#32664: a Redshift/Postgres password ending in
+ '*' connects fine (Test Connection succeeds) but authentication fails
+ after the Database row is saved and reloaded. The default AES-CBC field
+ uses sqlalchemy_utils' "naive" padding scheme, which pads short values
+ with literal '*' bytes and unpads by unconditionally stripping every
+ trailing '*' on decrypt (see NaivePadding.unpad). That strips a real
+ trailing '*' in the secret right along with the padding, silently
+ corrupting any password/token that happens to end in that character.
+ """
+ field = SQLAlchemyUtilsAdapter().create(SECRET, String(1024))
+
+ encrypted = field.process_bind_param("mypassword*", DIALECT)
+ decrypted = field.process_result_value(encrypted, DIALECT)
+
+ assert decrypted == "mypassword*", (
+ f"expected the trailing '*' to survive the round trip, got {decrypted!r} "
+ "-- the default naive padding scheme strips real trailing '*' bytes "
+ "along with its own padding"
+ )
+
+
def test_aes_gcm_engine_selected_by_config() -> None:
"""SQLALCHEMY_ENCRYPTED_FIELD_ENGINE='aes-gcm' selects authenticated AES-GCM."""
field = SQLAlchemyUtilsAdapter().create(