Bug 1205706 - Part 1: Pass-through white-listed intent extras to about:accounts. r=sebastian
authorNick Alexander <nalexander@mozilla.com>
Thu, 17 Sep 2015 16:21:07 -0400
changeset 297652 70f459b00b8821ef13678ec1dfd3493bf8e8914c
parent 297651 4e9542200eb1a8a0d4928404b71ad0efaac1827e
child 297653 49dda13aabe2a5e74b0409db132b6e4778b9fa05
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1205706
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1205706 - Part 1: Pass-through white-listed intent extras to about:accounts. r=sebastian Pretty straight-forward. It's possible that getStringExtra is not safe in the face of malicious data; the worst we might expect is a crash on the Java side; a large memory allocation on the JS side; or significant URL data transfer. The first is valuable because we'd see abusers in crash-stats; and the second two are already possible when opening any URL.
mobile/android/base/fxa/activities/FxAccountWebFlowActivity.java
--- a/mobile/android/base/fxa/activities/FxAccountWebFlowActivity.java
+++ b/mobile/android/base/fxa/activities/FxAccountWebFlowActivity.java
@@ -1,28 +1,35 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.fxa.activities;
 
+import android.content.Intent;
 import android.os.Bundle;
 import org.mozilla.gecko.Locales;
 import org.mozilla.gecko.background.common.log.Logger;
 import org.mozilla.gecko.fxa.FxAccountConstants;
-import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
 import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
 
 /**
  * Activity which shows the status activity or passes through to web flow.
  */
 public class FxAccountWebFlowActivity extends FxAccountAbstractActivity {
     protected static final String LOG_TAG = FxAccountWebFlowActivity.class.getSimpleName();
 
     protected static final String ABOUT_ACCOUNTS = "about:accounts";
+
+    public static final String EXTRA_ENDPOINT = "entrypoint";
+
+    protected static final String[] EXTRAS_TO_PASSTHROUGH = new String[] {
+            EXTRA_ENDPOINT,
+    };
+
     private final String action;
     private final String extras;
 
     public FxAccountWebFlowActivity(int resume, String action) {
         this(resume, action, null);
     }
 
     public FxAccountWebFlowActivity(int resume, String action, String extras) {
@@ -44,18 +51,38 @@ public class FxAccountWebFlowActivity ex
         super.onCreate(icicle);
     }
 
     protected boolean redirectIfAppropriate() {
         final boolean redirected = super.redirectIfAppropriate();
         if (redirected) {
             return true;
         }
-        ActivityUtils.openURLInFennec(getApplicationContext(),
-                ABOUT_ACCOUNTS + "?action=" + action + extras);
+
+        final StringBuilder sb = new StringBuilder();
+        sb.append(ABOUT_ACCOUNTS);
+        sb.append("?action=");
+        sb.append(action);
+        sb.append(extras);
+
+        // Pass through a set of known string values from intent extras to about:accounts.
+        final Intent intent = getIntent();
+        if (intent != null) {
+            for (String key : EXTRAS_TO_PASSTHROUGH) {
+                final String value = intent.getStringExtra(key);
+                if (value != null) {
+                    sb.append("&");
+                    sb.append(key);
+                    sb.append("=");
+                    sb.append(value);
+                }
+            }
+        }
+
+        ActivityUtils.openURLInFennec(getApplicationContext(), sb.toString());
         return true;
     }
 
     @Override
     public void onResume() {
         super.onResume();
 
         // We are always redirected.