GHSA-h9h9-2rmf-rvhp: High severity maven/com.github.junrar:junrar vulnerability
Summary
Junrar's RAR virtual machine can be forced into a deterministic infinite loop while extracting a crafted RAR4 archive. The RarVM.ExecuteCode loop is intended to be bounded by maxOpCount, but jump instructions can bypass this limit when setIP() is called with a target instruction pointer greater than or equal to codeSize.
An unauthenticated attacker who can provide a RAR archive to an application using Junrar.extract() can cause the extraction thread to spin forever, consuming CPU and blocking the process. The issue is a denial of service vulnerability, not remote code execution.
Details
The root cause is in src/main/java/com/github/junrar/unpack/vm/RarVM.java.
setIP() returns early when the target IP is outside the prepared VM program:
java private boolean setIP(int ip) { if ((ip) >= codeSize) { return (true); }
if (--maxOpCount <= 0) { return (false); }
IP = ip; return true; }
When ip >= codeSize, this branch:
- does not update IP; - does not decrement maxOpCount; - returns true, so callers treat it as success.
The VMJMP handler and the other jump-like handlers discard the return value of setIP() and immediately continue the main VM loop:
java case VMJMP: setIP(getValue(false, mem, op1)); continue;
Because of the continue, execution also skips the loop-end accounting:
java IP++; --maxOpCount;
As a result, a VM program containing a single VMJMP instruction can freeze both IP and maxOpCount:
1. IP points to the VMJMP instruction. 2. The jump target resolves to codeSize or larger. 3. setIP() returns before modifying IP or decrementing maxOpCount. 4. The caller ignores the return value and continues. 5. The same VMJMP instruction is executed again forever.
Impact
This is a CPU denial of service vulnerability. Any application that uses junrar to extract untrusted RAR archives can have an extraction worker thread permanently blocked by a small crafted archive. In services that process uploads or attachments automatically, repeated submissions can exhaust worker capacity and degrade or stop archive-processing functionality.
The RAR VM does not provide native code execution, reflection, or process execution primitives, and Java array bounds checks prevent escaping the VM memory array. The expected security impact is availability only.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
maven/com.github.junrar:junrarto a version that resolves this vulnerability.Fixed in 7.6.1
Event History
Frequently Asked Questions
Which applications are exposed to this denial of service?
Applications that use Junrar's Junrar.extract() method and accept RAR archives from an unauthenticated or otherwise untrusted source are exposed. A crafted RAR4 archive can cause the extraction thread to consume CPU indefinitely and block the process.
What does an attacker need to exploit this issue?
The attacker needs only to provide a crafted RAR4 archive to an application that extracts it with Junrar.extract(). No authentication, user interaction, or prior privileges are required.
Is this vulnerability capable of remote code execution?
No. The described impact is denial of service: the extraction thread can enter a deterministic infinite loop, consuming CPU and blocking the process.
What version contains the fix?
The provided release reference identifies v7.6.1. The advisory also references commit 687a09c42f46066447faa9179ee11314ad6d9afb.