The vulnerability lies in the generation of Dockerfiles where environment variable names from the bentofile.yaml were used without proper sanitization. Specifically, the envs[*].name field was not escaped, allowing an attacker to inject newlines and arbitrary RUN commands into the resulting Dockerfile. When a user builds a container from this malicious bento using bentoml containerize, the injected commands execute on the host system.
The patch addresses this by introducing a new Jinja2 filter called normalize_line, which strips newlines and collapses whitespace, effectively preventing the injection. The core vulnerable functions, generate_dockerfile and generate_containerfile, were updated to use a new centralized Jinja2 environment (build_environment) where this sanitizing filter is applied to the env.name variable within the base_v2.j2 template. Any runtime profile during the exploitation of this vulnerability would show these functions being called to generate the malicious Dockerfile.