# CVE-2016-4977: Spring Security OAuth vulnerable to remote code execution (RCE) via specially crafted request using whitelabel views

> Attackers can execute arbitrary code by injecting Spring SpEL expressions into the response_type parameter during authorization requests.

- **Severity:** High 8.8 (`CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **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:** 25 May 2017
- **Updated:** 6 Aug 2024
- **Also known as:** GHSA-7q9c-h23x-65fq

## What is CVE-2016-4977?

CVE-2016-4977 is a high-severity code injection vulnerability in Pivotal Spring Security OAuth, published on 25 May 2017. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

When processing authorization requests using the whitelabel views in Spring Security OAuth 2.0.0 to 2.0.9 and 1.0.0 to 1.0.5, the response_type parameter value was executed as Spring SpEL which enabled a malicious user to trigger remote code execution via the crafting of the value for response_type.

Weakness: CWE-19

## Which versions are affected by CVE-2016-4977?

4 open source packages ship an affected version, including org.springframework.security.oauth:spring-security-oauth2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.springframework.security.oauth:spring-security-oauth2` | Maven | From 1.0.0 | 1.0.5 |
| `org.springframework.security.oauth:spring-security-oauth2` | Maven | From 1.0.0 | 1.0.5 |
| `org.springframework.security.oauth:spring-security-oauth2` | Maven | From 2.0.0 | 2.0.10 |
| `org.springframework.security.oauth:spring-security-oauth2` | Maven | From 2.0.0 | 2.0.10 |

Products: Pivotal Spring Security Oauth.

## How do I fix CVE-2016-4977?

Upgrade org.springframework.security.oauth:spring-security-oauth2 to a fixed version for your release line: 1.0.5 or 2.0.10.

## Is CVE-2016-4977 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2016-4977 exists.

Public exploit code:

- burpsuite 的Spring漏洞扫描插件。SpringVulScan：支持检测：路由泄露|CVE-2022-22965|CVE-2022-22963|CVE-2022-22947|CVE-2016-4977 (github_poc): https://github.com/tpt11fb/SpringVulScan
- https://github.com/N0b1e6/CVE-2016-4977-POC (github_poc): https://github.com/N0b1e6/CVE-2016-4977-POC
- Vulhub spring/CVE-2016-4977: Spring Security OAuth2 Whitelabel SpEL RCE (CVE-2016-4977), run with Isoloom (github_poc): https://github.com/CyberCTF/vulhub-spring-cve-2016-4977
- Spring Security OAuth2 Remote Command Execution (nuclei): http/cves/2016/CVE-2016-4977.yaml

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2016-4977 and fix it if it is affected.

What it is: CVE-2016-4977 is a high-severity code injection vulnerability in Pivotal Spring Security OAuth, published on 25 May 2017. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2016-4977 exists.

Affected packages and fixed versions:
- org.springframework.security.oauth:spring-security-oauth2 (Maven): affected from 1.0.0; fixed in 1.0.5
- org.springframework.security.oauth:spring-security-oauth2 (Maven): affected from 1.0.0; fixed in 1.0.5
- org.springframework.security.oauth:spring-security-oauth2 (Maven): affected from 2.0.0; fixed in 2.0.10
- org.springframework.security.oauth:spring-security-oauth2 (Maven): affected from 2.0.0; fixed in 2.0.10

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

## Sources

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

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