Skip to content

Harden decryption error handling#235

Open
jguz-pubnub wants to merge 3 commits into
masterfrom
python-sec-fixes
Open

Harden decryption error handling#235
jguz-pubnub wants to merge 3 commits into
masterfrom
python-sec-fixes

Conversation

@jguz-pubnub

@jguz-pubnub jguz-pubnub commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

fix: raises PubNubException('decryption error') on failure instead of returning the still-encrypted bytes

PubNubFileCrypto.decrypt now raises PubNubException('decryption error') instead of returning the still-encrypted bytes on failure, so callers can no longer mistake ciphertext for plaintext.

fix: return one generic decryption error from cryptors instead of the crypto-library message

Cryptors now return a single generic error on any decryption failure instead of surfacing the underlying crypto-library message. Cause kept in debug logs only.

test: strip dead python-object URL tags from asyncio VCR cassettes so vcrpy's hardened SafeLoader can deserialize them

@pubnub-ops-terraform

pubnub-ops-terraform commented Jun 26, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@jguz-pubnub jguz-pubnub marked this pull request as ready for review July 6, 2026 08:38
@jguz-pubnub jguz-pubnub requested a review from parfeon as a code owner July 6, 2026 08:38

@parfeon parfeon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but have small question.

Comment thread pubnub/workers.py
return self._pubnub.crypto.decrypt(message_input), None
except Exception as exception:
logger.warning("could not decrypt message: \"%s\", due to error %s" % (message_input, str(exception)))
logger.warning("could not decrypt message, due to error %s" % str(exception))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to hide message which wasn't decrypted? We can change log level

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.

3 participants