Skip to content

Harden Jinja template rendering with sandboxing#6888

Open
tcoatswo wants to merge 1 commit into
canonical:mainfrom
tcoatswo:fix/cloud-init-jinja-ssti-ready
Open

Harden Jinja template rendering with sandboxing#6888
tcoatswo wants to merge 1 commit into
canonical:mainfrom
tcoatswo:fix/cloud-init-jinja-ssti-ready

Conversation

@tcoatswo
Copy link
Copy Markdown

Summary

Harden cloud-init Jinja template rendering by switching to a sandboxed Jinja environment.

Changes

  • replace direct jinja2.Template rendering with SandboxedEnvironment
  • handle SecurityError in the Jinja payload handler so unsafe templates are ignored cleanly
  • add unit regressions covering unsafe attribute access in templater and handler paths

Verification

  • reproduced the pre-fix behavior directly in Python: template expressions could access class, mro, and subclasses
  • verified post-fix behavior directly in Python: unsafe attribute access is blocked, and handler rendering returns None with a warning
  • I could not run the repo pytest suite on this host because the Python environment here does not have the pytest module installed

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