what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Avian JVM 1.2.0 Silent Return

Avian JVM 1.2.0 Silent Return
Posted Aug 12, 2020
Authored by Pietro Oliva

Avian JVM version 1.2.0 suffers from a silent return issue in the vm::arrayCopy method defined in classpath-common.h, where multiple boundary checks are performed to prevent out-of-bounds memory read/write. One of these boundary checks makes the code return silently when a negative length is provided instead of throwing an exception.

tags | exploit
advisories | CVE-2020-17361
SHA-256 | 53ead956cdf9e9e2c075fcdfff1ae5c760e139f9927afb026cac0d5b93cd5921

Avian JVM 1.2.0 Silent Return

Change Mirror Download
Vulnerability title: Avian JVM vm::arrayCopy() silent return on negative length
Author: Pietro Oliva
CVE: CVE-2020-17361
Vendor: ReadyTalk
Product: Avian JVM
Affected version: 1.2.0

Description:
The issue is located in the vm::arrayCopy method defined in classpath-common.h,
where multiple boundary checks are performed to prevent out-of-bounds memory
read/write. One of these boundary checks makes the code return silently when a
negative length is provided instead of throwing an exception.

Impact:
The caller could assume that the method has succeeded in the copy operation due
to the lack of exception being thrown for negative lengths. This could result
in data being lost during the copy, with varying consequences depending on the
subsequent use of the destination buffer.

Exploitation:
The following PoC should throw an exception, but it silently returns instead:

import java.lang.*;

public class poc {

public static void main(String[] args) {
byte[] src = "This is src".getBytes();
byte[] dst = "This is dst".getBytes();

// This should throw an exception, but it doesn't and it silently returns intead.
System.arraycopy(src, 0, dst, 0, -1);
}
}


Evidence:

void arrayCopy(Thread* t,
object src,
int32_t srcOffset,
object dst,
int32_t dstOffset,
int32_t length)
{
if (LIKELY(src and dst)) {
if (LIKELY(compatibleArrayTypes(
t, objectClass(t, src), objectClass(t, dst)))) {
unsigned elementSize = objectClass(t, src)->arrayElementSize();

if (LIKELY(elementSize)) {
intptr_t sl = fieldAtOffset<uintptr_t>(src, BytesPerWord);
intptr_t dl = fieldAtOffset<uintptr_t>(dst, BytesPerWord);
if (LIKELY(length > 0)) {
if (LIKELY(srcOffset >= 0 and srcOffset + length <= sl
and dstOffset >= 0 and dstOffset + length <= dl)) {
uint8_t* sbody = &fieldAtOffset<uint8_t>(src, ArrayBody);
uint8_t* dbody = &fieldAtOffset<uint8_t>(dst, ArrayBody);
if (src == dst) {
memmove(dbody + (dstOffset * elementSize),
sbody + (srcOffset * elementSize),
length * elementSize);
} else {
memcpy(dbody + (dstOffset * elementSize),
sbody + (srcOffset * elementSize),
length * elementSize);
}

if (objectClass(t, dst)->objectMask()) {
mark(t, dst, ArrayBody + (dstOffset * BytesPerWord), length);
}

return;
} else {
throwNew(t, GcIndexOutOfBoundsException::Type);
}
} else {
return; // No exceptions are thrown for negative lengths
}
}
}
} else {
throwNew(t, GcNullPointerException::Type);
return;
}

throwNew(t, GcArrayStoreException::Type);
}

As can be seen in the line commented above, no exceptions are thrown for
negative lengths.


Remediation:
A patch has been merged in the master branch:
https://github.com/ReadyTalk/avian/pull/571


Disclosure timeline:
3rd August 2020 - Vulnerability reported.
3rd August 2020 - Vulnerability acknowledged.
4th August 2020 - CVE request sent to Mitre.
5th August 2020 - CVE assigned.
10th August 2020 - Proposed patch via pull request.
10th August 2020 - Patch approved and merged after changes.
10th August 2020 - Vulnerability details shared on fulldisclosure.


Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close