github nette/latte v3.1.11
Released version 3.1.11

37 minutes ago

This release closes several ways a sandboxed template could get around the security policy. Only applications that render templates of untrusted authors in the sandbox (setSandboxMode() or {sandbox}) are affected; for them the update is recommended.

🔒 Security

  • {iterateWhile} assigns the {foreach} target with the same policy check as {foreach} itself, so it can no longer write a property the policy does not allow
  • {first}, {last}, {sep}, {skipIf}, {iterateWhile} and {else} of {foreach} call methods of an internal iterator, never of $iterator, which a template could overwrite with a host object
  • Arguments of {include}, {embed}, {extends}, {import} and {sandbox} cannot set internal $ʟ_* variables; a literal key is a compile error, an unpacked or computed one is refused at runtime
  • The n:else branch of n:ifcontent and the expression in the name of a dynamic {block} or {define} are checked by the sandbox like any other code
  • |sort and |group read the property named by by or byKey through the policy; allow the properties your templates sort or group by
  • createSafePolicy() no longer allows |query and |escapeJs, which serialize an object with all its public properties; allow them explicitly if your templates need them
  • A dynamic property name whose __toString() returns a different value each time can no longer pass the check with one name and read another

💥 Breaking Changes

  • A sandboxed template using |query or |escapeJs under createSafePolicy(), or sorting and grouping by a property the policy does not allow, now throws SecurityViolationException (see Security)
  • For authors of custom tags: TagParser::parseCallArguments(), added in 3.1.9, is replaced by parseArguments() followed by NodeHelpers::checkArgumentOrder($args)

🐛 Bug Fixes

  • Deprecation notices raised while compiling a template name its file, not only the line (#436)
  • {foreach $items as $iterator} no longer breaks {first}, {last}, {sep} and {iterateWhile} inside the loop
  • A custom function in the name of a dynamic block ({block blockName()}) is resolved
  • A template containing a null byte throws CompileException instead of ValueError

Don't miss a new latte release

NewReleases is sending notifications on new releases.