Summary
Chartbrew versions prior to 4.8.3 contain a SQL injection vulnerability that allows unauthenticated attackers to inject arbitrary SQL into queries sent to connected MySQL or PostgreSQL databases.
When exploited, this can enable reading, modifying, or deleting data in those databases, constrained only by the privileges of the database user configured for Chartbrew.
Affected context
This vulnerability arises in Chartbrew deployments that:
- Expose a network-accessible Chartbrew web interface
- Use Chartbrew to connect directly to relational databases (MySQL, PostgreSQL)
- Allow query parameters or chart configuration to influence generated SQL statements
The issue is most serious when Chartbrew connects using highly privileged database accounts (e.g., with broad SELECT/INSERT/UPDATE/DELETE permissions) or when the application is reachable from untrusted networks such as the public internet.
Exploit preconditions
- Attack surface: HTTP(S) endpoints exposed by the Chartbrew web application
- Required access: None; the attack can be performed by unauthenticated users able to reach the Chartbrew instance
- Trigger point: Endpoints that build or execute SQL queries based on user-supplied parameters or chart configuration values
- Why exploitation is possible: User-controlled input is incorporated into SQL statements without robust parameterization or escaping, allowing attackers to alter the intended query structure and inject arbitrary SQL commands executed by the connected database.
Why this happens
The root cause maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
At a design and implementation level, Chartbrew constructs SQL queries for connected databases using input that originates from unauthenticated HTTP requests (for example, chart filters, query fragments, or dynamic parameters).
Instead of consistently using parameterized queries or safe query-building abstractions, some code paths appear to concatenate or interpolate this input directly into SQL strings.
This insecure pattern allows attacker-supplied tokens—such as quotes, operators, and statement delimiters—to break out of the intended query context and execute additional SQL instructions under the database account configured for Chartbrew.
Potential impact
- Unauthorized reading of sensitive data stored in connected MySQL/PostgreSQL databases
- Modification of existing records (e.g., tampering with business data or analytics inputs)
- Deletion of tables or rows, potentially leading to loss of critical data
- Creation of new database objects (tables, views, users) if the database account is overly privileged
- Abuse of database features (e.g., functions, stored procedures) that could enable further compromise of the environment
- Pivoting into other applications that share the same database or rely on the compromised data
General mitigation guidance
Effective mitigation focuses on eliminating unsafe query construction and reducing the blast radius of a potential compromise:
- Prefer parameterized queries / prepared statements for all database interactions; never concatenate or interpolate user input into SQL strings.
- Use query builder or ORM abstractions that encode parameters safely and minimize direct raw SQL formatting.
- Apply strict input validation on fields used to shape queries (e.g., allowlists for column names, sort fields, and operators; strongly typed numeric and date parameters).
- Segregate user-controllable elements from structural SQL (e.g., keep table/column lists static and configurable only by trusted administrators).
- Configure database accounts according to least privilege, granting only the minimal permissions (SELECT/INSERT/UPDATE/DELETE on specific schemas) required by Chartbrew.
- Place Chartbrew behind authentication or access controls when feasible, limiting exposure to the public internet and reducing unauthenticated attack surface.
- Implement defense in depth with database-level safeguards such as row-level security, audit logging, and constraints that can limit damage even if a query is abused.
How teams detect issues like this
Detection can combine code-level analysis with runtime monitoring:
- Static analysis and code review:
- Search for raw SQL construction using string concatenation or template literals incorporating request parameters or chart configuration values.
- Flag any dynamic assembly of WHERE, ORDER BY, or LIMIT clauses that rely on unchecked user input.
- Verify that all database access layers use prepared statements or safe query builders and that no "escape hatch" raw SQL routines bypass these protections.
- Automated tooling:
- Use SAST tools configured with rules for CWE-89 to highlight insecure SQL patterns.
- Integrate pre-commit or CI checks that detect direct concatenation of request-derived data into SQL strings.
- Runtime and operational monitoring:
- Enable database query logging and look for anomalous patterns such as unexpected UNIONs, stacked queries, or syntax errors consistent with injection probing.
- Monitor HTTP access logs for suspicious parameter values containing SQL meta-characters or common injection fingerprints.
- Security testing:
- Conduct regular dynamic testing and penetration exercises focused on endpoints that influence chart queries, filters, and custom SQL features.

