# CVE-2020-15105: In Django Two-Factor Authentication, user passwords are stored in clear text in the Django session

> Django Two-Factor Authentication stores user passwords in clear text within sessions, potentially exposing them in databases or caches until authentication completes.

- **Severity:** Medium 5.4 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 10 Jul 2020
- **Updated:** 4 Aug 2024
- **Also known as:** GHSA-vhr6-pvjm-9qwf, PYSEC-2020-39

## What is CVE-2020-15105?

CVE-2020-15105 is a medium-severity vulnerability in Bouke django-two-factor-auth, published on 10 Jul 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Django Two-Factor Authentication before 1.12, stores the user's password in clear text in the user session (base64-encoded). The password is stored in the session when the user submits their username and password, and is removed once they complete authentication by entering a two-factor authentication code. This means that the password is stored in clear text in the session for an arbitrary amount of time, and potentially forever if the user begins the login process by entering their username and password and then leaves before entering their two-factor authentication code. The severity of this issue depends on which type of session storage you have configured: in the worst case, if you're using Django's default database session storage, then users' passwords are stored in clear text in your database. In the best case, if you're using Django's signed cookie session, then users' passwords are only stored in clear text within their browser's cookie store. In the common case of using Django's cache session store, the users' passwords are stored in clear text in whatever cache storage you have configured (typically Memcached or Redis). This has been fixed in 1.12. After upgrading, users should be sure to delete any clear text passwords that have been stored. For example, if you're using the database session backend, you'll likely want to delete any session record from the database and purge that data from any database backups or replicas. In addition, affected organizations who have suffered a database breach while using an affected version should inform their users that their clear text passwords have been compromised. All organizations should encourage users whose passwords were insecurely stored to change these passwords on any sites where they were used. As a workaround, wwitching Django's session storage to use signed cookies instead of the database or cache lessens the impact of this issue, but should not be done without a thorough understanding of the security tradeoffs of using signed cookies rather than a server-side session storage. There is no way to fully mitigate the issue without upgrading.

Weakness: CWE-312 (Cleartext Storage of Sensitive Information)

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

3 open source packages ship an affected version, including django-two-factor-auth. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `django-two-factor-auth` | PyPI | All versions | 1.12 |
| `django-two-factor-auth` | PyPI | All versions | 1.12 |
| `django-two-factor-auth` | PyPI | All versions | 1.12 |

Products: Django Two-Factor Authentication Project Django Two-Factor Authentication.

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

Upgrade django-two-factor-auth to 1.12 or later.

## Is CVE-2020-15105 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2020-15105 is a medium-severity vulnerability in Bouke django-two-factor-auth, published on 10 Jul 2020. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2020-15105 in the wild and no public exploit code.

Affected packages and fixed versions:
- django-two-factor-auth (PyPI): affected all versions; fixed in 1.12
- django-two-factor-auth (PyPI): affected all versions; fixed in 1.12
- django-two-factor-auth (PyPI): affected all versions; fixed in 1.12

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-15105/ (Markdown: https://insights.sbomify.com/CVE-2020-15105/index.md)
```

## Sources

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

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