Skip to content

Commit

Permalink
[v8ctf] fix challenge flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
sroettger committed Jan 10, 2024
1 parent 1fd07e6 commit 28ed93e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
10 changes: 5 additions & 5 deletions v8ctf/chrome-118/challenge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
FROM ubuntu:22.04 as chroot

RUN /usr/sbin/useradd --no-create-home -u 1000 user
RUN /usr/sbin/useradd -u 1000 user

RUN apt-get update && apt-get install -y gnupg2 wget

Expand All @@ -32,10 +32,10 @@ RUN apt-get update && apt-get install -y unzip

RUN mkdir /home/user
# This version is to be released on 2023-11-06
RUN wget 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/118.0.5993.70/linux64/chrome-linux64.zip' -O /home/user/chrome-linux.zip
RUN cd /home/user && unzip chrome-linux.zip && rm chrome-linux.zip
RUN wget 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/118.0.5993.70/linux64/chrome-linux64.zip' -O /opt/chrome-linux.zip
RUN cd /opt && unzip chrome-linux.zip && rm chrome-linux.zip

COPY chal /home/user/
COPY chal /opt/

FROM gcr.io/kctf-docker/challenge@sha256:0f7d757bcda470c3bbc063606335b915e03795d72ba1d8fdb6f0f9ff3757364f

Expand All @@ -53,4 +53,4 @@ CMD kctf_setup && \
kctf_drop_privs \
socat \
TCP-LISTEN:1337,reuseaddr,fork \
EXEC:"kctf_pow nsjail --config /home/user/nsjail.cfg -- /home/user/chal",stderr
EXEC:"kctf_pow nsjail --config /home/user/nsjail.cfg -- /opt/chal",stderr
5 changes: 2 additions & 3 deletions v8ctf/chrome-118/challenge/chal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/bash

CHROME=/home/user/chrome-linux64/chrome
CHROME=/opt/chrome-linux64/chrome

echo "Version: $($CHROME --version | head -n1)"
echo "Please send me a URL to open."
Expand All @@ -10,6 +10,5 @@ if ! echo $url | grep -E '^https?://[A-Za-z0-9.:/?%\-_+&=]*$' -q; then
exit 1
fi

export HOME=/tmp
dbus-daemon --system
dbus-run-session -- $CHROME --headless=new --no-sandbox --disable-crashpad --disable-breakpad --disable-crash-reporter --user-data-dir=/tmp/chrome-userdata --enable-logging=stderr "${url}"
dbus-run-session -- $CHROME --headless=new --no-sandbox --disable-crashpad --disable-breakpad --disable-crash-reporter --enable-logging=stderr "${url}"
5 changes: 5 additions & 0 deletions v8ctf/chrome-118/challenge/nsjail.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ mount: [
fstype: "tmpfs"
rw: true
},
{
dst: "/home/user"
fstype: "tmpfs"
rw: true
},
{
dst: "/run/dbus"
fstype: "tmpfs"
Expand Down
10 changes: 5 additions & 5 deletions v8ctf/chrome/challenge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
FROM ubuntu:22.04 as chroot

RUN /usr/sbin/useradd --no-create-home -u 1000 user
RUN /usr/sbin/useradd -u 1000 user

RUN apt-get update && apt-get install -y gnupg2 wget

Expand All @@ -32,10 +32,10 @@ RUN apt-get update && apt-get install -y unzip

RUN mkdir /home/user
# This version is to be released on 2024-01-12
RUN wget 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.71/linux64/chrome-linux64.zip' -O /home/user/chrome-linux.zip
RUN cd /home/user && unzip chrome-linux.zip && rm chrome-linux.zip
RUN wget 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.71/linux64/chrome-linux64.zip' -O /opt/chrome-linux.zip
RUN cd /opt && unzip chrome-linux.zip && rm chrome-linux.zip

COPY chal /home/user/
COPY chal /opt/

FROM gcr.io/kctf-docker/challenge@sha256:0f7d757bcda470c3bbc063606335b915e03795d72ba1d8fdb6f0f9ff3757364f

Expand All @@ -53,4 +53,4 @@ CMD kctf_setup && \
kctf_drop_privs \
socat \
TCP-LISTEN:1337,reuseaddr,fork \
EXEC:"kctf_pow nsjail --config /home/user/nsjail.cfg -- /home/user/chal",stderr
EXEC:"kctf_pow nsjail --config /home/user/nsjail.cfg -- /opt/chal",stderr
5 changes: 2 additions & 3 deletions v8ctf/chrome/challenge/chal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/bash

CHROME=/home/user/chrome-linux64/chrome
CHROME=/opt/chrome-linux64/chrome

echo "Version: $($CHROME --version | head -n1)"
echo "Please send me a URL to open."
Expand All @@ -10,6 +10,5 @@ if ! echo $url | grep -E '^https?://[A-Za-z0-9.:/?%\-_+&=]*$' -q; then
exit 1
fi

export HOME=/tmp
dbus-daemon --system
dbus-run-session -- $CHROME --headless=new --no-sandbox --disable-crashpad --disable-breakpad --disable-crash-reporter --user-data-dir=/tmp/chrome-userdata --enable-logging=stderr "${url}"
dbus-run-session -- $CHROME --headless=new --no-sandbox --disable-crashpad --disable-breakpad --disable-crash-reporter --enable-logging=stderr "${url}"
5 changes: 5 additions & 0 deletions v8ctf/chrome/challenge/nsjail.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ mount: [
fstype: "tmpfs"
rw: true
},
{
dst: "/home/user"
fstype: "tmpfs"
rw: true
},
{
dst: "/run/dbus"
fstype: "tmpfs"
Expand Down

0 comments on commit 28ed93e

Please sign in to comment.