Skip to content
RCE Write-up Advanced

$17,000 for Walking a Class Hierarchy: Escaping a Template Sandbox to Full RCE

The sandbox for user-supplied Jinja2 templates blocked direct dunder-attribute access but not the equivalent attr() filter, allowing the classic object-introspection chain to be rebuilt. An attacker with a customer account could reach a subprocess-capable class and achieve remote code execution on the report-rendering infrastructure.

T4nv1 Follow

Published on medium.com

Sandboxes exist because someone already knew this feature was dangerous. That’s what made this target interesting from the start — Solmark hadn’t made the beginner’s mistake of handing raw template syntax to a full-privilege engine.

T4nv1, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The sandbox filtered dunder-attribute access only on the direct dot syntax and did not apply the same restriction to Jinja2's attr() filter, which reaches the same attributes through a different code path.

Impact

Full remote code execution on the report-rendering infrastructure, achievable by any customer account permitted to define a custom report template; the tester confirmed it only with an inert outbound callback and did not attempt file access or persistence.

What the attacker needed

A customer account; permission to define a custom report template; ability to trigger a report render

The fix

The filter was extended to cover attr()-based access within 48 hours, and rendering was later moved to a genuinely isolated process; the report also recommends allowlisting permitted operations and isolating rendering with no network egress or filesystem access.

How it was found

  1. Confirm the template input is evaluated by the engine using an arithmetic expression.
  2. Try the classic direct dunder-attribute chain and observe it is blocked.
  3. Reach the same attributes through the attr() filter and confirm it succeeds.
  4. Rebuild the full subclass-enumeration chain using attr() indirection at each step.
  5. Locate a subprocess-capable subclass and instantiate it through the same indirection.
  6. Trigger a report render and confirm execution via an outbound callback to controlled infrastructure.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A template engine lets a report template contain small expressions that the server evaluates. A sandbox is meant to stop those expressions from reaching dangerous parts of the programming language. Here the sandbox only checked one way of writing an attribute name, so a second, built-in way slipped past it and let the tester run commands on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by T4nv1

View all

113 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.