/

CVE-2026-87803

Severity:

HIGH RISK

(7.1)

Authorization Bypass (CWE-863) in Countly DBViewer

CVE-2026-87803

Deferred

Vulnerability type

Category:

Authorization Bypass

CWE:

CWE-863

Impact:

Unauthorized Data Access and Potential Account Takeover

Severity:

HIGH RISK

(7.1)

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

A flawed aggregation-stage sanitizer in Countly Server DBViewer can misclassify nested pipeline arrays when they contain an unrecognized stage key. A non-admin user with DBViewer read permission may then use forbidden aggregation operators to access data from restricted collections, potentially exposing password-reset tokens and enabling account takeover.

Affected context

The vulnerability occurs in Countly Server's DBViewer aggregation endpoint when user-controlled aggregation JSON is processed by the stage sanitizer. It requires a deployment where non-admin users have DBViewer read permission and where the sanitizer encounters a nested pipeline containing an unrecognized stage key, causing sibling stages to avoid expected restrictions.

Exploit preconditions

  • Attack surface: The /o/db aggregation endpoint and its user-controlled aggregation input
  • Required access: An authenticated non-admin account with DBViewer read permission
  • Trigger point: Sanitization of nested aggregation pipelines, including pipelines within aggregation branches
  • Why exploitation is possible: The sanitizer uses an all-elements check against a hardcoded stage-operator set; an unrecognized stage key can cause the complete branch to be treated as a generic array, bypassing stage-level filtering for sibling stages

Why this happens

The underlying bug is an authorization enforcement failure caused by incorrect structural classification during aggregation sanitization. The sanitizer determines whether an array represents a sub-pipeline only when every element contains a recognized stage key. If one element is unrecognized, the entire array may be treated as ordinary data, allowing restricted operators in sibling pipeline stages to pass through. This maps to CWE-863: Incorrect Authorization, because a user with limited read permission can cause the system to perform operations outside the intended authorization boundary.

Potential impact

  • Unauthorized reads from restricted database collections may occur
  • Sensitive records, including password-reset tokens, could be exposed
  • Account takeover may become possible when exposed tokens remain valid
  • Cross-collection data access could undermine tenant or role isolation
  • Sensitive information could be aggregated or exfiltrated through an authorized interface

General mitigation guidance

Mitigation generally focuses on enforcing authorization independently of parser classification and treating every user-controlled aggregation stage as untrusted.

Defensive patterns include:

  • Apply an explicit allowlist of permitted aggregation operators and stage locations
  • Validate every nested pipeline element independently rather than using branch-wide classification
  • Enforce collection-level and field-level authorization at query execution time
  • Use a canonical parser or schema model that rejects unknown operators instead of treating them as ordinary data
  • Limit DBViewer access to users who require it and apply least-privilege database roles
  • Reduce exposure of secrets such as reset tokens and avoid returning them through general-purpose query interfaces
  • Keep authorization checks separate from input sanitization so parser edge cases cannot grant additional access

How teams detect issues like this

Organizations can look for this weakness through:

  • Static analysis rules identifying aggregation sanitizers that classify nested arrays using all-elements checks
  • Code review signals involving hardcoded operator lists, unknown-key fallback behavior, or branch-level validation
  • Regression tests combining recognized and unrecognized stage keys in nested pipelines
  • Authorization tests that verify restricted collections and sensitive fields remain inaccessible to lower-privileged roles
  • Runtime monitoring for DBViewer queries that reference unexpected operators, collections, or unusually broad result sets
  • Policy enforcement requiring explicit operator allowlists and deny-by-default behavior for user-controlled database queries

Automated security review tools may help identify incomplete validation and authorization boundaries, but should be supplemented with permission-aware integration testing.

Sources

SourceLink
github.comgithub.com/Countly/countly-server/pull/7868

Frequently asked

questions

Exploitation generally requires an authenticated non-admin user who has DBViewer read permission. An unauthenticated attacker would typically need a separate weakness that provides access to the aggregation endpoint.

Depending on deployment permissions and database contents, unauthorized cross-collection reads could expose sensitive records such as password-reset tokens or other restricted account data.

Enforce a deny-by-default allowlist for aggregation operators, validate every nested pipeline independently, and apply authorization checks at query execution and data-return boundaries.

Use permission-aware regression tests for nested query structures, reject unknown operators, avoid relying on hardcoded structural heuristics, and minimize access to powerful database-viewing features.

Find out what's already
exploitable in your codebase.