Summary
Krayin CRM v2.2.x contains a SQL injection vulnerability in the rotten_lead parameter handled by /Lead/LeadDataGrid.php.
By manipulating this parameter, an attacker may inject arbitrary SQL into backend queries, potentially accessing or modifying CRM data when the application processes crafted requests.
Affected context
The vulnerability occurs in Krayin CRM v2.2.x within the lead management / data grid functionality, specifically in the handling of the rotten_lead parameter at /Lead/LeadDataGrid.php.
It is relevant in deployments where:
- User-controlled request parameters are used to filter or query leads in the database
- The
rotten_leadvalue is interpolated into SQL without robust parameterization - The CRM is reachable over a network (e.g., Internet or internal LAN) by untrusted or semi-trusted users
Exploit preconditions
- Attack surface: HTTP(S) interface exposed by Krayin CRM, particularly the
/Lead/LeadDataGrid.phpendpoint. - Required access: Ability to send requests to the CRM instance (e.g., authenticated user, or unauthenticated if the endpoint is publicly accessible).
- Trigger point: Server-side processing of the
rotten_leadparameter as part of a SQL query used for listing/filtering leads. - Why exploitation is possible: The parameter value is incorporated into SQL statements without proper use of prepared statements or equivalent parameter binding, allowing crafted input to alter the intended query structure.
Why this happens
This issue stems from constructing SQL queries by concatenating or interpolating user-supplied data from the rotten_lead parameter directly into the query string.
Instead of treating the parameter as data through bound parameters or ORM-safe query mechanisms, the backend likely mixes control and data, enabling attackers to break out of the intended query context.
This pattern maps to CWE-89: SQL Injection, where input validation and query parameterization are insufficient, and untrusted input can change the logic of database commands.
Potential impact
- Read access to sensitive CRM data, including lead information and associated metadata
- Modification or deletion of lead records and related tables
- Bypassing of application-level authorization checks through manipulated queries
- Extraction of additional database information (such as user tables or configuration data), depending on database permissions
- Possible execution of database-specific functions that could aid in further compromise of the environment
General mitigation guidance
Mitigation generally focuses on separating SQL code from user input and reducing trust in request parameters:
- Use parameterized queries or prepared statements for all database interactions involving request parameters like
rotten_lead. - Prefer ORM or query builders that enforce binding over string concatenation when constructing filters and data grid queries.
- Apply strict server-side validation and normalization on filter parameters (e.g., accept only expected types and whitelisted values).
- Implement the principle of least privilege for the database user so that even if a query is abused, destructive operations are limited.
- Centralize query construction patterns for data grid components so that secure practices are consistently applied.
How teams detect issues like this
Detection commonly involves a mix of code-centric and runtime approaches:
- Static analysis rules to flag raw SQL construction that includes request parameters (e.g.,
$_GET,$_POST, or framework request objects) in/Lead/LeadDataGrid.phpand related code. - Code reviews that look for dynamic query fragments, string concatenation in WHERE/ORDER/LIMIT clauses, and lack of bound parameters.
- Automated security testing (DAST) targeting the
rotten_leadparameter with benign injection payloads to observe anomalous database error messages or behavior. - Central logging of SQL errors and unusual query patterns, optionally combined with anomaly detection to identify suspicious query structures.

