Couchbase ServerApplication · Couchbase

CVE-2021-31158

MEDIUM · 6.5 CVSS v3.1 Published 2021-05-19
Fix available
A fix is available. Upgrade to 6.6.2 or later.
See remediation →
71/100
Remediation priority · Elevated
Remotely reachable Zero-click

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
In the Query Engine in Couchbase Server 6.5.x and 6.6.x through 6.6.1, Common Table Expression queries were not correctly checking the user's permissions, allowing read-access to resources beyond what those users were explicitly allowed to access.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

The Query Engine in Couchbase Server 6.5.x through 6.6.1 fails to properly validate user permissions when processing Common Table Expression (CTE) queries, allowing authenticated users to bypass authorization controls and read data outside their explicitly granted permissions.

MitigationUpgrade Couchbase Server to version 6.6.2 or later which contains the vendor patch, or apply any available security patches. Review user query permissions and audit logs for unauthorized data access attempts using CTE queries.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
Couchbase ServerApplication
Affected:>= 6.5.0, < 6.6.2

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Identify Couchbase Server version
    Use the Couchbase CLI or admin console to retrieve the installed server version. Run 'couchbase-cli server-info' or check the About page in the web admin interface.
    Affected if The installed version is 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.6.0, or 6.6.1 (any version from 6.5.0 up to but not including 6.6.2).
  2. Confirm Query service is accessible
    Verify that the N1QL Query service is enabled and network-accessible. Check service configuration via the admin console under Settings > Services or by querying the cluster for active services.
    Affected if The Query (N1QL) service is enabled and exposed to authenticated users or applications.
  3. Review user query permissions
    Examine the role assignments for authenticated users who have query access. Use the admin console under Security > Users or run 'couchbase-cli user-list' to see which users have Query roles (like query_select, query_update, query_manage_indexes).
    Affected if Any authenticated user has been granted query-related roles, allowing them to submit N1QL queries including CTE queries.
  4. Audit for CTE query patterns
    Review the query logs and audit logs for the presence of WITH clauses (CTE syntax) in N1QL queries. Access logs via the admin console under Logs > Query Workbench or check the audit database for query events.
    Affected if CTE queries (queries using the WITH keyword) appear in logs, indicating the vulnerable feature is being exercised.

Your environment is affected if Couchbase Server version is 6.5.0 through 6.6.1 AND the Query service is accessible to authenticated users who could submit CTE queries to bypass their assigned permissions.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

From vendor data
Upgrade available Upgrade to 6.6.2 or later
Fixed in 6.6.2
Interim mitigation

Upgrade Couchbase Server to version 6.6.2 or later which contains the vendor patch, or apply any available security patches. Review user query permissions and audit logs for unauthorized data access attempts using CTE queries.

Fix this in Couchbase Server Scoped from the published advisory
  • Consultation3.0 h
  • Implementation12.0 h
  • Testing6.0 h
  • Review / QA3.0 h
24.0 hours of engineering $4,200
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $6,720.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2021-31158 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2021-31158 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data