fix(dockerfile): disable followlinks in Jinja2 FileSystemLoader#5612
Open
ibondarenko1 wants to merge 1 commit into
Open
fix(dockerfile): disable followlinks in Jinja2 FileSystemLoader#5612ibondarenko1 wants to merge 1 commit into
ibondarenko1 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
generate.pyconfiguresFileSystemLoader(templates_path, followlinks=True)in two places (built-in templates loader and user-template overlay loader). Jinja2 default isfollowlinks=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
TemplateNotFounderror and need to copy the file directly instead. Search ofgh issues/PRsshows no reports of this pattern in use; ship with a release-notes line.Testing
pytest tests/unit/_internal/container/test_generate.py(existing).dockerfile_templatefield, verify it still renders.