Skip to content
RCE Write-up Intermediate

Template to Terminal — Responsible Writeup of an OS Command

A template-fetch endpoint accepted an unsafe template_id parameter and passed it to a shell command, allowing an attacker to execute arbitrary OS commands on the server. The author confirmed command execution by observing command output and out-of-band interactions.

Nakul Singh Follow

Published on medium.com

OS command injection happens when a program builds a shell command string that includes untrusted input from users (URL parameters, form fields, template fields, etc.) and then passes that string to the operating system for execution. If the input is not properly validated or the design relies on shell behavior, an…

Nakul Singh, 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

Likely the server built a shell command by concatenating untrusted input directly into a string and executed it without proper validation or using safe process APIs.

Impact

An attacker could execute arbitrary OS commands on the server, leading to remote code execution, data exfiltration, and potential full system compromise.

What the attacker needed

Access to the email campaign feature; ability to send requests to the endpoint

The fix

The vulnerability should be fixed by avoiding shell commands, using native APIs, enforcing strict input validation, and if external processes are necessary, using argument arrays and least-privilege accounts.

How it was found

  1. Select a template in the email campaign interface and observe the request to the get_template_content endpoint with a template_id parameter.
  2. Test whether the template_id is used directly in a shell command by injecting shell metacharacters.
  3. Confirm command execution by observing command output in the HTTP response (e.g., whoami, directory listings).
  4. Use Burp Collaborator to detect out-of-band interactions, confirming network-capable command execution.

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.

This is a bug where a website takes a piece of user input (like a template ID) and uses it to build a command that the computer's operating system runs. Because the input isn't checked, an attacker can add extra commands that the system will also run, giving them control over the server. This is called OS command injection and can lead to full remote code execution.

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 Nakul Singh

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.