fix: handle missing base64 padding in WeCom aes_key decryption - #18654
Closed
highland0971 wants to merge 4 commits into
Closed
fix: handle missing base64 padding in WeCom aes_key decryption#18654highland0971 wants to merge 4 commits into
highland0971 wants to merge 4 commits into
Conversation
- feat(feishu): add markdown table rendering support - fix(feishu): silent message drop handling - fix(feishu): ensure replies stay inside topic threads in group chats
- Set NO_COLOR=1 env var to disable colors in agent-browser CLI - Add fallback regex to strip any remaining ANSI sequences - Fixes JSON parse failures from escape codes like \x1b[A (cursor up)
Previous regex \x1b/[a-z]* was greedy and consumed trailing letters. Fixed to \x1b/ which only matches the ESC+/ sequence. Example: \x1b/tabs now correctly becomes 'tabs' instead of ''. Also expanded pattern to handle: - CSI sequences with private mode params (\x1b[?25h) - OSC sequences (\x1b]...BEL) - Single ESC+letter sequences (\x1bM) - Non-standard ESC+/ sequences
Collaborator
|
Likely duplicate of #14888 and #14580 — same root cause (unpadded base64 aes_key in WeCom media decrypt) and same fix (pad to multiple of 4). Also overlaps with #17375 which handles multiple AES key formats. Note: this PR touches files beyond wecom.py (feishu.py, run.py, stream_consumer.py, browser_tool.py) which seems unrelated to the stated fix. |
Collaborator
|
duplicate |
17 tasks
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.
Problem
WeCom AI Bot sends image messages with an
aes_keythat may lack standard base64 padding (missing trailing '=' characters). This causesbase64.b64decode()to fail withIncorrect paddingerror, preventing image decryption.Solution
Add padding validation before decoding the
aes_key. Base64 strings must have length that is a multiple of 4 characters. The fix automatically appends the required '=' padding characters.Changes
File:
gateway/platforms/wecom.pyMethod:
_decrypt_file_bytes()(around line 1013)Testing
Verified on production WeCom integration:
Before fix:
Incorrect paddingerror in logsAfter fix: Images processed successfully (JPEG format verified)
Impact