# GHSA-74fp-r6jw-h4mp: Kubernetes apimachinery packages vulnerable to unbounded recursion in JSON or YAML parsing

> Authorized users can cause Kubernetes API server denial of service via malicious YAML or JSON payloads triggering excessive resource consumption.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Sep 2022
- **Also known as:** GO-2022-0965

## What is GHSA-74fp-r6jw-h4mp?

GHSA-74fp-r6jw-h4mp is a denial of service vulnerability in k8s.io/apimachinery, published on 2 Sep 2022. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

CVE-2019-11253 is a denial of service vulnerability in the kube-apiserver, allowing authorized users sending malicious YAML or JSON payloads to cause kube-apiserver to consume excessive CPU or memory, potentially crashing and becoming unavailable. 

When creating a ConfigMap object which has recursive references contained in it, excessive CPU usage can occur. This appears to be an instance of a "Billion Laughs" attack which is quite well known as an XML parsing issue.

Applying this manifest to a cluster causes the client to hang for some time with considerable CPU usage.

```yaml
apiVersion: v1
data:
  a: &a ["web","web","web","web","web","web","web","web","web"]
  b: &b [*a,*a,*a,*a,*a,*a,*a,*a,*a]
  c: &c [*b,*b,*b,*b,*b,*b,*b,*b,*b]
  d: &d [*c,*c,*c,*c,*c,*c,*c,*c,*c]
  e: &e [*d,*d,*d,*d,*d,*d,*d,*d,*d]
  f: &f [*e,*e,*e,*e,*e,*e,*e,*e,*e]
  g: &g [*f,*f,*f,*f,*f,*f,*f,*f,*f]
  h: &h [*g,*g,*g,*g,*g,*g,*g,*g,*g]
  i: &i [*h,*h,*h,*h,*h,*h,*h,*h,*h]
kind: ConfigMap
metadata:
  name: yaml-bomb
  namespace: default
```
### Specific Go Packages Affected
- k8s.io/apimachinery/pkg/runtime/serializer/json
- k8s.io/apimachinery/pkg/util/json

## Which versions are affected by GHSA-74fp-r6jw-h4mp?

3 open source packages ship an affected version, including k8s.io/apimachinery.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `k8s.io/apimachinery` | Go | All versions | 0.0.0-20190927203648-9ce6eca90e73 |
| `k8s.io/apimachinery` | Go | All versions | 0.0.0-20190927203648-9ce6eca90e73 |
| `k8s.io/apimachinery` | Go | All versions | 0.0.0-20190927203648-9ce6eca90e73 |

## How do I fix GHSA-74fp-r6jw-h4mp?

Upgrade k8s.io/apimachinery to 0.0.0-20190927203648-9ce6eca90e73 or later.

## Is GHSA-74fp-r6jw-h4mp being exploited?

There is no known exploitation of GHSA-74fp-r6jw-h4mp in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-74fp-r6jw-h4mp and fix it if it is affected.

What it is: GHSA-74fp-r6jw-h4mp is a denial of service vulnerability in k8s.io/apimachinery, published on 2 Sep 2022. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-74fp-r6jw-h4mp in the wild and no public exploit code.

Affected packages and fixed versions:
- k8s.io/apimachinery (Go): affected all versions; fixed in 0.0.0-20190927203648-9ce6eca90e73
- k8s.io/apimachinery (Go): affected all versions; fixed in 0.0.0-20190927203648-9ce6eca90e73
- k8s.io/apimachinery (Go): affected all versions; fixed in 0.0.0-20190927203648-9ce6eca90e73

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-74fp-r6jw-h4mp/ (Markdown: https://insights.sbomify.com/GHSA-74fp-r6jw-h4mp/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-74fp-r6jw-h4mp

---
From sbomify Insights: https://insights.sbomify.com/GHSA-74fp-r6jw-h4mp/
Summaries are generated and may contain mistakes; the official description above is the record.
