GHSA-4qm4-8hg2-g2xm

Suggest an improvement
Source
https://github.com/advisories/GHSA-4qm4-8hg2-g2xm
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/10/GHSA-4qm4-8hg2-g2xm/GHSA-4qm4-8hg2-g2xm.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-4qm4-8hg2-g2xm
Aliases
Published
2024-10-17T19:30:03Z
Modified
2024-10-18T16:33:38.035772Z
Summary
MessagePack allows untrusted data to lead to DoS attack due to hash collisions and stack overflow
Details

Impact

When this library is used to deserialize messagepack data from an untrusted source, there is a risk of a denial of service attack by an attacker that sends data contrived to produce hash collisions, leading to large CPU consumption disproportionate to the size of the data being deserialized.

This is similar to a prior advisory, which provided an inadequate fix for the hash collision part of the vulnerability.

Patches

The following steps are required to mitigate this risk.

  1. Upgrade to a version of the library where a fix is available. If upgrading from v1, check out our migration guide.
  2. Review the steps in this previous advisory to ensure you have your application configured for untrusted data.

Workarounds

If upgrading MessagePack to a patched version is not an option for you, you may apply a manual workaround as follows:

  1. Declare a class that derives from MessagePackSecurity.
  2. Override the GetHashCollisionResistantEqualityComparer<T> method to provide a collision-resistant hash function of your own and avoid calling base.GetHashCollisionResistantEqualityComparer<T>().
  3. Configure a MessagePackSerializerOptions with an instance of your derived type by calling WithSecurity on an existing options object.
  4. Use your custom options object for all deserialization operations. This may be by setting the MessagePackSerializer.DefaultOptions static property, if you call methods that rely on this default property, and/or by passing in the options object explicitly to any Deserialize method.

References

For more information

If you have any questions or comments about this advisory:

References

Affected packages

NuGet / MessagePack

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
2.5.187

Affected versions

0.*

0.1.0-beta
0.2.0-beta
0.2.1-beta
0.2.2-beta
0.2.3-beta
0.3.0-beta
0.4.0
0.4.1
0.4.2
0.5.0
0.6.0
0.6.1
0.7.0
0.7.2
0.8.0
0.8.1
0.8.2
0.8.3
0.8.4
0.8.5

1.*

1.0.0
1.0.1
1.0.2
1.0.3
1.1.0
1.1.1
1.1.1.1
1.1.2
1.2.0
1.2.0.1
1.2.0.2
1.2.1
1.2.2
1.2.3
1.3.0
1.3.1
1.3.1.1
1.3.2
1.3.3
1.4.0
1.4.1
1.4.2
1.4.3
1.4.4
1.5.0
1.5.0.1
1.5.0.2
1.5.1
1.6.0
1.6.0.1
1.6.0.2
1.6.0.3
1.6.1
1.6.1.1
1.6.1.2
1.6.2
1.7.0
1.7.1
1.7.2
1.7.3
1.7.3.1
1.7.3.2
1.7.3.3
1.7.3.4
1.7.3.7
1.8.71-beta
1.8.74
1.8.80
1.9.3-g129239b107
1.9.3
1.9.11

2.*

2.0.107-alpha
2.0.108-alpha
2.0.110-alpha
2.0.110-alpha-g1e44a9106f
2.0.119-beta
2.0.123-beta
2.0.171-beta
2.0.204-beta
2.0.221-beta
2.0.231-rc
2.0.270-rc
2.0.299-rc
2.0.323
2.0.335
2.1.80
2.1.90
2.1.115
2.1.143
2.1.152
2.1.165
2.1.194
2.2.36-alpha
2.2.44-rc
2.2.60
2.2.85
2.2.113
2.3.58-alpha
2.3.73-alpha
2.3.75
2.3.85
2.3.112
2.4.14-alpha
2.4.23-alpha
2.4.35
2.4.59
2.5.64-alpha
2.5.94
2.5.103
2.5.108
2.5.124
2.5.129
2.5.140
2.5.168
2.5.171
2.5.172

NuGet / MessagePack

Package

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.6.95-alpha
Fixed
3.0.214-rc.1

Affected versions

2.*

2.6.95-alpha
2.6.100-alpha

3.*

3.0.54-alpha
3.0.111-alpha
3.0.129-beta
3.0.134-beta
3.0.208-rc-0001