# GHSA-3qmc-2r76-4rqp: Redwood is vulnerable to account takeover via dbAuth "forgot-password"

> Attackers can hijack user accounts by obtaining reset tokens via the forgot-password API, affecting Redwood projects with this feature enabled.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 10 Nov 2022

## What is GHSA-3qmc-2r76-4rqp?

GHSA-3qmc-2r76-4rqp is an authentication bypass vulnerability in @redwoodjs/api, published on 10 Nov 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

# Impact

_What kind of vulnerability is it? Who is impacted?_

This is an API vulnerability in Redwood's [dbAuth], specifically the dbAuth forgot password feature:
- only projects with the dbAuth "forgot password" feature are affected
- this vulnerability was introduced in v0.38.0

## User Accounts are Vulnerable to Takeover (Hijacking)

A reset token for any user can be obtained given knowledge of their username or email via the forgot-password API. With the leaked reset token, a malicious user could request to reset a user's password, changing their credentials and gaining access to their account.

## How to Determine if Projects have been Attacked

To determine if a project has been attacked, we recommend checking logs for suspicious activity; namely, the volume of requests to the forgot-password API using emails that don't exist. Another indication is if users inform you that they can't access their accounts.

If you have question or concerns, reach out via the "For More Information" section below.

# Patch Releases Available

**The problem has been patched on the v3 and v2 release lines.** Users should upgrade to **v3.3.1+**  or **v2.2.5+** respectively.

## Workarounds

_Is there a way for users to fix or remediate the vulnerability without upgrading?_

We recommend upgrading to the Patch Releases above. If upgrading is not possible, there are several workarounds:

### Manually strip out `resetToken` and `resetTokenExpiresAt` in the `forgotPassword.handler()`

Users on all release lines can have their `forgotPassword.handler()` function strip out the sensitive fields manually before returning

```js
handler: (user) => {
  // your code to notify/email user of the link to reset their password...

  const = { resetToken, resetTokenExpiresAt, ...rest }

  return rest
}
```

### Use `yarn patch` to manually apply the fix

Users on v3 and v2 can use [`yarn patch`] to apply the fix if they're using yarn v3. See the dbAuth "forgot-password" Account Takeover Vulnerability high gist for instructions. 

### Disable the forgot password flow entirely v3 only

Users on v3 can disable the forgot password flow entirely.

## Which versions are affected by GHSA-3qmc-2r76-4rqp?

4 open source packages ship an affected version, including @redwoodjs/api.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@redwoodjs/api` | npm | From 0.38.0 | 2.2.5 |
| `@redwoodjs/api` | npm | From 0.38.0 | 2.2.5 |
| `@redwoodjs/api` | npm | From 3.0.0 | 3.3.1 |
| `@redwoodjs/api` | npm | From 3.0.0 | 3.3.1 |

## How do I fix GHSA-3qmc-2r76-4rqp?

Upgrade @redwoodjs/api to a fixed version for your release line: 2.2.5 or 3.3.1.

## Is GHSA-3qmc-2r76-4rqp being exploited?

There is no known exploitation of GHSA-3qmc-2r76-4rqp in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-3qmc-2r76-4rqp and fix it if it is affected.

What it is: GHSA-3qmc-2r76-4rqp is an authentication bypass vulnerability in @redwoodjs/api, published on 10 Nov 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-3qmc-2r76-4rqp in the wild and no public exploit code.

Affected packages and fixed versions:
- @redwoodjs/api (npm): affected from 0.38.0; fixed in 2.2.5
- @redwoodjs/api (npm): affected from 0.38.0; fixed in 2.2.5
- @redwoodjs/api (npm): affected from 3.0.0; fixed in 3.3.1
- @redwoodjs/api (npm): affected from 3.0.0; fixed in 3.3.1

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/GHSA-3qmc-2r76-4rqp/ (Markdown: https://insights.sbomify.com/GHSA-3qmc-2r76-4rqp/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-3qmc-2r76-4rqp

---
From sbomify Insights: https://insights.sbomify.com/GHSA-3qmc-2r76-4rqp/
Summaries are generated and may contain mistakes; the official description above is the record.
