Description
- I have checked that the SDK documentation doesn't solve my issue.
- I have checked that the API documentation doesn't solve my issue.
- I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
- I have searched Issues in this repo and my issue isn't already reported.
Description of the Issue
The escape_unicode() function used internally by WebhooksManager.validate_message() alters the raw webhook payload, resulting in failed validation for otherwise valid Box webhook events. validate_message() calls internal.utils.compute_webhook_signature() which then passes the request body to internal.utils.escape_unicode().
The function escapes:
-
Control characters (\n, \r, \t)
-
All non-ASCII characters
-
Supplementary Plane Unicode characters via surrogate pairs
Since the Box signature is computed over the raw request body, escaping any characters changes the payload and causes a signature mismatch.
Successful workarounds:
-
Removing the internal call to escape_unicode()
-
Manual signature validation following the method described at https://developer.box.com/guides/webhooks/v2/signatures-v2/#manual-signature-verification
Steps to Reproduce
- Attempt to validate a webhook payload that contains any of the escaped characters above using WebhooksManager.validate_message()
Expected Behavior
validate_message() should use the exact raw bytes of the webhook payload — without transformations — to compute the HMAC.
Versions Used
Python SDK: box-sdk-gen==1.12.0
Python: 3.11.4