For AES GCM this isn't an issue because the padding removal is handled automatically.
For modes that do care about padding (e.g. AES CBC) this is blindly removing characters under the assumption that A) they belong to the padding and B) that the padding is valid. This allows an attacker to spoof data much more easily because the padding is never validated and invalid JSON characters are being silently removed.
The pycryptodome library that this package uses contains padding utilities. I strongly recommend you use them.
The logic for padding removal from JWE encryption is incorrect. The current code merely strips unprintable characters regardless if they belong to the padding or not: https://github.com/Mastercard/client-encryption-python/blob/5f8ecefabe293e15b2920fb103f87308a131882d/client_encryption/jwe_encryption.py#L99
For AES GCM this isn't an issue because the padding removal is handled automatically.
For modes that do care about padding (e.g. AES CBC) this is blindly removing characters under the assumption that A) they belong to the padding and B) that the padding is valid. This allows an attacker to spoof data much more easily because the padding is never validated and invalid JSON characters are being silently removed.
The pycryptodome library that this package uses contains padding utilities. I strongly recommend you use them.