Summary
DoS via malicious record IDs in WatermelonDB
Workarounds
- Ensure that your backend service sanitizes record IDs sent in the
pull syncendpoint, such that only IDs matching/^[a-zA-Z0-9_-.]+$/are returned. This could also be done in JavaScriptpullChangesfunction passed tosynchronize() - If you use
destroyDeletedRecordsdirectly, validate all IDs passed the same way
For more information
If you have any questions about this advisory, contact @radex.
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.
Untrusted input alters a database query, allowing the attacker to read or modify data the query was not intended to access. Typical impact: data disclosure or modification.
CVE-2020-4035 has a CVSS score of 5.9 (Medium). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.15.1, 0.16.2); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Patched versions include:
- 0.15.1
- 0.16.2
- 0.16.1-fix
- this is actually the same as 0.16.0, but with the patch applied - as 0.16.1 is causing issues for some users
924c7ae2a8dcommit id contains the patch
Frequently Asked Questions
- What is CVE-2020-4035? CVE-2020-4035 is a medium-severity SQL injection vulnerability in @nozbe/watermelondb (npm), affecting versions < 0.15.1. It is fixed in 0.15.1, 0.16.2. Untrusted input alters a database query, allowing the attacker to read or modify data the query was not intended to access.
- How severe is CVE-2020-4035? CVE-2020-4035 has a CVSS score of 5.9 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of @nozbe/watermelondb are affected by CVE-2020-4035? @nozbe/watermelondb (npm) versions < 0.15.1 is affected.
- Is there a fix for CVE-2020-4035? Yes. CVE-2020-4035 is fixed in 0.15.1, 0.16.2. Upgrade to this version or later.
- Is CVE-2020-4035 exploitable, and should I be worried? Whether CVE-2020-4035 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2020-4035 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2020-4035?
- Upgrade
@nozbe/watermelondbto 0.15.1 or later - Upgrade
@nozbe/watermelondbto 0.16.2 or later
- Upgrade