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 that is already
released. 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/vszbqy1wvgvy4ol7ckdjgg648z0kqr4g
Reporter: Yu Bao from PayPal Cybersecurity Team
Disposition: HARDENING -- not a vulnerability; no CVE; hardened in
Commons Codec 1.23.0
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 ==
`Sha2Crypt`, which implements the SHA-256 and SHA-512 variants of
crypt(3) and is reached through `Crypt.crypt`, reads the iteration
count from the `rounds=N` token of the salt string. The value is
clamped to the range [1000, 999,999,999] and the cost of the hash is
linear in it: the reporter measured about 110 seconds of single-core
CPU for `rounds=999999999`. The reporter limited the scope to
applications that hash data with a salt string influenced by an
attacker, such as hash-generation endpoints or migration tools that
re-hash with salts from an untrusted feed, and explicitly excluded the
usual verification pattern `stored.equals(crypt(entered, stored))`. The
reporter proposed a configurable maximum number of rounds.
== PMC assessment ==
This is NOT a vulnerability. The `rounds=` parameter is part of the
crypt(3) format, and its range matches the one accepted by glibc and
other implementations. In the usual verification pattern, the stored
hash, including its `rounds=` value, is trusted: an adversary able to
change it can simply replace it with the hash of a known password. An
application that hashes passwords with salts from an untrusted source
is responsible for validating them, as it would be with any other
crypt(3) implementation:
https://commons.apache.org/threat-model-0.1.0.html
== Hardening ==
We nevertheless agree that a library default can be safer than the
format's maximum. Commons Codec 1.23.0:
- limits `rounds=` to 1,000,000 by default,
- limits passwords to 4096 bytes by default,
- allocates a single `MessageDigest` per call instead of one per
round.
Both limits are configurable with system properties, for deployments
that legitimately need higher values; see the `Sha2Crypt` Javadoc.
== References ==
Threat model:
https://commons.apache.org/threat-model-0.1.0.html
Security policy:
https://commons.apache.org/security.html
Commons Codec release notes:
https://commons.apache.org/proper/commons-codec/changes.html
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]