# CVE-2026-27654 PoC-1: write primitive. Tested on aarch64.
FROM --platform=linux/arm64 ubuntu:24.04

RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential libpcre2-dev zlib1g-dev wget ca-certificates python3 \
    && rm -rf /var/lib/apt/lists/*

# Build nginx 1.29.5 with DAV module
RUN wget -q https://nginx.org/download/nginx-1.29.5.tar.gz \
    && tar xzf nginx-1.29.5.tar.gz \
    && cd nginx-1.29.5 \
    && ./configure --with-http_dav_module --without-http_rewrite_module \
    && make -j"$(nproc)" \
    && make install \
    && cd / && rm -rf nginx-1.29.5 nginx-1.29.5.tar.gz

# WebDAV alias root (39 chars: /home/ubuntu/ + 25 a's + /)
# Target webroot, writable by the worker (PoC runs nginx as root with
# master_process off, so this is automatically writable; on a real
# deployment /var/www/html would need to be chowned to www-data).
RUN mkdir -p /home/ubuntu/nginx-lab/client_body_temp \
             /home/ubuntu/aaaaaaaaaaaaaaaaaaaaaaaaa \
             /var/www/html

COPY nginx.conf                    /home/ubuntu/nginx.conf
COPY nginx-merge-slashes-off.conf  /home/ubuntu/nginx-merge-slashes-off.conf
COPY poc.py                        /home/ubuntu/poc.py
COPY poc_slashes.py                /home/ubuntu/poc_slashes.py

WORKDIR /home/ubuntu

CMD ["python3", "poc.py", \
     "--nginx-bin", "/usr/local/nginx/sbin/nginx", \
     "--nginx-conf", "/home/ubuntu/nginx.conf"]
