-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dependency net-imap to v0.5.6 [SECURITY] #205
Merged
Merged
Conversation
This file contains 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
Container Scanning Status: ❌ Failure
|
tpendragon
approved these changes
Feb 12, 2025
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.
This PR contains the following updates:
0.5.5
->0.5.6
GitHub Vulnerability Alerts
CVE-2025-25186
Summary
There is a possibility for denial of service by memory exhaustion in
net-imap
's response parser. At any time while the client is connected, a malicious server can send can send highly compresseduid-set
data which is automatically read by the client's receiver thread. The response parser usesRange#to_a
to convert theuid-set
data into arrays of integers, with no limitation on the expanded size of the ranges.Details
IMAP's
uid-set
andsequence-set
formats can compress ranges of numbers, for example:"1,2,3,4,5"
and"1:5"
both represent the same set. WhenNet::IMAP::ResponseParser
receivesAPPENDUID
orCOPYUID
response codes, it expands eachuid-set
into an array of integers. On a 64 bit system, these arrays will expand to 8 bytes for each number in the set. A malicious IMAP server may send specially craftedAPPENDUID
orCOPYUID
responses with very largeuid-set
ranges.The
Net::IMAP
client parses each server response in a separate thread, as soon as each responses is received from the server. This attack works even when the client does not handle theAPPENDUID
orCOPYUID
responses.Malicious inputs:
Simple way to test this:
Fixes
Preferred Fix, minor API changes
Upgrade to v0.4.19, v0.5.6, or higher, and configure:
This replaces
UIDPlusData
withAppendUIDData
andCopyUIDData
. These classes store their UIDs asNet::IMAP::SequenceSet
objects (not expanded into arrays of integers). Code that does not handleAPPENDUID
orCOPYUID
responses will not notice any difference. Code that does handle these responses may need to be updated. See the documentation for UIDPlusData, AppendUIDData and CopyUIDData.For v0.3.8, this option is not available.
For v0.4.19, the default value is
true
.For v0.5.6, the default value is
:up_to_max_size
.For v0.6.0, the only allowed value will be
false
(UIDPlusData
will be removed from v0.6).Mitigation, backward compatible API
Upgrade to v0.3.8, v0.4.19, v0.5.6, or higher.
For backward compatibility,
uid-set
can still be expanded into an array, but a maximum limit will be applied.Assign
config.parser_max_deprecated_uidplus_data_size
to set the maximumUIDPlusData
UID set size.When
config.parser_use_deprecated_uidplus_data == true
, larger sets will raiseNet::IMAP::ResponseParseError
.When
config.parser_use_deprecated_uidplus_data == :up_to_max_size
, larger sets will useAppendUIDData
orCopyUIDData
.For v0.3,8, this limit is hard-coded to 10,000, and larger sets will always raise
Net::IMAP::ResponseParseError
.For v0.4.19, the limit defaults to 1000.
For v0.5.6, the limit defaults to 100.
For v0.6.0, the limit will be ignored (
UIDPlusData
will be removed from v0.6).Please Note: unhandled responses
If the client does not add response handlers to prune unhandled responses, a malicious server can still eventually exhaust all client memory, by repeatedly sending malicious responses. However,
net-imap
has always retained unhandled responses, and it has always been necessary for long-lived connections to prune these responses. This is not significantly different from connecting to a trusted server with a long-lived connection. To limit the maximum number of retained responses, a simple handler might look something like the following:Proof of concept
Save the following to a ruby file (e.g:
poc.rb
) and make it executable:Use
ulimit
to limit the process's virtual memory. The following example limits virtual memory to 1GB:Release Notes
ruby/net-imap (net-imap)
v0.5.6
Compare Source
What's Changed
🔒 Security Fix
Fixes CVE-2025-25186 (GHSA-7fc5-f82f-cx69): A malicious server can exhaust client memory by sending
APPENDUID
orCOPYUID
responses with very largeuid-set
ranges.Net::IMAP::UIDPlusData
expands these ranges into arrays of integers.Fix with minor API changes
Set
config.parser_use_deprecated_uidplus_data
tofalse
to replaceUIDPlusData
withAppendUIDData
andCopyUIDData
. These classes store their UIDs asNet::IMAP::SequenceSet
objects (not expanded into arrays of integers). Code that does not handleAPPENDUID
orCOPYUID
responses should not see any difference. Code that does handle these responses may need to be updated.For v0.3.8, this option is not available
For v0.4.19, the default value is
true
.For v0.5.6, the default value is
:up_to_max_size
.For v0.6.0, the only allowed value will be
false
(UIDPlusData
will be removed from v0.6).Mitigate with backward compatible API
Adjust
config.parser_max_deprecated_uidplus_data_size
to limit the maximumUIDPlusData
UID set size.When
config.parser_use_deprecated_uidplus_data == true
, larger sets will crash.When
config.parser_use_deprecated_uidplus_data == :up_to_max_size
, larger sets will useAppendUIDData
orCopyUIDData
.For v0.3,8, this limit is hard-coded to 10,000.
For v0.4.19, this limit defaults to 1000.
For v0.5.6, this limit defaults to 100.
For v0.6.0, the only allowed value will be
0
(UIDPlusData
will be removed from v0.6).Please Note: unhandled responses
If the client does not add response handlers to prune unhandled responses, a malicious server can still eventually exhaust all client memory, by repeatedly sending malicious responses. However,
net-imap
has always retained unhandled responses, and it has always been necessary for long-lived connections to prune these responses. This is not significantly different from connecting to a trusted server with a long-lived connection. To limit the maximum number of retained responses, a simple handler might look something like the following:Added
SequenceSet#each_ordered_number
by @nevans in https://github.com/ruby/net-imap/pull/386SequenceSet#find_ordered_index
by @nevans in https://github.com/ruby/net-imap/pull/396SequenceSet#ordered_at
by @nevans in https://github.com/ruby/net-imap/pull/397APPENDUID
/COPYUID
, 🗑️ Deprecate UIDPlusData by @nevans in https://github.com/ruby/net-imap/pull/401Fixed
SequenceSet#append
when its@string
is nil by @nevans in https://github.com/ruby/net-imap/pull/376#starttls
error from receiver thread by @nevans in https://github.com/ruby/net-imap/pull/395Documentation
SequenceSet#cover?
documentation by @nevans in https://github.com/ruby/net-imap/pull/379Other Changes
uid-set
assequence-set
without*
by @nevans in https://github.com/ruby/net-imap/pull/393Miscellaneous
Full Changelog: ruby/net-imap@v0.5.5...v0.5.6
Configuration
📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.