CVE-2021-23404

7.6 HIGH

📋 TL;DR

This vulnerability affects all versions of the sqlite-web package, allowing attackers to perform unauthorized sensitive actions through Cross-Site Request Forgery (CSRF). Attackers can trick authenticated users into executing SQL operations without their knowledge by exploiting missing CSRF protection in the SQL dashboard.

💻 Affected Systems

Products:
  • sqlite-web
Versions: All versions
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: All deployments of sqlite-web are vulnerable regardless of configuration.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data deletion, modification, or exfiltration through unauthorized SQL execution.

🟠

Likely Case

Unauthorized data manipulation or extraction through crafted SQL queries executed via CSRF.

🟢

If Mitigated

No impact if proper CSRF tokens are implemented and validated for all sensitive actions.

🌐 Internet-Facing: HIGH - Web applications exposed to the internet are directly vulnerable to CSRF attacks from malicious sites.
🏢 Internal Only: MEDIUM - Internal applications are still vulnerable to CSRF from compromised internal systems or phishing attacks.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires the victim to be authenticated to sqlite-web and visit a malicious website. CSRF attacks are well-understood and easy to implement.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: None

Vendor Advisory: https://github.com/coleifer/sqlite-web/security/advisories

Restart Required: Yes

Instructions:

1. Check for updated version of sqlite-web package. 2. If no patch available, implement CSRF protection manually. 3. Restart the sqlite-web service after changes.

🔧 Temporary Workarounds

Implement CSRF Protection

all

Add CSRF token validation to all POST requests in the SQL dashboard endpoints.

Modify sqlite-web source code to include CSRF tokens in forms and validate them server-side

Use SameSite Cookies

all

Configure session cookies with SameSite=Strict attribute to prevent CSRF from external sites.

Set session cookie with SameSite=Strict attribute in web server configuration

🧯 If You Can't Patch

  • Restrict access to sqlite-web to trusted networks only using firewall rules
  • Implement a reverse proxy with additional CSRF protection or require re-authentication for sensitive actions

🔍 How to Verify

Check if Vulnerable:

Check if sqlite-web is installed and if CSRF tokens are missing from SQL dashboard forms and endpoints.

Check Version:

pip show sqlite-web | grep Version

Verify Fix Applied:

Verify that all POST requests to SQL dashboard endpoints require and validate CSRF tokens.

📡 Detection & Monitoring

Log Indicators:

  • Multiple SQL operations from same user in rapid succession
  • SQL queries with unusual patterns or from unexpected sources

Network Indicators:

  • HTTP POST requests to /sql/ endpoints without Referer header validation
  • Requests with missing or invalid CSRF tokens

SIEM Query:

source="sqlite-web" AND (method="POST" AND uri="/sql/*") | stats count by src_ip, user

🔗 References

📤 Share & Export