Summary
The reporting module in OpenProject embeds user-supplied values from the =n operator directly into SQL WHERE clauses without parameterization, enabling SQL injection.
Under typical configurations, an attacker who can craft reporting filters may inject arbitrary SQL, potentially accessing or modifying data across the OpenProject database.
Affected context
This vulnerability occurs in OpenProject's reporting feature, specifically within the implementation of the =n operator in modules/reporting/lib/report/operator.rb.
It is relevant when:
- The reporting module is enabled and used to build/filter reports
- User-controlled input is passed into the
=noperator - Database queries are constructed dynamically using these operator values
In such contexts, insufficient query parameterization allows crafted inputs to flow directly into SQL WHERE clauses.
Exploit preconditions
- Attack surface: Web interface endpoints that use the reporting engine and accept user-defined filters or parameters.
- Required access: Ability to authenticate or otherwise submit inputs that reach the reporting
=noperator (often a regular application user with reporting access). - Trigger point: Creation, modification, or execution of reports that apply filters using the
=noperator with attacker-controlled values. - Why exploitation is possible: The implementation concatenates raw user input into SQL
WHEREclauses rather than using bound parameters or proper escaping, so attacker-controlled tokens are interpreted as SQL syntax.
Why this happens
The underlying bug is a classic SQL injection pattern mapped to CWE-89: Improper Neutralization of Special Elements used in an SQL Command.
In the reporting module, the =n operator constructs SQL fragments by directly interpolating user input into a query string.
Because the code does not use prepared statements or parameter binding, it fails to treat input as data only; instead, user-controlled text becomes part of the SQL command, allowing attackers to alter query structure, bypass filters, or execute additional SQL operations.
Potential impact
- Read access to sensitive project and user data that the database role can query
- Unauthorized modification or deletion of tasks, issues, projects, or configuration records
- Escalation of privileges by manipulating authorization-related tables
- Creation of backdoor accounts or persistence mechanisms at the data layer
- Potential full compromise of the OpenProject database instance associated with the application
General mitigation guidance
Effective mitigation focuses on eliminating dynamic SQL construction from user input and enforcing strict separation between code and data:
- Use parameterized queries or ORM query builders for all reporting filters, including custom operators like
=n - Avoid string concatenation when building
WHEREclauses; treat all external input as untrusted data - Centralize query-building logic so that all operators pass through a common, parameterized interface
- Apply strict whitelisting for allowed operators and column names, and avoid passing unvalidated identifiers from user input
- Run the database with least-privilege accounts so that even if a query is abused, damage is constrained
How teams detect issues like this
Detection typically combines code-level review with runtime monitoring:
- Static analysis: Configure rules that flag dynamic SQL construction, string interpolation in query methods, and use of raw SQL APIs with user-controlled variables.
- Code review: Examine reporting and filter-building code paths for any operator that manually assembles WHERE clauses or accepts raw SQL fragments.
- Security testing: Use automated and manual testing to supply unexpected SQL metacharacters in reporting filters and observe for errors or anomalies.
- Runtime monitoring: Monitor database logs for unusual query patterns, concatenated literals, or repeated failed queries stemming from reporting endpoints.

