Skip to content
Crypto Disclosed report Intermediate CVE-2022-39334

nextcloudcmd incorrectly trusts bad TLS certificates

The nextcloudcmd client treated a TLS certificate validation failure as a non-error and continued syncing, making a MITM attack possible.

tobiaskaminsky Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 36 days
  • Disclosed after 3 months

Summary by the program

Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-82xx-98xv-4jxv

The report

Ref: https://github.com/nextcloud/desktop/issues/4927

Bug description

I have a self hosted Nextcloud instance using my own private CA for TLS certs. When running nextcloudcmd without the --trust, it disregards the cert validation failure as "This is not an actual error" and proceeds with the sync anyway. I expected it to reject the untrusted server cert and assume it is a MITM attack:

# nextcloudcmd --non-interactive -n ~/Nextcloud https://nextcloud.lan
09-10 12:25:54:348 [ info nextcloud.sync.accessmanager ]:	2 "" "https://nextcloud.lan/ocs/v1.php/cloud/capabilities?format=json" has X-Request-ID "18ff47a0-a482-4456-a489-7aa747170c58"
09-10 12:25:54:348 [ info nextcloud.sync.networkjob ]:	OCC::JsonApiJob created for "https://nextcloud.lan" + "ocs/v1.php/cloud/capabilities" ""
09-10 12:25:54:545 [ info nextcloud.sync.account ]:	"SSL-Errors happened for url  \"https://nextcloud.lan/ocs/v1.php/cloud/capabilities?format=json\" \tError in  QSslCertificate(\"3\", [REDACTED] : \"The root certificate of the certificate chain is self-signed, and untrusted\" ( \"The root certificate of the certificate chain is self-signed, and untrusted\" ) \n " Certs are known and trusted! This is not an actual error.
09-10 12:25:54:871 [ info nextcloud.sync.networkjob.jsonapi ]:	JsonApiJob of QUrl("https://nextcloud.lan/ocs/v1.php/cloud/capabilities?format=json") FINISHED WITH STATUS "OK"

After adding the root CA cert to the system's trust store the validation passes and the warning goes away.

I am running the latest nextcloud-desktop-cmd package, version 2.6.2-1build1, on Ubuntu Server 20.04.2 LTS.

I did not see this problem in the NextCloud CVE list.

Steps to reproduce

Run nextcloudcmd against a server that has a TLS cert that the system won't validate.

Expected behavior

Abort the operation if the server's TLS cert cannot be validated, unless --trust is specified to explicitly override the security checks.

Which files are affected by this bug

src/libsync/account.cpp

Operating system

Linux

Which version of the operating system you are running.

Ubuntu 20.04.2 LTS

Package

Distro package manager

Nextcloud Server version

24.0.3

Nextcloud Desktop Client version

2.6.2-1build1

Is this bug present after an update or on a fresh install?

Fresh desktop client install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

Are you using an external user-backend?

  • Default internal user-backend
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Impact

Possible MITM

The original report as published on HackerOne, by tobiaskaminsky. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the client's certificate error handling in account.cpp logs the validation failure but does not abort the connection unless the user passes --trust.

Impact

An attacker in a position to intercept traffic could perform a man-in-the-middle attack against the sync client.

What the attacker needed

Attacker can intercept network traffic; victim uses nextcloudcmd without --trust

The fix

The client should abort the operation when the server certificate cannot be validated, unless --trust is explicitly given.

How it was found

  1. Run nextcloudcmd against a server whose TLS certificate the system does not trust.
  2. Observe that the client logs the certificate error but still completes the sync.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program connects to a server over HTTPS, it checks a digital certificate to confirm it is talking to the real server. Here the command-line sync tool saw that check fail but carried on anyway, so someone sitting between the user and the server could pretend to be the server.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.