# GHSA-w9mr-28mw-j8hg: Hop-by-hop abuse to malform header mutator

> Attackers can bypass header-based authentication or authorization by dropping headers via Connection header manipulation in Go-based gateways.

- **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:** 26 Apr 2023
- **Also known as:** GO-2023-1747

## What is GHSA-w9mr-28mw-j8hg?

GHSA-w9mr-28mw-j8hg is a vulnerability in github.com/ory/oathkeeper, published on 26 Apr 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact

Downstream services relying on the presence of headers set by the `header` mutator could be exploited. A client can drop the header set by the `header` mutator by including that header's name in the `Connection` header. Example minimal config:

```yaml
- id: 'example'
  upstream:
    url: 'https://example.com'
  match:
    url: 'http://127.0.0.1:4455/'
    methods:
      - GET
  authenticators:
    - handler: anonymous
  authorizer:
    handler: allow
  mutators:
    - handler: header
      config:
        headers:
          X-Subject: {{ .Subject }}
```

```
curl -H "Connection: close,x-subject" http://127.0.0.1:4455/
```

The `X-Subject` header will not arrive at the downstream server. It is completely dropped. In case the downstream server handles such a request in an unexpected way, an attacker can exploit this, assuming they know or guess the internal header name.

### Patches

c5cc7f736dc84185034be4356057d1c7a656d797

### Workarounds

The downstream server should handle the case that an expected header is not set by responding with an appropriate error.

### References

See background info in https://github.com/golang/go/issues/50580

## Which versions are affected by GHSA-w9mr-28mw-j8hg?

3 open source packages ship an affected version, including github.com/ory/oathkeeper.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/ory/oathkeeper` | Go | All versions | 0.40.3 |
| `github.com/ory/oathkeeper` | Go | All versions | 0.40.3 |
| `github.com/ory/oathkeeper` | Go | All versions | 0.40.3 |

## How do I fix GHSA-w9mr-28mw-j8hg?

Upgrade github.com/ory/oathkeeper to 0.40.3 or later.

## Is GHSA-w9mr-28mw-j8hg being exploited?

There is no known exploitation of GHSA-w9mr-28mw-j8hg in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-w9mr-28mw-j8hg and fix it if it is affected.

What it is: GHSA-w9mr-28mw-j8hg is a vulnerability in github.com/ory/oathkeeper, published on 26 Apr 2023. 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-w9mr-28mw-j8hg in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/ory/oathkeeper (Go): affected all versions; fixed in 0.40.3
- github.com/ory/oathkeeper (Go): affected all versions; fixed in 0.40.3
- github.com/ory/oathkeeper (Go): affected all versions; fixed in 0.40.3

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-w9mr-28mw-j8hg/ (Markdown: https://insights.sbomify.com/GHSA-w9mr-28mw-j8hg/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-w9mr-28mw-j8hg

---
From sbomify Insights: https://insights.sbomify.com/GHSA-w9mr-28mw-j8hg/
Summaries are generated and may contain mistakes; the official description above is the record.
