File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
lib/semmle/code/java/security
test/query-tests/security/CWE-273 Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
97
97
override predicate isSource ( DataFlow:: Node source ) {
98
98
exists ( MethodAccess ma |
99
99
ma instanceof SafeSetEndpointIdentificationAlgorithm and
100
- ma . getQualifier ( ) = source .asExpr ( )
100
+ DataFlow :: getInstanceArgument ( ma ) = source .( DataFlow :: PostUpdateNode ) . getPreUpdateNode ( )
101
101
)
102
102
}
103
103
Original file line number Diff line number Diff line change @@ -102,6 +102,20 @@ public void testSSLSocketEndpointIdSafe() throws Exception {
102
102
socket .getOutputStream (); // Safe
103
103
}
104
104
105
+ public void testSSLSocketEndpointIdSafeWithModificationByReference () throws Exception {
106
+ SSLContext sslContext = SSLContext .getInstance ("TLS" );
107
+ SSLSocketFactory socketFactory = sslContext .getSocketFactory ();
108
+ SSLSocket socket = (SSLSocket ) socketFactory .createSocket ();
109
+ SSLParameters sslParameters = socket .getSSLParameters ();
110
+ onSetSSLParameters (sslParameters );
111
+ socket .setSSLParameters (sslParameters );
112
+ socket .getOutputStream (); // Safe
113
+ }
114
+
115
+ private void onSetSSLParameters (SSLParameters sslParameters ) {
116
+ sslParameters .setEndpointIdentificationAlgorithm ("HTTPS" );
117
+ }
118
+
105
119
public void testSocketEndpointIdNotSet () throws Exception {
106
120
SocketFactory socketFactory = SocketFactory .getDefault ();
107
121
Socket socket = socketFactory .createSocket ("www.example.com" , 80 );
You can’t perform that action at this time.
0 commit comments