Skip to content
RCE Write-up Intermediate

Advanced Template Injection Lifecycle From Input Vector Discovery to Command Execution and Post…

An authenticated administrator could inject Smarty template expressions into the group name field of Form Tools 3.1.1, leading to server-side template injection. This allowed execution of arbitrary system commands and a reverse shell on the host.

kizerh Follow

Published on kizerh.medium.com

This entry documents a completed exploitation exercise targeting CVE 2024 22722 in Form Tools version 3.1.1. The engagement was performed in a controlled environment following a TryHackMe room scenario.

Kiza, on kizerh.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

Likely the application passed user-supplied group names directly into the Smarty template engine without sanitisation, allowing template expressions to be evaluated.

Impact

An authenticated attacker with access to the form creation workflow could execute arbitrary system commands and obtain an interactive shell on the host.

What the attacker needed

Administrator access to Form Tools; Access to the form creation workflow

The fix

The application should treat user-editable template inputs as untrusted and avoid evaluating them directly in a template engine, and should disable or restrict template features that allow system command execution.

How it was found

  1. Log in as administrator and access the form builder.
  2. Create a new internal form and note the editable group name field.
  3. Under the view tab, add or update a group name with a template polyglot to trigger an error revealing Smarty.
  4. Submit a benign Smarty expression to confirm evaluation.
  5. Inject a system command payload to execute 'id' and confirm command execution.
  6. Set up a listener and inject an escaped PHP reverse shell to obtain an interactive shell.

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.

The application let an admin type a special code into a form field, and the server ran that code as if it were part of the website's own programming. Because the code could run system commands, the attacker could take full control of the server. This is dangerous because even trusted users should not be able to run arbitrary commands.

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 kizerh

View all

2 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.