Skip to content

Commit 0d7ff9f

Browse files
Change the setup so that the attacker user doesn't have sudo privileges.
1 parent 26cf2fb commit 0d7ff9f

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

strongSwan/CVE-2018-5388/Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN apt-get update && \
99
tmux screen pkg-config libtool automake sudo libgmp-dev iptables \
1010
xl2tpd module-init-tools supervisor emacs gettext libcap-dev
1111

12+
# Create a vpn group.
1213
RUN groupadd vpn
1314
RUN useradd -g vpn vpn
1415

@@ -18,18 +19,12 @@ RUN cd strongswan && git checkout 5.6.2 && ./autogen.sh && \
1819
./configure --with-capabilities=libcap --with-user=vpn --with-group=vpn && \
1920
make && make install
2021

21-
# switch over to the 'attacker' user, since root access is no longer required
22-
RUN addgroup attacker --gid 1001
23-
RUN adduser attacker --disabled-password --uid 1001 --gid 1001
22+
# Create an 'attacker' user. This user will be a member of the vpn
23+
# group, but does not get superuser privileges.
24+
RUN adduser attacker
2425
RUN adduser attacker vpn
2526

26-
# We need to give the "attacker" user sudo permission so that we can
27-
# start strongswan inside the container. The sudo privileges are not
28-
# used to run the exploit. For that, the attacker only needs to be a
29-
# member of the "vpn" group.
30-
RUN adduser attacker sudo
31-
RUN echo "attacker:x" | chpasswd # sudo password is "x"
32-
27+
# Switch to the attacker user and create the exploit code.
3328
USER attacker
3429
WORKDIR /home/attacker/
3530

@@ -43,3 +38,7 @@ COPY stroke_patch.txt /home/attacker/stroke_patch.txt
4338
RUN cd strongswan && git checkout 5.6.2 && \
4439
git apply ../stroke_patch.txt && \
4540
./autogen.sh && ./configure && make
41+
42+
# Switch back to the root user so that we can start ipsec when we start
43+
# the container.
44+
USER root

strongSwan/CVE-2018-5388/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ First, build the docker image:
2222
docker build . -t strongswan
2323
```
2424

25-
As you can see from the Dockerfile, we have installed strongSwan version 5.6.2. We have also created a user named "attacker". This user is a member of the `vpn` group, so that they can use the [stroke](https://wiki.strongswan.org/projects/strongswan/wiki/IpsecStroke) utility to query the [charon](https://wiki.strongswan.org/projects/strongswan/wiki/Charon) daemon. The attacker user is also a member of the `sudo` group, but this is only to enable us to start `ipsec`. Superuser permissions are not used for the actual attack.
25+
As you can see from the Dockerfile, we have installed strongSwan version 5.6.2. We have also created a user named "attacker". This user is a member of the `vpn` group, so that they can use the [stroke](https://wiki.strongswan.org/projects/strongswan/wiki/IpsecStroke) utility to query the [charon](https://wiki.strongswan.org/projects/strongswan/wiki/Charon) daemon. The attacker does not get other special privileges though. For example, they do not have superuser privileges.
2626

2727
Now start the container:
2828

@@ -33,10 +33,16 @@ docker run --privileged -i -t strongswan
3333
The `--privileged` flag is needed to start `ipsec` inside the container. Do this now:
3434

3535
```
36-
sudo ipsec start # sudo password is "x"
36+
ipsec start
3737
```
3838

39-
Now run the attack:
39+
Now switch to the attacker user account:
40+
41+
```
42+
su - attacker
43+
```
44+
45+
And run the attack:
4046

4147
```
4248
./strongswan/src/stroke/.libs/stroke statusall

0 commit comments

Comments
 (0)