CVE-2019-9039 SQL Injection in Couchbase Sync Gateway

Critical 9.8 Published Updated

Attackers can inject N1QL queries via REST API parameters to extract sensitive data or cause denial of service in Couchbase Sync Gateway.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2019-9039?

CVE-2019-9039 is a critical SQL injection vulnerability in n/a, published on 26 Jun 2019. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

In Couchbase Sync Gateway 2.1.2, an attacker with access to the Sync Gateway’s public REST API was able to issue additional N1QL statements and extract sensitive data or call arbitrary N1QL functions through the parameters "startkey" and "endkey" on the "_all_docs" endpoint. By issuing nested queries with CPU-intensive operations they may have been able to cause increased resource usage and denial of service conditions. The _all_docs endpoint is not required for Couchbase Mobile replication and external access to this REST endpoint has been blocked to mitigate this issue. This issue has been fixed in versions 2.5.0 and 2.1.3.

Weakness: CWE-89

Which versions are affected by CVE-2019-9039?

2 open source packages ship an affected version, including github.com/couchbase/sync_gateway. It affects 1 product.

PackageAffectedFixed in
github.com/couchbase/sync_gateway GoAll versions2.5.0
github.com/couchbase/sync_gateway GoAll versions2.5.0

Products include Couchbase Sync Gateway.

How do I fix CVE-2019-9039?

Upgrade github.com/couchbase/sync_gateway to 2.5.0 or later.

Use parameterised queries everywhere and never build SQL by joining strings. Upgrade affected software first; a web application firewall only buys time. More about SQL injection.

Is CVE-2019-9039 being exploited?

There is no known exploitation of CVE-2019-9039 in the wild and no public exploit code.

Sources

Also known as GHSA-g622-r636-qfqh.

Is CVE-2019-9039 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free