226 points · by scblzn · 4y ago · 173 comments
I read a lot of negative things about log4j these days, but people forget how great log4j was compared to whatever the JDK provided us with. It served a useful purpose for most developers, and inspired many libraries in other languages.
Take care!
From a quick glance at the comments this looks like a minor issue due to the attack vector being very, very small — i.e., the attacker must have access to where the logging pattern is defined, and if that is the case, this attack is probably not the most worrisome they could pull off.
I hope I'm not wrong, otherwise we'll be patching everything again.
Plenty of existing code does things like:
log.info(“foo: “ + request.getFoo());
Rather than using fixed format strings and {} place holders. You’re not supposed to, but it’s far from uncommon.log.debug(xmldoc)
The debug method took a string, and Java was converting the xmldoc to a string. This was back in the 1.4/1.5 days.
log.Print(fixed_string)
log.Printf(format_string, args...)
Simple, unambiguous.So if this is true:
> In 2.16.0: if the suspect string is put in the PatternLayout, then that specific patternLayout will crash when loaded and replace itself with a PatternLayout that just logs what is handed to it with no formatting
> logging the suspect string seems to have no affect, and it is passed untransformed to both System.Out or the file I specified as expected.
Then not a big deal. I'm sure there's a number of ways I could mess up the config file and end up with no formatting. Should I be submitting CVE's for those too?
12/18 - https://nvd.nist.gov/vuln/detail/CVE-2021-45105 Score: -
12/14 - https://nvd.nist.gov/vuln/detail/CVE-2021-45046 Score: 3.7
12/14 - https://nvd.nist.gov/vuln/detail/CVE-2021-4104 Score: 8.1
12/10 - https://nvd.nist.gov/vuln/detail/CVE-2021-44228 Score: 10.0
And the new CVE-2021-45105 is self-assessed to have a CVSS of 7.5/10 (see the same page above).
It's goods new so far that with more people/time and attention paid to the log4j exloits, the vulnerabilities are just getting narrower in scope and lesser in impact.
If you shine a thousand spotlights at a problem, you'll find more problems.
Glad this library is finally getting the code review it deserves. Hope the whole SDK gets the fine-tooth comb treatment it is overdue.
Like it or not... 50% of the Internet runs on Java (and my statistics are 50% accurate. I swear, 50% of the time.)
Polished, masterful, crafted product is hard to KPI for.
Highly unlikely. Most of the internet runs on PHP, WordPress more often than not (there are stats on that, but I'm on mobile and can't check right now).
Wow, a LOGGER engine that execute arbitrary code. wow
Ironically, tho, my tool to scan all our jar files for log4j has revealed a panic in archive/zip, something to do with a zero length file name.
The last time I benchmarked java.util.logging though, it lost out to log4j by a wide enough margin. Has anyone done any benchmarking lately?
Who needs decades of battle tested, proven methods and tools? Who needs thousands of human hours behind thousands of GitHub issues and pull requests?
Let’s do everything from scratch!
Hm, why is there JavaScript fatigue and 10 new frameworks every month?
I'm not a Java developer, so I don't know, but is there something "wrong" with java.util.logging?
It's quite depressing.
Sometimes I wish I had more time to rewrite all Java stack, from logging to http server with dumb simple inefficient but understandable code.
May be I should just move to Go. It seems to better reflect that approach. But I like Java language...
Our field is royally screwed, whole thing needs to be rethought.
Any such field is in varying degrees of messiness (medicine, agriculture, architecture, you name it). Mistakes are made constantly, have real consequences (people die), and hopefully are discovered and admitted sooner rather than later.
All we can is (cliché warning) do our best, keep growing, act responsibly and be humble.
At one point, it seems that "everyone use this so it must be secure enough" replaced "we're a large company, did we spend enough time reviewing code of the open source stuff we use?".
It seems the Linus's quote "given enough eyeballs, all bugs are shallow", is not really true.
Imagine if a well funded agency like the NSA employed at least hundreds of full time developers whose job would be to sniff for those vulns. I'm pretty sure you could automate searching for those vulns, and that only the NSA has such tool.
Well that's the issue isn't it. Very few have read the log4j code, even though thousands of developers have incorporated it into they projects. Right now all eyes are on log4j and the bugs a showing up quicker than the log4j users can patch.
If you want to find issues in a code library, embed it somewhere in the hot code paths of a game or DRM system to maximize the number of eyeballs looking at every single instruction.
The problem is, there are a vanishingly small amount of engineers talented enough to find these kinds of things.
And if NSA wanted to hire a few hundred they’d have to go the defense contractor route which will inevitably lead to them getting 1 great engineer and 499 extremely mediocre ones.
It is about the willingness to invest, not brainpower. If I was tasked to "improve security" at my current project, I could instantly tell you things that could be looked into, even though reasonably precautions are already taken and there are already processes around it in place. I bet it is the same for most programmers.
Given that you're mentioning fuzzers and a decent source of inputs you could use, I think you're either underestimating yourself or overestimating the actual "average" of software developers.
I think it is called Linus' Law but the quote is by ESR
I am 1000% in favor of apps managing their own logs. Generic system agents can collect and ship arbitrary logs remotely for storage/processing.
Putting /var on its own partition has always been recommended.
When default installer/partitioners fail to do so, I assume it's a habit picked up from desktop-oriented Linux distros.
Logging to /opt would clearly be a bug of the brown M&M variety -- it would make me question other decisions made by the developers.
And looking at the documentation, it has a very Java idea of rotation, where it supports every possible use case as a main case, and the examples expect that you will set it with the most insane defaults from day zero.
I decided to just ditch it and write from scratch something api-compatible, but extremely cut-down on "features".
Maybe someone would release something along this line. I can't.
LibreSSL is a complete rewrite of the openssl functionality with drastically fewer features. Same goes for CARP.
Maybe running software with minimal defaults is a good thing, as it forces the users of the system/library/whatever to think about its behaviour and usecase.
That's actually a great thing for the long term health of the project - it's getting a whole lot of free auditing right now. Many millions of dollars worth.
There's an old joke, goes something like: “Recently, I was asked if I was going to fire an employee who made a mistake that cost the company $600,000. No, I replied, I just spent $600,000 training him. Why would I want somebody to hire his experience?”. That's what's happening for log4j right now. A lot of eyes, a lot of attention, stuff's going to come out - and long-term it'll be better off for it. Shutting it down and moving to something else that hasn't been tested in battle isn't the pay-off it sounds like.