A simple entry point can lead to Server Compromise

During a web application penetration project, our team has exploited a simple bug that can turn into remote code execution to the main server.

Recently our team escalated a straight forward template injection to a Remote Code Execution and compromised the server.

1) Starts with recon

In the first stage of the project, our team identifies some information about the web application. It seems like the web application is a kind of email service providing an application that runs on an Apache server. Also, we discover that JavaScript and some libraries were used by the developers during the application development.

2) Understand the functionality

In the given application there is a function for admin users to send mail to other users. Actually, when the admin creates some predefined email templated with some fixed mail body, Admin can invite another user to use this email template for the further process. Here admin has two options for sharing that email template, either admin can make the template public and invite any user or can make the template private and invite-only selected user. Here the private template can be accessible with the help of an email id and password which were shared by the admin via mail.

3) Exploiting entry points for Server-side template injection(SSTI)

So our team starts to test the function, we have created one custom email template and shared the link with the user. While sending the link to the user via email we observed that the application uses some function named “${externalShareableInfo}” to retrieve the credentials and merge this function into the email body along with other text like shown below

As an attacker we try to play with this given function, we replaced the function with some Mathematical calculation like “${7*7}”, and boom the calculation part was executed by the backend. So as a result we get 49 as output into the email body. This type of attack is called “Server-Side Template Injection” where an attacker can insert some script which executed by the backend

4) Further exploits SSTI to Remote code execution

Now it’s time to get some more results via SSTI. During recon, we identify that the backend server is Apache and the scripting language is Java. So our team starts to recon more about the template. After some trial and error methods, we discover that the web application is using a freemarker java template for the mailing function.

Our team has injected free maker template code into the SSTI payload. The payload was ${\”freemarker.template.utility.Execute\”?new()(\”id\”)}. As we expected we have successfully executed “id” command on the backend server the successfully get the output in the email body. Here we have exploited SSTI to RCE

This is how an attacker can exploit simple bugs into remote code execution and can execute malicious commands on the server which can lead to data breaches or other sensitive information disclosure.

Want a quick demo on web application penetration testing – Talk to Our Delivery Head

About Author

Keyur Talati – Cyber Security | Red teaming | VAPT Security Analyst – Wesecureapp Opsec team

The post A simple entry point can lead to Server Compromise appeared first on WeSecureApp :: Simplifying Enterprise Security!.

*** This is a Security Bloggers Network syndicated blog from WeSecureApp :: Simplifying Enterprise Security! authored by Keyur Talati. Read the original post at: https://wesecureapp.com/blog/a-simple-entry-point-can-lead-to-access-to-your-server/

Recent Posts

Is Your Password Strong Enough? Brute Force Attack on the Rise!

In today’s technologically advanced world, our online accounts provide access to everything from personal information and funds to professional networks…

4 hours ago

Response to CISA Advisory (AA24-109A): #StopRansomware: Akira Ransomware

AttackIQ has released a new attack graph in response to the recently published CISA Advisory (AA24-109A) which disseminates known Tactics,…

11 hours ago

USENIX Security ’23 – The Case for Learned Provenance Graph Storage Systems

Authors/Presenters: *Hailun Ding, Juan Zhai, Dong Deng, and Shiqing Ma* Many thanks to USENIX for publishing their outstanding USENIX Security…

13 hours ago

BreachRx Gets $6.5 Million to Automate Security Incident Response

The company's platform also is aimed at shielding CISOs and other executives from personal liability in cyberattacks.

14 hours ago

What is CAS Integration?

What is CAS integration? Why does it matter for businesses and their cybersecurity strategies? Read here to find out all…

15 hours ago

Brewing Trouble: How Nespresso’s Open Redirect Made Way for a Phishing Frenzy

Phishing attacks remain a prevalent threat, continuously evolving to outsmart even the most sophisticated security measures. Researchers at Perception Point…

15 hours ago