Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85844916 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

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
parent 521ca5f8
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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()");