Summary
An SQL Injection flaw in the thaipalliative_lte application allows attackers to inject arbitrary SQL through unsanitized idFormMain and id parameters in ezform.php.
When these parameters are controlled by a remote user and concatenated directly into queries, an attacker can manipulate the database, exfiltrate data, or alter application state.
Affected context
The vulnerability appears in the thaipalliative_lte web application within the /substudy/ezform.php script, where idFormMain (line 14) and id (line 49) are used.
It is most relevant in deployments where this script is exposed over HTTP/S and these parameters are derived from user-controllable input without intermediate validation or query parameterization.
Any environment where the application connects to a production database with significant privileges (e.g., read/write to core tables) is particularly at risk.
Exploit preconditions
- Attack surface: HTTP/S endpoints that route to /substudy/ezform.php.
- Required access: Ability to send requests with crafted idFormMain or id parameters (typically unauthenticated or low-privilege web access).
- Trigger point: Execution of SQL queries that directly interpolate these parameters into SQL strings.
- Why exploitation is possible: The application constructs SQL statements by string concatenation, embedding untrusted parameter values without sanitization, escaping, or prepared statements, allowing attacker-controlled SQL fragments to be executed by the database.
Why this happens
This issue stems from constructing SQL queries by directly concatenating user input into query strings.
Instead of binding values using prepared statements or parameterized queries, the code embeds the idFormMain and id parameters inline, which aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The absence of a separation between code (the SQL statement) and data (user-provided values) enables attackers to inject control characters and SQL syntax that the database interprets as part of the query logic.
Potential impact
- Extraction of sensitive data from application tables, including potentially personal or medical information.
- Modification or deletion of database records, impacting data integrity and availability.
- Creation or escalation of application accounts by manipulating authentication or authorization tables.
- Potential execution of database-specific functions that may facilitate further system compromise, depending on DBMS capabilities and privileges.
General mitigation guidance
Effective mitigation focuses on enforcing a strict separation between SQL code and user-supplied data.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all database interactions involving external input.
- Applying strict input validation and whitelisting for identifier-like parameters (e.g., ensuring ids are numeric or from a known set).
- Centralizing database access logic in a data access layer that enforces safe query construction by default.
- Restricting database user permissions so that the application account has only the minimal privileges required for its operations.
- Introducing a consistent query-building abstraction that avoids ad-hoc string concatenation in application code.
How teams detect issues like this
Detection usually combines code-centric and behavior-centric approaches:
- Static analysis rules that flag SQL strings built via concatenation with request parameters, superglobals, or other untrusted sources.
- Manual code review that traces how web parameters (e.g., idFormMain, id) flow into query construction without parameter binding.
- Use of application security testing tools or web vulnerability scanners configured to probe for SQL Injection on dynamic parameters.
- Logging and monitoring for anomalous SQL errors, unexpected query patterns, or unusual access to sensitive tables that may indicate active exploitation.

