Skip to content

Commit ec2fc50

Browse files
JensenPaulThe Android Automerger
authored andcommitted
Don't pass URL path and username/password to PAC scripts
The URL path could contain credentials that apps don't want exposed to a potentially malicious PAC script. Bug: 27593919 Change-Id: I4bb0362fc91f70ad47c4c7453d77d6f9a1e8eeed
1 parent e83f0f6 commit ec2fc50

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

core/java/android/net/PacProxySelector.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.net.ProxySelector;
3131
import java.net.SocketAddress;
3232
import java.net.URI;
33+
import java.net.URISyntaxException;
3334
import java.util.List;
3435

3536
/**
@@ -67,7 +68,15 @@ public List<Proxy> select(URI uri) {
6768
String response = null;
6869
String urlString;
6970
try {
71+
// Strip path and username/password from URI so it's not visible to PAC script. The
72+
// path often contains credentials the app does not want exposed to a potentially
73+
// malicious PAC script.
74+
if (!"http".equalsIgnoreCase(uri.getScheme())) {
75+
uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), "/", null, null);
76+
}
7077
urlString = uri.toURL().toString();
78+
} catch (URISyntaxException e) {
79+
urlString = uri.getHost();
7180
} catch (MalformedURLException e) {
7281
urlString = uri.getHost();
7382
}

0 commit comments

Comments
 (0)