Summary
A critical SQL injection vulnerability in the smart-web2 report module allows attacker-controlled report SQL resources to be embedded directly into Hibernate native queries. If an attacker can submit or alter the sqlResource.sql value through the report-saving interface, they may execute unauthorized database statements with the application's database privileges.
Affected context
The vulnerability occurs in the backend report module when the sqlResource.sql parameter submitted through the ReportController.save() interface is persisted in the t_report_sql_resource table and later included in Hibernate native queries. Risk depends on whether the interface is reachable by an attacker and whether submitted report definitions are trusted, validated, or restricted by authorization controls.
Exploit preconditions
- Attack surface: The backend report-saving interface and subsequent report query execution
- Required access: Ability to submit, modify, or influence a report's
sqlResource.sqlvalue; the exact access level depends on deployment authorization - Trigger point: Processing a saved report that causes the stored SQL resource to be used in a native database query
- Why exploitation is possible: The value is embedded into a native query without parameterization or effective filtering, allowing SQL syntax supplied through the report resource to alter query behavior
Why this happens
The underlying bug is the construction of Hibernate native queries by concatenating or directly embedding a value that can originate from an externally controlled report resource. Because the application does not separate SQL code from data through parameter binding or an equivalent constrained query model, attacker-controlled content can change the intended statement structure. This behavior maps to CWE-89, Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Potential impact
- An attacker may read unauthorized database records.
- An attacker could modify or delete application data.
- The vulnerability may expose credentials, tokens, personal information, or business records stored in accessible tables.
- An attacker may bypass application-level data restrictions enforced only outside the database query.
- Database availability could be affected through resource-intensive or destructive statements.
- Further compromise could occur if the database account has excessive privileges or database-specific operating features are enabled.
General mitigation guidance
Mitigation generally focuses on keeping SQL code separate from user-controlled
or configuration-controlled data.
Common defensive patterns include:
- Use parameterized queries, bind variables, or safe query-builder abstractions for all runtime values.
- Avoid treating stored report definitions as trusted SQL; prefer a constrained report language or allowlisted query templates.
- Apply strict server-side validation and authorization to report creation, modification, and execution.
- Limit report users to the smallest set of query operations and data scopes required.
- Run the application with a dedicated database account that has only necessary privileges.
- Avoid exposing database administrative capabilities through the application account.
- Apply output filtering, auditing, and controlled error handling to reduce data leakage.
How teams detect issues like this
Organizations can identify this class of issue through:
- Static analysis for string concatenation, interpolation, or formatting of request or database-derived values into native SQL.
- Code review signals such as direct use of report fields in query text, dynamic SQL fragments, and missing parameter binding.
- Tests that submit unexpected SQL metacharacters and verify that values remain data rather than changing query structure.
- Runtime database monitoring for unusual statements, privilege use, access to unrelated tables, and anomalous query volume.
- Policy enforcement requiring approved parameterized query APIs or constrained query builders.
- Neutral automated security and code-review tools can help detect unsafe query construction, but findings should be validated against application authorization and data-flow behavior.

