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/xm0f8ghwfmwmxrgyw07dlz0p58jl3w5h
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 ==
`Base58.decode(byte[])` and `Base58.decode(String)`, introduced in
Commons Codec 1.22.0, converted Base58 text to bytes by accumulating
each digit into a `BigInteger`. Since the accumulator grows by about
5.86 bits per character, the total cost was quadratic in the input
length, and no input-size limit applied on the decode path. The
reporter measured about 17 seconds of CPU to decode 320,000 characters
and extrapolated about three minutes for a 1 MB input. The reporter
noted that `Base58InputStream` invites inputs of arbitrary length and
proposed a maximum input length and a faster base-conversion algorithm.
== PMC assessment ==
This is NOT a vulnerability. Commons Codec does not claim to safely
process arbitrary malicious input: applications that pass untrusted
data to a codec are responsible for bounding its size first:
https://commons.apache.org/threat-model-0.1.0.html
Base58 is designed for short values, such as keys and addresses, that
are a few dozen characters long. Big-integer base conversion is the
standard way to decode it, and its cost on such values is negligible.
The cost only becomes significant for inputs that are orders of
magnitude longer than any legitimate Base58 value, which the
application chose to accept.
== Hardening ==
We nevertheless agree that Codec should not make this mistake easy.
Commons Codec 1.23.0:
- replaces the `BigInteger` accumulation with a faster word-array
algorithm,
- limits Base58 input to 8192 bytes by default.
Users who decode untrusted Base58 data with Commons Codec 1.22.x should
upgrade to 1.23.0 or reject oversized input before decoding it.
== 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]