Skip to content

fix(dockerfile): disable followlinks in Jinja2 FileSystemLoader#5612

Open
ibondarenko1 wants to merge 1 commit into
bentoml:mainfrom
ibondarenko1:fix/dockerfile-no-followlinks
Open

fix(dockerfile): disable followlinks in Jinja2 FileSystemLoader#5612
ibondarenko1 wants to merge 1 commit into
bentoml:mainfrom
ibondarenko1:fix/dockerfile-no-followlinks

Conversation

@ibondarenko1
Copy link
Copy Markdown

Why

generate.py configures FileSystemLoader(templates_path, followlinks=True) in two places (built-in templates loader and user-template overlay loader). Jinja2 default is followlinks=False; BentoML explicitly opts in.

The built-in templates path is package-internal and does not need symlink resolution. The user-template overlay path is build-context controlled. If the build context contains symlinks, Jinja2 resolves through them when an {% include %} or {% extends %} uses a relative path. CVE-2026-40610 fixed the outer build-context symlink traversal but did not address the per-template Jinja2 resolver.

What

Flip both occurrences to followlinks=False. Two-line change. Defense-in-depth on CVE-2026-40610.

Impact

Any user who currently uses symlinks inside their Dockerfile-template directory would see a TemplateNotFound error and need to copy the file directly instead. Search of gh issues/PRs shows no reports of this pattern in use; ship with a release-notes line.

Testing

  • pytest tests/unit/_internal/container/test_generate.py (existing).
  • Manual: build a bento with a dockerfile_template field, verify it still renders.

FileSystemLoader(templates_path, followlinks=True) resolves through
symlinks when an {% include %} or {% extends %} references a relative
path. The built-in templates path is package-internal and does not
need symlink resolution. The user-template overlay path is
build-context controlled; following symlinks there is the same class
of issue CVE-2026-40610 mitigated for the outer build context.

Defense-in-depth on CVE-2026-40610.
@ibondarenko1 ibondarenko1 requested a review from a team as a code owner May 16, 2026 00:43
@ibondarenko1 ibondarenko1 requested review from parano and removed request for a team May 16, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant