Oracle Java SE SecurityManager Sandbox Escape (CVE-2012-4681)
Published: 2026-11-27 • Researcher: ZH3FENG (PoC repository author); in-the-wild Gondzz / Gondvv exploit reported by FireEye and Immunity
Exploitation signals
Confirmed exploited in the wild. Added to CISA KEV 2022-03-03. Federal remediation deadline 2022-03-24.
EPSS 98.5% · 100th percentile
- Severity
- Critical
- CVE
- CVE-2012-4681
- Category
- binary
- Affected product
- Oracle Java SE (JRE and JDK): java.beans, com.sun.beans.finder.ClassFinder and sun.awt.SunToolkit
- Affected versions
- Java SE 7 Update 6 and earlier (NVD description, CPE oracle:jdk); Oracle fixed the issue in Java SE 7 Update 7
- Disclosed
- 2026-11-27
- Patch status
- Patched
Tags
References
- https://nvd.nist.gov/vuln/detail/CVE-2012-4681
- https://github.com/ZH3FENG/PoCs-CVE_2012_4681
- http://blog.fireeye.com/research/2012/08/zero-day-season-is-not-over-yet.html
- http://immunityproducts.blogspot.com/2012/08/java-0day-analysis-cve-2012-4681.html
- http://labs.alienvault.com/labs/index.php/2012/new-java-0day-exploited-in-the-wild/
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2012-4681
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2018-01-05 |
| Author / Researcher | ZH3FENG (PoC repository author); in-the-wild Gondzz / Gondvv exploit reported by FireEye and Immunity |
| CVE / Advisory | CVE-2012-4681 |
| Category | binary |
| Severity | Critical |
| CVSS Score | 10.0 (NVD, CVSSv2 base); 9.8 (CVSSv3.1 rescore in the KEV batch record) |
| Status | PoC (sandbox-escape primitive implemented; demonstration program only, no applet delivery or second-stage payload) |
| Tags | Java, JRE, sandbox escape, SecurityManager, reflection, applet, ClassFinder, SunToolkit, CWE-284, CISA KEV |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Oracle Java SE (JRE and JDK): java.beans, com.sun.beans.finder.ClassFinder and sun.awt.SunToolkit |
| Versions Affected | Java SE 7 Update 6 and earlier (NVD description, CPE oracle:jdk); Oracle fixed the issue in Java SE 7 Update 7 |
| Language / Platform | Java bytecode / JVM; desktop JRE on Windows, Linux and macOS, normally reached through a browser applet plugin |
| Authentication Required | No |
| Network Access Required | Yes for the in-the-wild vector (victim loads an attacker-supplied applet); the archived program can also be run locally |
Summary
CVE-2012-4681 is a Java SE sandbox bypass in which untrusted applet code can reach restricted internal classes and reflection helpers. The flaw lets an applet obtain and modify private fields of java.beans.Statement and install a forged AccessControlContext carrying AllPermission, after which it removes the SecurityManager and runs unrestricted code. It was exploited in the wild in August 2012 through the Gondzz and Gondvv classes and is listed in the CISA KEV catalog.
Vulnerability Details
Root Cause
Two unsafe primitives combine in the JDK 7 class library. First, com.sun.beans.finder.ClassFinder.findClass performs a class lookup without restricting the requested package, so sandboxed code can load otherwise restricted internals such as sun.awt.SunToolkit. Second, SunToolkit.getField performs reflective field lookup with a trusted immediate caller, and the java.beans.Expression / Statement machinery executes reflective calls in a privileged context. Together they allow applet code to read and write a private field of java.beans.Statement named acc, which holds the AccessControlContext used when the statement is executed.
The attacker replaces acc with an AccessControlContext built from a ProtectionDomain with AllPermission and a dummy CodeSource such as file:///testtest. When Statement.execute runs, the reflective call to System.setSecurityManager(null) is made inside that forged privileged context, so the permission check passes and the JVM security manager is removed. The original in-the-wild exploit packaged this primitive as an applet (Gondzz.class and Gondvv.class) loaded from a malicious web page.
Attack Vector
A victim visits an attacker-controlled web page that embeds a Java applet; a vulnerable browser plugin downloads and runs the applet, which executes the sandbox-escape chain. No credentials or user interaction beyond page load are required. The archived program is a standalone Java class that demonstrates the same chain from a main method, with no HTTP delivery.
Impact
Security-manager removal and arbitrary code execution with the privileges of the user running the browser or JVM. After the escape the payload can read and exfiltrate local files and credentials, install malware or a remote-access tool, modify user data and pivot to other systems reachable from the host. The in-the-wild campaign used the bypass to drop a Windows backdoor and was distributed through watering-hole and exploit-kit pages.
Environment / Lab Setup
OS: Linux or Windows desktop with JDK/JRE 7 Update 6 installed
Target: Oracle JDK 7u6 (1.7.0_06); the exploit depends on JDK 7 internals
Attacker: Local terminal (this PoC), or a web server hosting the applet for the remote vector
Tools: JDK 7u6 (javac, java), a text editor, optionally an old browser with the Java pluginSetup Steps
The upstream repository contains no setup instructions; it only carries the single Java source file and a one-line description. The steps below are reconstructed from the source and its package declaration and were not executed while preparing this entry.
| |
Proof of Concept
Step-by-Step Reproduction
Prepare the vulnerable JVM — Install JDK 7u6 and verify that java -version reports 1.7.0_06.
Compile the class — The source declares package org.zh3feng.poc, so place it in the matching directory before compiling.
Shell script1 2mkdir -p org/zh3feng/poc && cp CVE_2012_4681.java org/zh3feng/poc/ javac org/zh3feng/poc/CVE_2012_4681.javaRun the demonstration — The program installs a SecurityManager, performs the reflection chain, executes System.setSecurityManager(null) and prints whether the manager is still present.
Shell script1java -cp . org.zh3feng.poc.CVE_2012_4681Confirm the escape — The first line shows that a manager is installed and the second line shows that it has been removed. To prove code execution, add a Runtime.getRuntime().exec call after the second print; the upstream file deliberately stops at the escape.
Exploit Code
See
CVE_2012_4681.javain this folder.
| |
Expected Output
$ java -cp . org.zh3feng.poc.CVE_2012_4681
false
trueThe first false means a SecurityManager is active at that point; the final true means the manager was set to null and the sandbox no longer exists. On a patched or newer JVM the ClassFinder lookup, the Expression call or the reflective field access throws a SecurityException, the catch block swallows it, and the second line is never printed, so a single false line means the escape failed. All exceptions are silently discarded by design in the upstream code, which makes the program quiet on failure.
Detection & Indicators of Compromise
SIEM / IDS Rule (example):
title: Java process spawning a shell (sandbox escape follow-on)
logsource:
category: process_creation
product: windows
detection:
parent:
ParentImage|endswith: '\java.exe'
child:
Image|endswith:
- '\cmd.exe'
- '\powershell.exe'
- '\wscript.exe'
condition: parent and child
level: highRemediation
| Action | Detail |
|---|---|
| Patch | Upgrade to Oracle Java SE 7 Update 7 or later, which enforces the access restrictions in ClassFinder and the beans reflection path. Apply all later Critical Patch Updates. |
| Workaround | Disable the Java browser plugin when applets are not required; set the deployment security level to Very High and enable prompt/block behaviour for unsigned applets; restrict applet execution by GPO or browser policy. |
| Config Hardening | Remove end-of-life JREs from endpoints, keep only a supported JDK, and monitor for java.exe or browser processes spawning shells. Treat any host that loaded an applet from an untrusted site as compromised and reimage it. |
References
Notes
Auto-prepared on 2026-11-27 from https://github.com/ZH3FENG/PoCs-CVE_2012_4681 (stars 0, Java).
Review verdict: ingested. The repository is a genuine sandbox-escape PoC, not a detector: it actively installs a SecurityManager, abuses ClassFinder and the privileged beans reflection path to overwrite Statement.acc with an AllPermission context, and then removes the SecurityManager, printing the before/after state. It reproduces the exact primitive described by NVD and used by the in-the-wild Gondzz/Gondvv applet, and it is not malware.
License: the upstream repository has no LICENSE file; copyright remains with the author ZH3FENG. The source file credits the author and links the WeChat analysis article. The upstream README is copied verbatim as upstream-README.md and the original source is kept unmodified for attribution.
Limitations: the archived class is a standalone main program, not an applet, so it demonstrates the sandbox escape but not the browser delivery or the Windows payload of the 2012 campaign. It depends on JDK 7 internals such as com.sun.beans.finder.ClassFinder and only works on vulnerable JDK 7 builds; on patched or newer runtimes the swallowed SecurityException leaves the second line unprinted. The code intentionally contains no post-exploitation payload. No exploit code was executed during preparation of this entry.
| |