Skip to content

Keep templates and macros per weblog, and bound render output and time - #366

Merged
snoopdave merged 3 commits into
roller-6.1.xfrom
template-isolation-6.1.x
Nov 21, 2026
Merged

snoopdave merged 3 commits into
roller-6.1.xfrom
template-isolation-6.1.x

Conversation

@snoopdave

@snoopdave snoopdave commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A smaller alternative to #335. It keeps #335's template isolation and output/time limits, and leaves out the in-memory render budget (RenderLimitParser, RenderLimitUberspector, StringGrowth, DeadlineRegex, ValueLimits). It also adds the security model to 6.1.x and puts template resource use out of scope.

  • Templates per weblog. While a weblog renders, #parse and #include load only that weblog's stored templates. Inline macros are local to the template that defines them (local_scope=true, replace_global=true). Library macros stay global. Error pages no longer show template ids.
  • Output and time limits. A render fails, and is not cached, once it writes more than rendering.maxOutputChars (10 MB), inserts a longer string, or runs past rendering.maxRenderSeconds (30 s). Writes, reference insertions and every #foreach pass check the limits. A #foreach of more than 100,000 passes fails the render.
  • Security model. Copies SECURITY.md and docs/security-model.md from Add security model and SECURITY.md #202, which 6.1.x didn't have. Adds "Resource use by templates" to Not vulnerabilities: a global admin who turns on custom themes (off by default) trusts weblog Admins not to abuse the server's CPU and memory. The template sandbox stays a security boundary: no Java calls, no file reads, no access to other weblogs.

Status: all 28 test classes under ui/rendering pass on JDK 11 and 17 (121 tests). The limits don't stop every expensive template, which the model change now says. When roller-6.1.x is next merged into master, docs/security-model.md will conflict with master's copy (master removed pings and OAuth in #241). Keep master's text and add the new entries.

Behavior change: a custom theme that calls a macro defined in a template it doesn't #parse now prints the call as text. See CHANGES.md.

snoopdave and others added 2 commits November 21, 2026 14:11
A slimmer version of #335 without the in-memory render budget. #parse and
#include load only the rendering weblog's own templates, inline macros are
local to the template that defines them, and a render fails once it writes
more than rendering.maxOutputChars, runs past rendering.maxRenderSeconds,
or makes more than 100,000 #foreach passes.

Co-authored-by: Matt Raible <matt@raibledesigns.com>
@snoopdave

Copy link
Copy Markdown
Contributor Author

It's not that much smaller.

@snoopdave snoopdave closed this Nov 21, 2026
@snoopdave snoopdave reopened this Nov 21, 2026
… scope

Copies SECURITY.md and docs/security-model.md from #202. A global admin who
turns on custom themes trusts weblog Admins not to abuse the server's CPU
and memory; the template sandbox stays a security boundary.

@mraible mraible left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the security model change. Turning on custom themes means trusting weblog Admins with the server's CPU and memory, and the sandbox boundary (no Java calls, no file reads, no other weblogs) stays. I compared this with #335: the only differences are the removed budget classes and their tests, and the output, time and loop limits and the per-weblog templates and macros are unchanged. Thanks for trimming it down.

mraible added a commit that referenced this pull request Nov 21, 2026
… scope

As in #366 for 6.1.x: a global admin who turns on custom themes trusts weblog Admins not to abuse the server's CPU and memory, so the security model now lists template resource use under Not vulnerabilities. The output, time and loop limits, the per-weblog templates and macros, and the template sandbox stay. RenderLimitParser, RenderLimitUberspector, StringGrowth, DeadlineRegex and ValueLimits and their tests are removed.
@snoopdave
snoopdave merged commit 193d70f into roller-6.1.x Nov 21, 2026
7 checks passed
@snoopdave
snoopdave deleted the template-isolation-6.1.x branch November 21, 2026 20:30
snoopdave added a commit that referenced this pull request Nov 21, 2026
#367)

* Keep templates and macros per weblog, and bound render output and time

The Roller 7 version of #366, and a slimmer version of #317 without the
in-memory render budget. #parse and #include load only the rendering
weblog's own templates, inline macros are local to the template that
defines them, and a render fails once it writes more than
rendering.maxOutputChars, runs past rendering.maxRenderSeconds, or makes
more than 100,000 #foreach passes. $utils.addNofollow stays available.

The security model puts template resource use out of scope: a global admin
who turns on custom themes trusts weblog Admins not to abuse the server's
CPU and memory. The template sandbox stays a security boundary.

Co-authored-by: Matt Raible <matt@raibledesigns.com>

* Reference #367 in CHANGES

---------

Co-authored-by: Matt Raible <matt@raibledesigns.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants