Summary
A SQL injection flaw in NocoBase's in-app notification plugin allows attacker-controlled filter values to be embedded directly into a Sequelize literal query.
An authenticated user can exploit this to run stacked PostgreSQL statements, which may lead to arbitrary command execution via features like COPY ... TO PROGRAM in vulnerable deployments.
Affected context
The vulnerability occurs in NocoBase deployments that expose the in-app message notification API endpoint GET /api/myInAppChannels:list and rely on Sequelize for PostgreSQL queries.
Risk is present when user-provided filter parameters, particularly filter[latestMsgReceiveTimestamp][$lt], are treated as trusted input and interpolated into raw SQL expressions without escaping or parameterization.
Exploit preconditions
- Attack surface: HTTP API endpoint
GET /api/myInAppChannels:listin the in-app notification plugin - Required access: Authenticated user with the ability to call the endpoint and supply
filter[latestMsgReceiveTimestamp][$lt] - Trigger point: Construction of a
Sequelize.literal()expression using the unescaped filter value in SQL templates - Why exploitation is possible: The filter value is concatenated directly into SQL, enabling injection of stacked statements on PostgreSQL, including potentially dangerous constructs like
COPY ... TO PROGRAMwhere supported and permitted
Why this happens
The root cause is a classic SQL injection pattern: untrusted user input is concatenated into SQL query text without parameter binding.
In this case, Sequelize's literal() function is used to build a raw SQL fragment with a template string, and the filter[latestMsgReceiveTimestamp][$lt] parameter is inserted verbatim.
This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command, where the application fails to properly neutralize or separate data from control in SQL statements.
Potential impact
- Authenticated users may inject arbitrary SQL commands into the underlying PostgreSQL database
- Attackers could read, modify, or delete application data stored in the database
- In environments where PostgreSQL is configured with sufficient privileges, attackers may execute OS-level commands using
COPY ... TO PROGRAM - Compromise of application integrity and potential lateral movement to other services connected to the database
General mitigation guidance
Effective mitigation focuses on removing direct string interpolation from SQL construction and enforcing strict separation of data and control.
Recommended defensive patterns include:
- Using parameterized queries or query builders instead of raw SQL literals for all user-supplied values
- Avoiding
Sequelize.literal()for dynamic parts of queries that depend on client input - Applying strict validation and normalization on filter parameters, restricting them to expected formats and value ranges
- Running database accounts with least privilege so that high-risk features (such as
COPY ... TO PROGRAM) are not available to the application user - Adopting secure-by-default query APIs and disabling features that allow stacked statements or command execution where possible
How teams detect issues like this
Detection commonly combines static, review-based, and runtime approaches:
- Static analysis rules that flag the use of raw SQL construction (e.g.,
literal()or string concatenation) with variables derived from HTTP request parameters - Code review practices that specifically scrutinize query-building logic in controller and service layers, looking for unparameterized filters and literals
- Centralized security policies that discourage or forbid direct use of raw SQL helpers in high-level application code, requiring safer abstractions
- Optional use of automated code scanning tools with checks for CWE-89 patterns in JavaScript/TypeScript and ORM usage

