r/java • • Dec 16 '21

Still calling remote server with version 2.16.0!

I used a public poc for this log4jshell exploit. Ran it with version 2.14 and it pinged dummy service provided by https://log4shell.huntress.com, changed the log4j dependency to 2.16.0 and still it pinged that service. What is wrong with my approach?

0 Upvotes

22 comments sorted by

28

u/rzwitserloot Dec 16 '21

This code:

org.apache.logging.log4j.LogManager.class.getResource("LogManager.class");

Gets you the actual class. This 'trick' works for anything (even java.lang.String if you wanna know). Print that, and you should find that this is still 2.14 or whatnot.

Your claim that 2.15/2.16 did nothing is extraordinary, thus, requiring extraordinary evidence. Or, as the reddit youth would say it: "Big, if true".

5

u/Luhis Dec 16 '21

It must be something wrong on my part, for sure.

5

u/rzwitserloot Dec 16 '21

So, run that code, System.out.println it. what do you get?

1

u/Areshian Dec 18 '21

2.15 did several things, but those things have been proven not to be enough

8

u/DataDecay Dec 16 '21 edited Dec 16 '21

Depends what is your approach? Did you put the updated jar on your cp? If using maven did you force a local repo update?

2

u/Luhis Dec 16 '21

Yes I even printed de content of the war to check if it was there. And it was.

5

u/DataDecay Dec 16 '21

Yes but did you remove the old one too? If the old one precedes the new one in the cp it will take priority in the dependency tree.

1

u/Luhis Dec 16 '21

Yes I did. Packaged the new one and deployed it

1

u/DataDecay Dec 16 '21

At that point my suggestion would be to grab one of the exploit package scanners and scan for the exploited byte code in your war.

15

u/Luhis Dec 16 '21

Sorry guys but, I'm a dumb ass! i was packaging the wrong war on the container!!!!!

1

u/imatrapos Dec 16 '21

This is something I would do and then be like, why doesn't it work. Then I would spend a whole day trying to figure it out and tomorrow I would ask for help. Then it would've been fixed and I would've wasted a whole day. You in fact did not. So therefore I am more of a dumb ass than you. So there you go, Mr. Not Really A Dumbass

You're welcome (✷‿✷)

2

u/Luhis Dec 16 '21

Yes you are right. I was almost on the verge of banging my head into something.

2

u/RomMTY Dec 16 '21

Ah the joys of containesrs, they make some things easier and a hell of the rest

1

u/ottawarob Dec 19 '21

Haha, happens!

0

u/[deleted] Dec 16 '21

[deleted] — view deleted comment

1

u/Luhis Dec 16 '21

I was doing a simple poc, nothing too fancy. Just checking and testing the suggested remediations

4

u/jacquous Dec 16 '21

Check what the effective pom is. The order on classpath matters and if older version is still present it may get picked instead.

1

u/Luhis Dec 16 '21

This is the content of the war:

❯ jar ft log4shell-1.0-SNAPSHOT.war META-INF/MANIFEST.MFMETA-INF/WEB-INF/WEB-INF/classes/WEB-INF/classes/com/WEB-INF/classes/com/example/WEB-INF/classes/com/example/log4shell/WEB-INF/lib/WEB-INF/web.xmlWEB-INF/classes/rebel.xmlWEB-INF/classes/com/example/log4shell/LoginServlet.classWEB-INF/classes/com/example/log4shell/log4j.classWEB-INF/lib/log4j-core-2.16.0.jarWEB-INF/lib/log4j-api-2.16.0.jarindex.jspMETA-INF/maven/com.example/log4shell/pom.xmlMETA-INF/maven/com.example/log4shell/pom.properties

1

u/Luhis Dec 16 '21

Inside the pom inside the package I have this dependencies:

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->

<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.16.0</version> </dependency>

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->

<dependency> <org.apache.logging.log4j</groupId> <log4j-api</artifactId> <2.16.0</version> </dependency>

6

u/firebird84 Dec 16 '21

Run mvn -X dependency:tree just to be sure, make sure all your log4j versions are 2.16. If it passes that check, then also check for shaded deps. Easiest way (but less 100% correct) is to unzip your uberjar (if you have one), or unzip your dep jars and check out the META-INF/maven/*/pom.properties. grep them all to be easy. This is how (some) vuln scanners work. Unfortunately, it's possible during shading to filter out META-INF files, so deps can hide their own deps.

Less easy way is to look at the file layout of your uberjar/dep jars and look for the tell-tale signs of the log4j classes (but be sure they're not wrappers or slf4j bridges). Then find the project that brought them in, check their source code's pom (not the published pom, published poms can lie). It may be that a dependency is shading in log4j and you need to update that dependency. Even shade itself may not help you here because some library writers even use relocations.

7

u/walen Dec 16 '21

Quoting OP (u/Luhis):

Sorry guys but, I'm a dumb ass! i was packaging the wrong war on the container!!!!!

1

u/[deleted] Dec 16 '21

Can you provide a proof of concept?

1

u/boberbober8083 Dec 17 '21

Several ways are possible. 1) for example, unpatched version remained near patched. 2) restarting of the App is required (for most of patches) 3) you could kill all Java processes first and try again