security(discord): bound image/animation/attachment HTTP response reads - #60222
Closed
isheng-eqi wants to merge 5 commits into
Closed
security(discord): bound image/animation/attachment HTTP response reads#60222isheng-eqi wants to merge 5 commits into
isheng-eqi wants to merge 5 commits into
Conversation
The gateway already strips stale dangerous-confirmation text from replayed history (NousResearch#60110, NousResearch#60117 — fix for NousResearch#59607). The TUI gateway has two session resume paths that sanitize replay history but do not strip stale dangerous confirmations, leaving the same vulnerability unaddressed in TUI sessions. Add strip_stale_dangerous_confirmations() after sanitize_replay_history() in both TUI resume paths (resume_session and the WebUI resume path). Refs: NousResearch#59607, NousResearch#60110, NousResearch#60117
The recent Discord resource-bounding pass (NousResearch#60122, NousResearch#60112, NousResearch#60113) added limits for REST JSON/error response bodies and component label UTF-16 lengths. Four HTTP response reads for image/animation/attachment downloads were left unbounded — an oversized response from a CDN or external URL could OOM the bot. Add _DISCORD_IMAGE_DOWNLOAD_MAX_BYTES (50 MB) and _DISCORD_ATTACHMENT_DOWNLOAD_MAX_BYTES (100 MB) constants, a shared _read_response_bytes_bounded() helper, and apply bounds to: - Batch image download (adapter.py ~2467) - Single image download (adapter.py ~3555) - Animation/GIF download (adapter.py ~3634) - Attachment download (adapter.py ~5799) Refs: NousResearch#60122, NousResearch#60112
Contributor
Author
|
Branch contaminated — rebuilding with clean base from upstream/main. |
This was referenced Jul 27, 2026
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.
What does this PR do?
Extends the Discord resource-bounding pass (#60122, #60112, #60113) to four HTTP response reads for image/animation/attachment downloads that were left unbounded.
An attacker or misconfigured CDN serving a multi-GB response to an
await resp.read()call in the Discord adapter could exhaust memory and crash the bot.Related Issue
Fixes sibling paths of the Discord bounding pass (#60122, #60112).
Type of Change
Changes Made
plugins/platforms/discord/adapter.py: Add_read_response_bytes_bounded()helper, constants (50MB/100MB). Replace 4 unboundedawait resp.read()calls.tests/gateway/test_discord_image_download_bounds.py: Unit tests