File tree Expand file tree Collapse file tree
lib/semmle/code/java/security
test/query-tests/security/CWE-273 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ private class SafeSslParametersFlowConfig extends DataFlow2::Configuration {
9797 override predicate isSource ( DataFlow:: Node source ) {
9898 exists ( MethodAccess ma |
9999 ma instanceof SafeSetEndpointIdentificationAlgorithm and
100- ma . getQualifier ( ) = source .asExpr ( )
100+ DataFlow :: getInstanceArgument ( ma ) = source .( DataFlow :: PostUpdateNode ) . getPreUpdateNode ( )
101101 )
102102 }
103103
Original file line number Diff line number Diff line change @@ -102,6 +102,20 @@ public void testSSLSocketEndpointIdSafe() throws Exception {
102102 socket .getOutputStream (); // Safe
103103 }
104104
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+
105119 public void testSocketEndpointIdNotSet () throws Exception {
106120 SocketFactory socketFactory = SocketFactory .getDefault ();
107121 Socket socket = socketFactory .createSocket ("www.example.com" , 80 );
You can’t perform that action at this time.
0 commit comments