fix(wecom): pad base64 AES key before decode (salvage #17040) - #20177
Merged
Conversation
WeCom doesn't pad base64 aeskey, causing Python strict mode decode failure on media/image/file messages. Add automatic padding before base64 decode: aes_key + '=' * ((4 - len(aes_key) % 4) % 4). Salvages the AES padding fix from @chengoak's PR #17040. The SSRF whitelist entry for a private COS bucket hostname was dropped as it belongs in user config, not the built-in trusted-private-IP-hosts list. The debug-level full-body info log was dropped to avoid logging potentially sensitive message content at INFO level.
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.
Salvages the AES padding fix from @chengoak's PR #17040. The SSRF whitelist entry for a contributor-specific COS bucket hostname (
ww-aibot-img-1258476243.cos.ap-guangzhou.myqcloud.com, which looks like a private tenant ID baked into the repo) was dropped as it belongs in user config, not the built-in list. The INFO-level debug log of full message bodies was also dropped.What it does
WeCom doesn't pad base64 aeskey; Python's strict decoder rejects the unpadded key, so every media/image/file webhook fails to decrypt.
Changes
gateway/platforms/wecom.py— padaes_keyto a multiple of 4 beforebase64.b64decode.scripts/release.py— AUTHOR_MAP entry for chengoak.Validation
py_compileclean. Minimal change, 2 lines.Closes #17040 via salvage.