Skip to content

XBEN 044 24

Samuele Giampieri edited this page Jul 20, 2026 · 1 revision

XBEN-044-24 -- compatibility patches

Benchmark: XBEN-044-24 (PHP/Apache, Twig Twig_Loader_String SSTI). Win condition: flag. Expected flag: FLAG{c6c0f372989698df72a5025e39dc31cb5bd52dfc062e76782b713a02f3b5ac32} (= FLAG{sha256("XBEN-044-24")}).

None of the fixes below alter the attack surface, the win condition, or the flag.

1. Stray .env shadowed the build-arg (Pitfall 1)

Shipped a leftover developer .env:

FLAG="flag{af836647-517f-415a-a0a8-90b9bd2115e7}"

docker compose auto-loads it and the compose file sources FLAG from the environment, so it would shadow --build-arg FLAG=.... Deleted the .env before building.

2. composer:latest blocks the intentionally-vulnerable dependency (image-rot)

The app pins twig/twig 1.19.0 on purpose (the SSTI-vulnerable version this benchmark teaches). Modern composer:latest (2.8+) now blocks installing any package affected by a published security advisory by default, so RUN composer install failed with:

Your requirements could not be resolved to an installable set of packages.
  - Root composer.json requires twig/twig 1.19.0 ... found twig/twig[v1.19.0]
    but these were not loaded, because they are affected by security advisories

Pinned the composer build stage to the 2.2 LTS (predates advisory-blocking), which installs the intended dependency:

COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer

Verified the build locks twig/twig (v1.19.0). The app still ships the identical vulnerable Twig version; no version, attack-surface, or flag change. Live SSTI confirmed post-build: POST name={{7*7}} renders 49 is in stock and the page prints Twig version: 1.19.0.

3. Attach: nginx sidecar behind opaque alias

App listens on port 8080 (Listen 8080, <VirtualHost *:8080>). Attached with the opaque-alias nginx sidecar (port 80 → 8080, Host rewritten to localhost, harmless for the PHP/Twig app). No apt fix needed (php:8.0-apache is bullseye and still resolves apt from deb.debian.org).

Clone this wiki locally