Summary
PowerJob 5.1.0–5.1.2 contains a SQL injection vulnerability in the detailPlus endpoint of InstanceController, where the customQuery request parameter is incorporated into database queries without sufficient sanitization.
A remote attacker can craft malicious customQuery input to manipulate SQL statements, potentially accessing or modifying job instance data and other records managed by the PowerJob server.
Affected context
The vulnerability occurs in the detailPlus endpoint of the PowerJob server's InstanceController class.
It affects deployments where:
- The PowerJob server is reachable over the network (e.g., exposed to internal or external clients).
- The
detailPlusendpoint is enabled and processes thecustomQueryargument. - Input from HTTP requests is passed to database queries without robust parameterization or filtering.
Risk increases when the same database holds sensitive configuration, tenant, or scheduling metadata beyond basic job instance details.
Exploit preconditions
- Attack surface: HTTP interface of the PowerJob server, specifically the
detailPlusendpoint. - Required access: Ability to send requests to the PowerJob server (network access to the management API; authentication requirements depend on deployment configuration).
- Trigger point: Submission of a crafted
customQueryvalue that is incorporated into a SQL statement executed by the backend. - Why exploitation is possible: The implementation appears to concatenate the
customQueryparameter directly into SQL or a query builder without using strictly parameterized queries or proper escaping, enabling user-controlled alteration of the query structure.
Why this happens
This issue stems from improper neutralization of user-supplied input before it is included in SQL statements, aligning with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The customQuery parameter is likely treated as trusted and interpolated into a query string or dynamic condition, allowing attackers to inject control characters, operators, or additional clauses (e.g., logical conditions, unions, or subqueries).
Conceptually, the bug is an insecure pattern where application logic exposes flexible query functionality to clients without enforcing strict query templates, parameter binding, or a constrained query syntax, thereby blurring the boundary between data and code within the database interaction.
Potential impact
- Attackers may read data they are not intended to see, including job instances, logs, or tenant-related metadata.
- Malicious users could modify or delete records, impacting scheduled jobs, execution history, or operational data.
- SQL injection payloads can potentially be used to bypass logical access controls implemented at the application layer.
- Under certain database and permission configurations, attackers might escalate to broader database compromise, including alteration of configuration tables or creation of backdoor accounts.
- Indirect disruption of job scheduling or execution reliability by corrupting or poisoning stored state.
General mitigation guidance
Effective mitigation focuses on eliminating direct concatenation of user input into SQL and strictly limiting the expressiveness of client-controlled query parameters.
Recommended defensive patterns include:
- Using prepared statements with parameterized queries for all variable parts of SQL, ensuring that
customQuery-derived values are bound as data, not code. - Refactoring the
detailPlusfunctionality to expose only a predefined set of filter fields and operators rather than arbitrary query fragments. - Implementing a strict whitelist-based query builder that parses incoming filter criteria into a constrained, validated structure before translating it into SQL.
- Applying centralized input validation and canonicalization for any field that influences query construction, rejecting malformed or overly complex expressions.
- Ensuring the database account used by the PowerJob server follows least privilege, limiting the impact of any successful injection attempt.
- Considering query timeouts, row limits, and defensive database configuration to reduce the impact of expensive or destructive queries.
How teams detect issues like this
Detection efforts can focus on both code-level analysis and runtime monitoring:
- Static analysis: Configure SAST tools or custom rules to flag string concatenation or formatting operations used to build SQL, especially around controllers or service methods handling
customQueryor similar parameters. - Code review: During manual review, look for endpoints that offer advanced or "flexible" search capabilities; verify that they rely on parameterized queries or a safe query DSL rather than raw fragments.
- Unit and integration tests: Add negative tests that include typical SQL injection tokens (
',",--,;,/* */, logical operators) incustomQueryvalues and verify that the resulting SQL does not change structure. - Runtime monitoring: Use database query logging or an application firewall to detect anomalous queries containing unexpected concatenated user input, multiple statements, or always-true conditions.
- Policy enforcement: Enforce internal coding standards that disallow raw string-based query construction in new code and require any dynamic query functionality to go through vetted builder utilities.

