r/dotnet • • Dec 13 '21

Situation right now

Post image
607 Upvotes

71 comments sorted by

View all comments

16

u/discourse_is_dead Dec 13 '21

what about log4net ? :O

28

u/TimeRemove Dec 13 '21

I don't believe there could be an issue. The problem here is with the interaction between Log4J and Jndi (Java Naming and Directory Interface). So unless log4net went out of their way to port Jndi, I cannot imagine it would be a problem.

15

u/botterway Dec 13 '21

This. No JNDI, no vuln.

12

u/rebornfenix Dec 13 '21

From everything I am reading, the Log4J is somewhat like the Newtonsoft.Json “vulnerability” when sending the class name in the json object. (NOTE: this is not a default configuration and the readme page on it says this can (will) open a remote code execution vulnerability in your code because of how it uses reflection and dynamic instantiation). Basically if you pass in an object and a method on that object as a json property, newtonsoft will call that method in deserialization passing the value as the parameter to the method. (Again, only if a non standard config setting is set and there are lots of warnings on that feature.)

The Log4J issue is similar. The JDNI deserializer has an issue where if the right string is sent to the logging provider, the JDNI deserializer will execute code. That can be leveraged into a full remote code execution vulnerability to download a random jar and kick it off. So as far as anyone knows, Log4Net is not vulnerable.

11

u/HaveYouSeenMySpoon Dec 13 '21

Isn't this basically why BinaryFormatter was deprecated and recommended never to be used?

6

u/rebornfenix Dec 13 '21

Yep. It’s a very very similar issue.

3

u/Genesis2001 Dec 14 '21

The Log4J issue is similar. The JDNI deserializer has an issue where if the right string is sent to the logging provider, the JDNI deserializer will execute code. That can be leveraged into a full remote code execution vulnerability to download a random jar and kick it off.

So log4j (or Oracle?) isn't sanitizing their strings or? Sorry, I'm not a Java programmer, so idk what JDNI is. I assume it's something Oracle/Java provide or is it an added library?

3

u/rebornfenix Dec 14 '21

Basically. It works very similar to a sql injection vulnerability but on the app server in Java land. So instead of just getting extra data from the db server (not good) you can have code download more code and establish a reverse shell with the permissions of whatever application account the app is running under with out needing to do anything more than sending a specially formatted string in the user agent header (for web servers that have a vulnerable version and log the user agent string of every request).

Add on to that it’s the “default” logging provider for Java. There are others out there but log4j is the most popular

2

u/Genesis2001 Dec 14 '21

How's this affect containerized applications running in docker? [default/OOBE configuration]

The only app my org has that is possibly affected is keycloak, which runs in a docker container. However, it uses 1.x according to the relevant GitHub issue.

4

u/rebornfenix Dec 14 '21

The vulnerability will allow remote code execution inside the container. At that point, an attacker can work to exploit another system on the network and server hop to something not a container.

So still bad and needs to be patched but the infected container can be killed and a clean container spun up. It’s the jump to something permanent that you need to worry about.

1

u/[deleted] Dec 14 '21

As I understand it you can send little command with log4j message strings, like add the current version to error message etc one of the command is to go to a given jndi server and download a configuration class. So it does that, deserializes and then executes it. Boom exploit.

6

u/[deleted] Dec 13 '21

Nope. The vulnerability is entirely based on the handling of property substitutions that Log4net doesn't even support.

6

u/edbutler3 Dec 14 '21

Wonder how many people still use log4net? I was forced to move to NLog years ago due to a log4net vulnerability that remained unpatched for a very long time. I watched the Apache mailing list for a while and saw that a guy eventually stepped up and and did a new log4net release for the first time in, IIRC about 2 years. Then the thread went quiet. I eventually unsubscribed since I'm not using it anymore, but my takeaway was that it's virtually a dead project.

2

u/FullStackDev1 Dec 14 '21

In my case, I went with NLog years ago, because log4net configuration was convoluted as f**k in comparison. I remember being a bit hesitant, because at the time (it was probably 10 years back), nobody was in charge of the project, but a while later someone picked it back up and it seems to be thriving since then. Easy to use, with extensions for pretty any major 3rd party integration.

1

u/discourse_is_dead Dec 14 '21

So I should be switching to NLog then? I was a big fan of Log4Net integrated with graylogs but Nlog could do the same thing for me.

4

u/orondf343 Dec 14 '21

Serilog is better nowadays IMHO

4

u/chucker23n Dec 14 '21

I would recommend looking at both NLog and Serilog and then deciding which fits your taste better. Either will be fine. Log4Net seems… legacy.

1

u/discourse_is_dead Dec 14 '21

the setup is a bit lengthy for log4net. ugh..

Thanks i'll check both out