The Apache Commons PMC has received the security report referenced
below. After analysis, we classified it as HARDENING: not a
vulnerability, but a defense-in-depth improvement. In the interest of
transparency and so that the community and other researchers can
benefit from the analysis, we are disclosing a summary of it.

  Report reference (Apache Commons PMC / security archive):
    https://lists.apache.org/thread.html/78k2mj90gnl2k63tzvoo2vr3dcslczwn
  Reporter: buiih (buihuyyy)
  Disposition: HARDENING -- not a vulnerability; no CVE; tracked in
    COLLECTIONS-903
  TLP:CLEAR (this message may be redistributed without restriction)

The reporter was informed of this classification and of our intent to
publish this summary.


== Summary of the report ==

`AbstractHashedMap.doReadObject` and `AbstractReferenceMap.doReadObject`
validate the serialized load factor, but allocate the backing table
straight from the serialized capacity, before reading any entry. This
affects `HashedMap`, `LinkedMap`, `CaseInsensitiveMap`, `LRUMap`,
`ReferenceMap` and `ReferenceIdentityMap`. The reporter changed the
capacity of a serialized empty `HashedMap` to 0x1FFFFFFF and showed
that deserializing the resulting 81-byte stream throws an
`OutOfMemoryError` in a JVM with a 128 MB heap. The reporter proposed
validating the capacity, or treating it as a hint and sizing the table
from the number of entries.


== PMC assessment ==

This is NOT a vulnerability. Commons Collections does not support
deserializing untrusted data: the `readObject` methods of its
`Serializable` classes assume the stream comes from a trusted source.
An application that deserializes attacker-controlled bytes is
vulnerable whatever classes are on its classpath; for example, a
stream can declare a huge array directly, with no Commons class
involved:

  https://commons.apache.org/threat-model-0.1.0.html

Applications that must deserialize data of limited trust should use an
`ObjectInputFilter` or Commons IO's `ValidatingObjectInputStream`, and
should not rely on Commons classes to bound resource use.


== Hardening ==

We nevertheless agree that deserialization should validate its input
the same way the constructors do. The next Commons Collections release
will apply the constructors' capacity checks in `doReadObject` and will
limit the initial table to the size that the serialized entries
require.


== References ==

  Threat model:
    https://commons.apache.org/threat-model-0.1.0.html
  Security policy:
    https://commons.apache.org/security.html
  Issue:
    https://issues.apache.org/jira/browse/COLLECTIONS-903

Questions and follow-up are welcome on this list.

On behalf of the Apache Commons PMC,
Piotr P. Karwasz

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to