Skip to content

Commit 5d5974a

Browse files
committed
Add check for CVE-2015-1528
1 parent c24a423 commit 5d5974a

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

app/src/main/java/fuzion24/device/vulnerability/vulnerabilities/VulnerabilityOrganizer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import fuzion24.device.vulnerability.vulnerabilities.kernel.CVE_2014_3153;
2424
import fuzion24.device.vulnerability.vulnerabilities.kernel.CVE_2014_4943;
2525
import fuzion24.device.vulnerability.vulnerabilities.kernel.CVE_2015_3636;
26+
import fuzion24.device.vulnerability.vulnerabilities.system.CVE20151258;
2627
import fuzion24.device.vulnerability.vulnerabilities.system.SamsungCREDzip;
2728

2829
public class VulnerabilityOrganizer {
@@ -50,6 +51,7 @@ public static List<VulnerabilityTest> getTests(Context ctx){
5051
//tests.add(new ZergRush()); // Hide super old bugs?
5152
allTests.add(new SamsungCREDzip());
5253
allTests.add(new CVE_2015_6608());
54+
allTests.add(new CVE20151258());
5355

5456
List<VulnerabilityTest> filteredTest = new ArrayList<VulnerabilityTest>();
5557
String cpuArch1 = SystemUtils.propertyGet(ctx, "ro.product.cpu.abi");
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package fuzion24.device.vulnerability.vulnerabilities.system;
2+
3+
import android.content.Context;
4+
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
import fuzion24.device.vulnerability.util.CPUArch;
9+
import fuzion24.device.vulnerability.vulnerabilities.VulnerabilityTest;
10+
11+
/**
12+
* Created by fuzion24 on 11/23/15.
13+
*/
14+
public class CVE20151528 implements VulnerabilityTest {
15+
16+
static {
17+
System.loadLibrary("cve20151528");
18+
}
19+
20+
21+
@Override
22+
public String getCVEorID() {
23+
return "CVE-2015-1528";
24+
}
25+
26+
private native int doCheck();
27+
28+
@Override
29+
public boolean isVulnerable(Context context) throws Exception {
30+
int checkVal = doCheck();
31+
32+
if(checkVal == 0) {
33+
return false;
34+
}else if(checkVal == 1) {
35+
return true;
36+
}else {
37+
//TODO: grab more information about failure, errno and error string
38+
throw new Exception("Error running test");
39+
}
40+
}
41+
42+
@Override
43+
public List<CPUArch> getSupportedArchitectures() {
44+
List<CPUArch> supportedArchs = new ArrayList<>();
45+
supportedArchs.add(CPUArch.ARM);
46+
supportedArchs.add(CPUArch.ARM7);
47+
return supportedArchs;
48+
}
49+
}

app/src/main/jni/Android.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
168168
include $(BUILD_EXECUTABLE)
169169
################################
170170

171+
172+
################################
173+
include $(CLEAR_VARS)
174+
175+
LOCAL_MODULE := cve20151528
176+
LOCAL_SRC_FILES := cve20151528.c
177+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
178+
179+
include $(BUILD_SHARED_LIBRARY)
180+
################################
181+
171182
################################
172183
include $(CLEAR_VARS)
173184

app/src/main/jni/cve20151528.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <dlfcn.h>
2+
#include <errno.h>
3+
#include <limits.h>
4+
5+
#include <stdio.h>
6+
#include <stdlib.h>
7+
#include <jni.h>
8+
#include <android/log.h>
9+
10+
//#include <cutils/native_handle.h>
11+
12+
13+
14+
int Check_CVE_2015_1528()
15+
{
16+
const char *libname = "libcutils.so";
17+
size_t * ( *native_handle_create )( int numFds, int numInts ) = NULL;
18+
19+
void *handle = dlopen( libname, RTLD_NOW | RTLD_GLOBAL );
20+
if( !handle )
21+
{
22+
printf( "error opening %s: %s\n", libname, dlerror() );
23+
return -1;
24+
}
25+
26+
native_handle_create = dlsym( handle, "native_handle_create" );
27+
if( !native_handle_create )
28+
{
29+
printf( "missing native_handle_create\n" );
30+
return -1;
31+
}
32+
33+
int ret = -1;
34+
35+
int numFds = 1025;
36+
int numInts = 1;
37+
size_t *bla = native_handle_create( numFds, numInts );
38+
if( !bla )
39+
{
40+
// fixed
41+
printf( "looks fixed to me\n" );
42+
ret = 0;
43+
goto done;
44+
}
45+
46+
// sanity checks
47+
switch(bla[0])// version
48+
{
49+
case 12://android wear 5.0.2 LWX49K
50+
if( bla[1] != numFds || bla[2] != numInts )
51+
{
52+
printf( "got back unexpected values\n" );
53+
}
54+
else
55+
{
56+
printf( "its vulnerable\n" );
57+
}
58+
break;
59+
default:
60+
printf( "failed. version %d %d %d\n", bla[0], bla[1], bla[2] );
61+
break;
62+
}
63+
64+
65+
done:
66+
// done with this
67+
dlclose( handle );
68+
69+
// should be allocated with malloc
70+
//! if its already null, then free does nothing
71+
free( bla );
72+
73+
return ret;
74+
}
75+
76+
77+
JNIEXPORT jint JNICALL Java_fuzion24_device_vulnerability_vulnerabilities_system_CVE20151258_doCheck(JNIEnv *env, jobject obj)
78+
{
79+
return Check_CVE_2015_1528();
80+
}
81+
82+
83+
int main( int argc, char *argv[] )
84+
{
85+
return Check_CVE_2015_1528();
86+
}

0 commit comments

Comments
 (0)