# CVE-2026-27654 source-path corruption PoC.
# Single COPY request, no PUT, copies /etc/passwd to /tmp/passwd.proof.
# Tested on aarch64.
FROM --platform=linux/arm64 debian:12

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

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

# Pivot dir: the surviving source-path prefix (first 23 bytes of the
# alias root), which the kernel must be able to walk through to resolve
# `..`.  The full alias root (/tmp/lab/aaa.../, 39 chars) need not exist.
RUN mkdir -p /tmp/lab/logs /tmp/lab/temp /tmp/lab/www /tmp/lab/aaaaaaaaaaaaaa

COPY nginx.conf /tmp/lab/nginx.conf
COPY poc_src.py /tmp/lab/poc_src.py
COPY trace1.gdb /tmp/lab/trace1.gdb

WORKDIR /tmp/lab

CMD ["python3", "poc_src.py", \
     "--nginx-bin", "/usr/local/nginx/sbin/nginx", \
     "--nginx-conf", "/tmp/lab/nginx.conf"]
