fix: notify() generates iv_nonce and a fresh session_id per call#522
Open
cconstab wants to merge 1 commit into
Open
fix: notify() generates iv_nonce and a fresh session_id per call#522cconstab wants to merge 1 commit into
cconstab wants to merge 1 commit into
Conversation
notify() crashed when the AtKey had no iv_nonce ('nonce must be bytes-like'),
forcing callers to set metadata.iv_nonce manually. It also used a signature
default session_id=str(uuid.uuid4()), which is evaluated once at import, so every
notify() without an explicit id reused the same one and the server deduped the
duplicates.
Generate the AES nonce inside notify() when unset (and store it on the key's
metadata so it travels with the notification), and default session_id to None,
generating a fresh UUID per call.
Adds network-free unit tests for both behaviours.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
notify()had two defects, both inat_client/atclient.py:at_key.metadata.iv_nonceand passed itstraight to
aes_encrypt_from_base64; if the caller hadn't set it, AES-CTR raisednonce must be bytes-like. Callers had to setmetadata.iv_noncemanually.session_id=str(uuid.uuid4())isevaluated once at import, so every
notify()without an explicit id reused the sameid for the process lifetime. The atServer dedups by notification id, so duplicate /
rapid notifications were silently dropped.
Fix: generate the nonce inside
notify()when unset (and store it on the key'smetadata so it travels with the notification for the receiver to decrypt), and default
session_idtoNone, minting a fresh UUID per call.Tests:
test/notify_test.py— network-free:session_iddefault isNone(regression against the import-time UUID)notify()setsiv_noncewhen the key has none (mocked network)Found while building a production integration on atsdk; both were reproducible in
isolation.