CVE-2016-8640: SQL Injection in pycsw

pycsw Updated 02 Oct 2025

Summary

15/08/2018
Yes i
Critical
9.1

CVE-2016-8640: SQL Injection in pycsw. Affects pycsw across 3 version ranges.

< 1.8.6 >= 1.10.0, < 1.10.5 >= 2.0.0, < 2.0.2

Fixed in 1.8.6, 1.10.5 or 2.0.2, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2016-8640 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

pycsw is an open source Python project that implements the Catalogue Service for the Web (CSW) standard. It provides a metadata and catalogue server for geospatial data. The vulnerability in pycsw versions before 2.0.2, 1.10.5, and 1.8.6 allows for SQL injection, which can lead to unauthorized access, data extraction, and even modifications to the database.

Vulnerability Detail

The SQL injection vulnerability in pycsw allows an attacker to manipulate SQL queries and execute arbitrary SQL code. This can result in unauthorized access to sensitive data, extraction of data from any table in the pycsw database, and on PostgreSQL, it can even allow for updates, inserts, deletes, and modifications to any table accessible by the database user. The vulnerability is rated as critical with a CVSS score of 9.1.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 1.8.6 1.8.6
    pip install --upgrade "pycsw==1.8.6"
  • >= 1.10.0, < 1.10.5 1.10.5
    pip install --upgrade "pycsw==1.10.5"
  • >= 2.0.0, < 2.0.2 2.0.2
    pip install --upgrade "pycsw==2.0.2"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading to a fixed version is not immediately possible, a temporary workaround is to sanitize and validate user input before using it in SQL queries. This can help prevent SQL injection attacks. Here is an example of how to sanitize user input in Python:

import psycopg2

def sanitize_input(input):
    # Sanitize and validate input
    sanitized_input = input.replace("'", "''")
    return sanitized_input

# Usage example
user_input = "' OR 1=1 --"
sanitized_input = sanitize_input(user_input)

# Use the sanitized input in SQL query
query = f"SELECT * FROM users WHERE username = '{sanitized_input}'"

# Execute the query
connection = psycopg2.connect(database='database', user='user', password='password', host='host', port='port')
cursor = connection.cursor()
cursor.execute(query)
results = cursor.fetchall()

Conclusion

The SQL injection vulnerability in pycsw versions before 2.0.2, 1.10.5, and 1.8.6 can have severe consequences, including unauthorized access to data and modifications to the database. It is crucial to upgrade to the fixed versions or apply the recommended workaround to mitigate the risk. Regularly updating and patching software is essential for maintaining security.

See every vulnerability recorded for pycsw →

Share this vulnerability

FAQ

pycsw is an open source Python project that implements the Catalogue Service for the Web (CSW) standard. It provides a metadata and catalogue server for geospatial data.

The vulnerability affects pycsw versions before 2.0.2, 1.10.5, and 1.8.6.

The vulnerability allows for SQL injection, which can lead to unauthorized access, data extraction from any table in the pycsw database, and on PostgreSQL, it can even allow for updates, inserts, deletes, and modifications to any table accessible by the database user.

To fix this vulnerability, it is recommended to upgrade to pycsw version 2.0.2, 1.10.5, or 1.8.6. These versions contain the necessary fixes to prevent SQL injection attacks.

If upgrading to a fixed version is not immediately possible, a temporary workaround is to sanitize and validate user input before using it in SQL queries. This can help prevent SQL injection attacks.

Related vulnerabilities

Recent vulnerabilities recorded for pycsw.

How To Fix

Fixed versions by release line

The minimum fixed version depends on the release line you run.

  • < 1.8.6 1.8.6
    pip install --upgrade "pycsw==1.8.6"
  • >= 1.10.0, < 1.10.5 1.10.5
    pip install --upgrade "pycsw==1.10.5"
  • >= 2.0.0, < 2.0.2 2.0.2
    pip install --upgrade "pycsw==2.0.2"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback