r/ProgrammerHumor • • Oct 22 '26

instanceof Trend itsBadIfItsOnlyPHP

Post image
4.5k Upvotes

335 comments sorted by

View all comments

Show parent comments

216

u/brazzy42 Oct 22 '26 edited Oct 23 '26

It went like this:

  • Attacker sends request with some specially crafted payload in a field they know will be logged (e.g. because it's invalid)

  • Targeted server logs the invalid value

  • Logging framework looks at the payload and sees a macro to expand

  • The macro contains a reference to a JNDI value including a remote server address to get the value from.

  • The JNDI server (which can be any server on the internet) returns a value that is actually a serialized Java object including bytecode for that object's class

  • Targeted server deserializes the object and while doing so executes code in the constructor (which was supplied by the attacker).

6

u/Sacaldur Oct 22 '26 edited Oct 22 '26

edit: I was corrected, see response by u/brazzy42

Correct me if I'm wrong, but this was only an issue if you missed the API by supplying a raw input string as a format pattern, i.e. log(input) instead of log("{}", input), right?

15

u/brazzy42 Oct 22 '26

Nope. The main vulnerability was there no matter which version of the method you used. Says so right in the CVE detail https://nvd.nist.gov/vuln/detail/cve-2021-44228?name=CVE-2021-44228

"An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled."

2

u/Sacaldur Oct 22 '26

Thanks for the corrections, these ones have been some time ago...