Skip to content

Commit ce65785

Browse files
JensenPaulandi34
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 55c1fe2 commit ce65785

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/java/android/net/PacProxySelector.java

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

3637
/**
@@ -65,7 +66,15 @@ public List<Proxy> select(URI uri) {
6566
String response = null;
6667
String urlString;
6768
try {
69+
// Strip path and username/password from URI so it's not visible to PAC script. The
70+
// path often contains credentials the app does not want exposed to a potentially
71+
// malicious PAC script.
72+
if (!"http".equalsIgnoreCase(uri.getScheme())) {
73+
uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), "/", null, null);
74+
}
6875
urlString = uri.toURL().toString();
76+
} catch (URISyntaxException e) {
77+
urlString = uri.getHost();
6978
} catch (MalformedURLException e) {
7079
urlString = uri.getHost();
7180
}

0 commit comments

Comments
 (0)