Skip to content

escape_unicode() corrupts payload during webhook validation in validate_message() #596

Open
@ajvoisancountyofsb

Description

@ajvoisancountyofsb

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:

  1. Removing the internal call to escape_unicode()

  2. Manual signature validation following the method described at https://developer.box.com/guides/webhooks/v2/signatures-v2/#manual-signature-verification

Steps to Reproduce

  1. 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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions