Skip to content

fix: reject serialized encryption contexts with zero entries - #832

Open
pcbeingused333 wants to merge 2 commits into
aws:masterfrom
pcbeingused333:fix/c2737-zero-entry-context
Open

pcbeingused333 wants to merge 2 commits into
aws:masterfrom
pcbeingused333:fix/c2737-zero-entry-context

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #57.

A nonempty serialized encryption context with an entry count of zero currently skips the parsing loop and returns an empty dictionary. Empty encryption contexts are encoded as an empty byte string, so this accepts a malformed encoding.

Reject a zero entry count with SerializationError. Preserve the valid empty byte string and the existing checks for trailing data. Add a regression test for the zero entry count in the existing encryption context unit suite, alongside its existing valid and empty context coverage.

Testing and validation

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src python -m pytest test/unit/test_encryption_context.py -k zero_entries -q: before the fix, 1 failed; after the fix, 1 passed (18 deselected).

The complete encryption context unit suite also passed: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=src python -m pytest -p pytest_mock test/unit/test_encryption_context.py -q (19 passed). Tests ran in a dedicated virtual environment with mock and pytest-mock installed.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

No files were moved.

AI assistance: this change and its regression tests were prepared with OpenAI Codex.

@pcbeingused333
pcbeingused333 requested a review from a team as a code owner November 12, 2026 07:36

This branch has not been deployed

No deployments
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.

deserialize encryption context should fail on malformed encryption context

1 participant