Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
Restricts per-notebook html_head_file injection so it only applies in SessionMode.RUN, preventing arbitrary head markup/scripts from being included when a notebook is opened in edit mode.
Changes:
- Gate
app_config.html_head_fileinjection behindmode == SessionMode.RUNinnotebook_page_template. - Add tests asserting: CSS file injection still works in edit mode;
html_head_fileis blocked in edit mode and allowed in run mode; globalhtml_headis still allowed in edit mode.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
marimo/_server/templates/templates.py |
Adds the SessionMode.RUN guard for html_head_file injection in notebook_page_template. |
tests/_server/templates/test_templates.py |
Adds regression tests covering edit vs run behavior for css_file, html_head_file, and global html_head. |
| # html_head_file is blocked in edit mode: it can contain arbitrary scripts | ||
| # and markup that could exfiltrate data or redress the UI. CSS-only styling | ||
| # (css_file) is permitted. Run mode is unaffected. | ||
| if mode == SessionMode.RUN and app_config.html_head_file: | ||
| head_contents = read_html_head_file( |
There was a problem hiding this comment.
The new comment implies css_file is a safe “CSS-only” alternative in edit mode, but _custom_css_block() inlines CSS unescaped, so a malicious CSS file can break out of the <style> tag (e.g., by including </style>), allowing arbitrary HTML/script injection in edit mode. If the goal is to prevent untrusted notebooks from injecting scripts in edit mode, consider either sanitizing/escaping style contents (at minimum neutralize </style sequences) or applying the same mode restriction to css_file as well; otherwise the html_head_file block can be bypassed via css_file.
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.1-dev21 |
📝 Summary