@@ -223,59 +223,4 @@ public void testStoredSSRFWithNoContext() throws InterruptedException {
223223 DNSRecordCollector .report ("metadata.google.internal" , new InetAddress []{imdsAddress1 , inetAddress2 });
224224 });
225225 }
226-
227- @ Test
228- public void testPrivateIpLiteralNotRecordedAsOutboundHostname () throws UnknownHostException {
229- // Regression: a private/internal IP literal passed straight to getAllByName
230- // (e.g. Reactor Netty resolver bootstrap resolving nameserver/gateway addresses,
231- // service discovery connecting by IP, a library building a private-IP matcher)
232- // must NOT be recorded as an outbound hostname, otherwise it floods the
233- // "new outbound connection" feature on port 0.
234- Context .set (null );
235- DNSRecordCollector .report ("10.0.0.0" , new InetAddress []{InetAddress .getByName ("10.0.0.0" )});
236- DNSRecordCollector .report ("172.16.0.0" , new InetAddress []{InetAddress .getByName ("172.16.0.0" )});
237- DNSRecordCollector .report ("192.168.0.0" , new InetAddress []{InetAddress .getByName ("192.168.0.0" )});
238- DNSRecordCollector .report ("169.254.0.0" , new InetAddress []{InetAddress .getByName ("169.254.0.0" )});
239- DNSRecordCollector .report ("10.20.11.143" , new InetAddress []{InetAddress .getByName ("10.20.11.143" )});
240- DNSRecordCollector .report ("127.0.0.1" , new InetAddress []{inetAddress2 });
241-
242- assertEquals (0 , HostnamesStore .getHostnamesAsList ().length );
243- }
244-
245- @ Test
246- public void testPrivateIpLiteralWithPendingPortStillConsumedButNotRecorded () {
247- // The pending port must still be consumed (so it can't leak into a later
248- // lookup of a different hostname), but nothing is recorded for the IP literal.
249- PendingHostnamesStore .add ("10.20.11.143" , 443 );
250- Context .set (mock (ContextObject .class ));
251-
252- DNSRecordCollector .report ("10.20.11.143" , new InetAddress []{inetAddress2 });
253-
254- assertEquals (0 , HostnamesStore .getHostnamesAsList ().length );
255- assertTrue (PendingHostnamesStore .getPorts ("10.20.11.143" ).isEmpty ());
256- }
257-
258- @ Test
259- public void testHostnameResolvingToPrivateIpStillRecorded () {
260- // Only raw IP literals are filtered. A real DNS name that resolves to a private
261- // IP (the customer's internal services) is still recorded by NAME.
262- Context .set (null );
263- DNSRecordCollector .report ("keycloak.internal.example.com" , new InetAddress []{inetAddress2 });
264-
265- Hostnames .HostnameEntry [] entries = HostnamesStore .getHostnamesAsList ();
266- assertEquals (1 , entries .length );
267- assertEquals ("keycloak.internal.example.com" , entries [0 ].getHostname ());
268- assertEquals (0 , entries [0 ].getPort ());
269- }
270-
271- @ Test
272- public void testPublicIpLiteralStillRecorded () {
273- // Scope: only PRIVATE IP literals are dropped; public IP literals remain visible.
274- Context .set (null );
275- DNSRecordCollector .report ("1.1.1.1" , new InetAddress []{inetAddress1 });
276-
277- Hostnames .HostnameEntry [] entries = HostnamesStore .getHostnamesAsList ();
278- assertEquals (1 , entries .length );
279- assertEquals ("1.1.1.1" , entries [0 ].getHostname ());
280- }
281226}
0 commit comments