Block loading WebView in privileged processes.

WebView is very powerful, but it also has a large attack area.  To
improve security, refuse to load WebView components when running as
the root or system UIDs.

Bug: 18376908
Change-Id: I515b819033586076b1a9668023bb43ee0295d003
This commit is contained in:
Jeff Sharkey
2014-11-13 16:20:38 -08:00
parent 521ca5f8fb
commit 85844916b8

View File

@@ -17,8 +17,8 @@
package android.webkit;
import android.app.ActivityManagerInternal;
import android.app.Application;
import android.app.AppGlobals;
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
@@ -33,14 +33,14 @@ import android.os.Trace;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.Log;
import com.android.server.LocalServices;
import dalvik.system.VMRuntime;
import java.io.File;
import java.util.Arrays;
import com.android.internal.os.Zygote;
/**
* Top level factory, used creating all the main WebView implementation classes.
*
@@ -89,6 +89,12 @@ public final class WebViewFactory {
// us honest and minimize usage of WebView internals when binding the proxy.
if (sProviderInstance != null) return sProviderInstance;
final int uid = android.os.Process.myUid();
if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID) {
throw new UnsupportedOperationException(
"For security reasons, WebView is not allowed in privileged processes");
}
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getProvider()");
try {
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");