/

CVE-2026-25887

Severity:

HIGH RISK

(7.2)

Code Injection in Chartbrew MongoDB Dataset Query

CVE-2026-25887

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Chartbrew versions prior to 4.8.1 contain a remote code execution vulnerability in the MongoDB dataset query functionality.

When attacker-controlled query data is interpreted in a way that influences server-side code execution, an attacker may execute arbitrary commands on the hosting server.

Affected context

The vulnerability occurs in Chartbrew deployments that use MongoDB datasets where user-provided query definitions are accepted, stored, and then processed on the server.

It is most relevant in scenarios where untrusted or semi-trusted users can create or modify MongoDB dataset queries, or where query configuration is indirectly influenced by external input (such as shared dashboards, integrations, or automation).

When the server interprets parts of these query definitions as executable logic rather than inert data, the risk of code injection arises.

Exploit preconditions

  • Attack surface: HTTP(S) interface of the Chartbrew application where MongoDB dataset queries can be created, edited, or executed.
  • Required access: Ability to supply or influence MongoDB dataset query content (e.g., authenticated user with dataset management privileges, misconfigured public project, or compromised user account).
  • Trigger point: Execution of a crafted MongoDB dataset query by the backend (e.g., test-run, dashboard refresh, scheduled job).
  • Why exploitation is possible: Parts of the MongoDB query structure are handled in a way that allow attacker-provided input to affect server-side code execution behavior instead of being treated as pure data.

Why this happens

This is a classic CWE-94: Improper Control of Generation of Code ('Code Injection') issue.

The backend logic handling MongoDB dataset queries appears to trust elements of the query definition and passes them into code paths that evaluate or construct executable code or commands.

Instead of treating the query structure purely as data passed directly and safely to the database driver, the implementation allows user-controlled values to participate in code generation or evaluation.

This insecure pattern means that if an attacker can craft a query definition with specially formed fields, the server may execute attacker-supplied logic during query processing.

Potential impact

  • Execution of arbitrary system commands or server-side code within the Chartbrew application environment
  • Complete compromise of the Chartbrew instance, including its configuration and stored dataset connections
  • Unauthorized access to connected databases or APIs via stolen credentials or tokens held by Chartbrew
  • Data exfiltration, modification, or destruction across dashboards and underlying data sources
  • Use of the compromised server as a foothold for further lateral movement in the hosting environment

General mitigation guidance

To mitigate this class of vulnerability, focus on treating all query configuration as untrusted data and eliminating any dynamic code paths:

  • Ensure MongoDB dataset queries are constructed using parameterized, driver-native APIs that never require building or evaluating code from user input.
  • Prohibit the use of generic eval-like constructs, dynamic Function creation, or string-to-code execution based on query fields.
  • Enforce strict schema validation for query definitions, allowing only expected operators, field types, and value ranges.
  • Apply strong server-side authorization so that only trusted roles can define or alter dataset queries, and separate configuration privileges from viewing privileges.
  • Run the Chartbrew service with least-privilege OS accounts and restricted network access to limit impact if a similar flaw is reintroduced.

Adopting a "data-only configuration" mindset significantly reduces the risk of code injection vulnerabilities in query builders.

How teams detect issues like this

Detecting this and similar vulnerabilities benefits from both static and dynamic approaches:

  • Static analysis: Scan the codebase for use of eval, dynamic function creation, or other meta-programming constructs that consume user-controlled query fields.
  • Code review: Pay special attention to any layer that maps HTTP request data or stored configuration directly into MongoDB queries or server-side logic; review for manual string concatenation or branching based on unvalidated input.
  • Runtime monitoring: Instrument logging around dataset query execution to detect unusual query patterns, unexpected operators, or serialized structures that deviate from the defined schema.
  • Security testing: Use targeted application security testing and fuzzing of the query configuration endpoints to identify paths where query input alters control flow instead of just data.

Automated SAST/DAST tools can be configured with rules for code injection and risky meta-programming APIs to surface similar issues early in development.

Sources

SourceLink
github.comgithub.com/chartbrew/chartbrew/releases/tag/v4.8.1
github.comgithub.com/chartbrew/chartbrew/security/advisories/GHSA-x4r6-prmw-7wvw

Frequently asked

questions

Exploitability depends on who can control MongoDB dataset queries. If only highly trusted administrators can edit queries, exposure is narrower; if lower-privileged or external users can influence query definitions, the vulnerability can become broadly exploitable over the web.

In most realistic deployments, some level of authenticated access or indirect control over dataset configuration is required, because MongoDB dataset queries are typically managed via authenticated project or organization settings. Misconfigurations that allow public editing would reduce this barrier.

The safest pattern is to completely avoid evaluating or generating executable code from user-provided query data. All query definitions should be strictly validated against a schema and passed directly to the database driver without going through any eval-like mechanisms or dynamic code paths.

Design new configuration and query-building features around data-only models: define explicit schemas, whitelist allowed operators, and rely on parameterized, driver-level APIs. Incorporate security-focused code review and static analysis rules targeting eval, dynamic execution, and meta-programming patterns so that risky constructs are flagged before deployment.

Find out what's already
exploitable in your codebase.