Repository navigation
fix: verify the signature before validating a received payload - #63
Merged
Merged
Conversation
parse_response() decoded and validated Ds_MerchantParameters before checking Ds_Signature, so an unsigned payload posted to the notification URL could raise decimal.Overflow and other unexpected exceptions, nested JSON could exhaust a small thread stack and crash the process, and an oversized Ds_Signature was normalized whatever its length. Before the signature check it now reads at most 128 KiB of Ds_MerchantParameters and 128 characters of Ds_Signature, and rejects JSON nested deeper than 32 levels; fields are validated only after the signature matches. Any malformed payload, and a send() answer that is not JSON, raises redsys.exceptions.ValidationError, a ValueError; a signature mismatch still raises ValueError.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #63 +/- ##
==========================================
- Coverage 99.16% 99.12% -0.05%
==========================================
Files 26 26
Lines 1315 1368 +53
==========================================
+ Hits 1304 1356 +52
- Misses 11 12 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 14, 2026
Merged
ddiazpinto
added a commit
that referenced
this pull request
Nov 14, 2026
* fix: verify the signature before reading the response create_response() decoded Ds_MerchantParameters and built the Response before checking Ds_Signature, so an unsigned payload posted to the notification URL could crash the process with deeply nested JSON on a small thread stack, have a Ds_Signature of any length normalized, or raise TypeError, AttributeError, RecursionError or decimal.InvalidOperation. Before the signature check it now reads at most 128 KiB of Ds_MerchantParameters and 128 characters of Ds_Signature, and rejects JSON nested deeper than 32 levels. Fields are read only after the signature matches, signatures compare in constant time, and any malformed payload raises ValueError. Backport of #63. * chore(release): 1.2.3 Version bump and changelog entry.
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.
parse_response() decoded and validated Ds_MerchantParameters before
checking Ds_Signature, so an unsigned payload posted to the notification
URL could raise decimal.Overflow and other unexpected exceptions, nested
JSON could exhaust a small thread stack and crash the process, and an
oversized Ds_Signature was normalized whatever its length.
Before the signature check it now reads at most 128 KiB of
Ds_MerchantParameters and 128 characters of Ds_Signature, and rejects
JSON nested deeper than 32 levels; fields are validated only after the
signature matches. Any malformed payload, and a send() answer that is
not JSON, raises redsys.exceptions.ValidationError, a ValueError; a
signature mismatch still raises ValueError.