Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTM4ZjktbTI5Ny02cTln

DoS via malicious record IDs in WatermelonDB

Impact

Medium severity 5.9 https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:H

A maliciously crafted record ID can exploit a SQL Injection vulnerability in iOS adapter implementation and cause the app to delete all or selected records from the database, generally causing the app to become unusable.

This may happen in apps that don't validate IDs (valid IDs are /^[a-zA-Z0-9_-.]+$/) and use Watermelon Sync or low-level database.adapter.destroyDeletedRecords method.

The integrity risk is low due to the fact that maliciously deleted records won't synchronize, so logout-login will restore all data, although some local changes may be lost if the malicious deletion causes the sync process to fail to proceed to push stage.

No way to breach confidentiality with this vulnerability is known. Full exploitation of SQL Injection is mitigated, because it's not possible to nest an insert/update query inside a delete query in SQLite, and it's not possible to pass a semicolon-separated second query. There's also no known practicable way to breach confidentiality by selectively deleting records, because those records will not be synchronized.

It's theoretically possible that selective record deletion could cause an app to behave insecurely if lack of a record is used to make security decisions by the app.

Patches

Patched versions include:

Workarounds

  1. Ensure that your backend service sanitizes record IDs sent in the pull sync endpoint, such that only IDs matching /^[a-zA-Z0-9_-.]+$/ are returned. This could also be done in JavaScript pullChanges function passed to synchronize()
  2. If you use destroyDeletedRecords directly, validate all IDs passed the same way

For more information

If you have any questions about this advisory, contact @radex.

Permalink: https://github.com/advisories/GHSA-38f9-m297-6q9g
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTM4ZjktbTI5Ny02cTln
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: almost 4 years ago
Updated: over 1 year ago


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

Identifiers: GHSA-38f9-m297-6q9g, CVE-2020-4035
References: Repository: https://github.com/Nozbe/WatermelonDB
Blast Radius: 14.1

Affected Packages

npm:@nozbe/watermelondb
Dependent packages: 18
Dependent repositories: 248
Downloads: 28,931 last month
Affected Version Ranges: >= 0.16.0, < 0.16.2, < 0.15.1
Fixed in: 0.16.2, 0.15.1
All affected versions: 0.1.15, 0.1.16, 0.1.20, 0.1.21, 0.1.22, 0.1.23, 0.1.24, 0.6.0, 0.6.1, 0.6.2, 0.7.0, 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.13.0, 0.14.0, 0.14.1, 0.15.0, 0.16.0, 0.16.1
All unaffected versions: 0.15.1, 0.16.2, 0.17.0, 0.17.1, 0.18.0, 0.19.0, 0.20.0, 0.21.0, 0.22.0, 0.23.0, 0.24.0, 0.25.0, 0.25.1, 0.25.2, 0.25.3, 0.25.4, 0.25.5, 0.26.0, 0.27.0, 0.27.1