# CVE-2020-4071: Timing attack on django-basic-auth-ip-whitelist

> An attacker on the local network can potentially recover basic authentication credentials via timing analysis if basic auth is enabled.

- **Severity:** Low 2.2 (`CVSS:3.1/AV:P/AC:H/PR:N/UI:N/S:C/C:L/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 24 Jun 2020
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-m38j-pmg3-v5x5, PYSEC-2020-37

## What is CVE-2020-4071?

CVE-2020-4071 is a low-severity vulnerability in tm-kn django-basic-auth-ip-whitelist, published on 24 Jun 2020. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

In django-basic-auth-ip-whitelist before 0.3.4, a potential timing attack exists on websites where the basic authentication is used or configured, i.e. BASIC_AUTH_LOGIN and BASIC_AUTH_PASSWORD is set. Currently the string comparison between configured credentials and the ones provided by users is performed through a character-by-character string comparison. This enables a possibility that attacker may time the time it takes the server to validate different usernames and password, and use this knowledge to work out the valid credentials. This attack is understood not to be realistic over the Internet. However, it may be achieved from within local networks where the website is hosted, e.g. from inside a data centre where a website's server is located. Sites protected by IP address whitelisting only are unaffected by this vulnerability. This vulnerability has been fixed on version 0.3.4 of django-basic-auth-ip-whitelist. Update to version 0.3.4 as soon as possible and change basic authentication username and password configured on a Django project using this package. A workaround without upgrading to version 0.3.4 is to stop using basic authentication and use the IP whitelisting component only. It can be achieved by not setting BASIC_AUTH_LOGIN and BASIC_AUTH_PASSWORD in Django project settings.

Weakness: CWE-208 (Observable Timing Discrepancy)

## Which versions are affected by CVE-2020-4071?

3 open source packages ship an affected version, including django-basic-auth-ip-whitelist. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `django-basic-auth-ip-whitelist` | PyPI | All versions | 0.3.4 |
| `django-basic-auth-ip-whitelist` | PyPI | All versions | 0.3.4 |
| `django-basic-auth-ip-whitelist` | PyPI | All versions | 0.3.4 |

Products: Django-Basic-Auth-Ip-Whitelist Project Django-Basic-Auth-Ip-Whitelist.

## How do I fix CVE-2020-4071?

Upgrade django-basic-auth-ip-whitelist to 0.3.4 or later.

## Is CVE-2020-4071 being exploited?

There is no known exploitation of CVE-2020-4071 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2020-4071 and fix it if it is affected.

What it is: CVE-2020-4071 is a low-severity vulnerability in tm-kn django-basic-auth-ip-whitelist, published on 24 Jun 2020. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2020-4071 in the wild and no public exploit code.

Affected packages and fixed versions:
- django-basic-auth-ip-whitelist (PyPI): affected all versions; fixed in 0.3.4
- django-basic-auth-ip-whitelist (PyPI): affected all versions; fixed in 0.3.4
- django-basic-auth-ip-whitelist (PyPI): affected all versions; fixed in 0.3.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2020-4071/ (Markdown: https://insights.sbomify.com/CVE-2020-4071/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2020-4071
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2020-4071
- OSV: https://osv.dev/vulnerability/CVE-2020-4071

---
From sbomify Insights: https://insights.sbomify.com/CVE-2020-4071/
Summaries are generated and may contain mistakes; the official description above is the record.
