1 /**
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.security.cts;
18 
19 import android.platform.test.annotations.AsbSecurityTest;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
23 
24 import static org.junit.Assert.*;
25 
26 @RunWith(DeviceJUnit4ClassRunner.class)
27 public class Poc17_04 extends SecurityTestCase {
28 
29     /**
30      * b/32342065
31      */
32     @Test
33     @AsbSecurityTest(cveBugId = 32342065)
testPocCVE_2017_0553()34     public void testPocCVE_2017_0553() throws Exception {
35       // Error code of 139 represents segmentation fault
36       getDevice().executeShellCommand("chmod +x /data/local/tmp/CVE-2017-0553");
37       assertFalse("Segfault found",
38           AdbUtils.runCommandGetExitCode("/data/local/tmp/CVE-2017-0553", getDevice())==139);
39     }
40 
41     /**
42      * b/72460737
43      */
44     @Test
45     @AsbSecurityTest(cveBugId = 34469585)
testPocCVE_2014_3145()46     public void testPocCVE_2014_3145() throws Exception {
47       assertFalse("VULNERABLE DEVICE DETECTED",
48                   AdbUtils.runPocCheckExitCode("CVE-2014-3145", getDevice(), 60));
49     }
50 
51     /**
52      * b/32813456
53      */
54     @Test
55     @AsbSecurityTest(cveBugId = 32813456)
testPocCVE_2016_10229()56     public void testPocCVE_2016_10229() throws Exception {
57       String out = AdbUtils.runPoc("CVE-2016-10229", getDevice());
58       assertNotMatchesMultiLine("OVERWRITE", out);
59     }
60 
61     /**
62      * b/33621647
63      */
64     @Test
65     @AsbSecurityTest(cveBugId = 33621647)
testPocCVE_2017_0477()66     public void testPocCVE_2017_0477() throws Exception {
67         AdbUtils.pushResource("/CVE-2017-0477.gif", "/data/local/tmp/CVE-2017-0477.gif",
68                 getDevice());
69         AdbUtils.runCommandLine("logcat -c", getDevice());
70 
71         // because runPocGetExitCode() isn't a thing
72         AdbUtils.runCommandLine("chmod +x /data/local/tmp/CVE-2017-0477", getDevice());
73         int code = AdbUtils.runCommandGetExitCode("/data/local/tmp/CVE-2017-0477", getDevice());
74         assertTrue(code != 139); // 128 + signal 11
75     }
76 }
77