JDK-8360166 : CodeSource.implies(): Wildcard host fails to imply specific host
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 8,25
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2025-06-20
  • Updated: 2025-06-30
Description
A DESCRIPTION OF THE PROBLEM :
The java.security.CodeSource.implies(CodeSource) method incorrectly returns false when the implying CodeSource has a URL with a wildcard host (e.g., *.example.com) and the implied CodeSource has a specific host (e.g., www.example.com), even though the specific host falls under the wildcard. This seems to occur because the specific host's name gets resolved to an IP address during the SocketPermission comparison, preventing a successful endsWith check against the wildcard host.


---------- BEGIN SOURCE ----------
import java.security.CodeSource;
import java.net.URL;

public class TestWildcardHost {
   public static void main(String[] args) throws Exception {
       URL thisURL = new URL("http", "*.example.com", "/file");
       URL thatURL = new URL("http", "www.example.com", "/file");
       System.out.println(thisURL);
       System.out.println(thatURL);
       CodeSource thisCs = new CodeSource(thisURL,(java.security.cert.Certificate[]) null);
       CodeSource thatCs = new CodeSource(thatURL, (java.security.cert.Certificate[])null);
       boolean result = thisCs.implies(thatCs); // expect true
       if (!result) {
           throw new RuntimeException("*.example.com can't implies www.example.com");
       }
   }
}
---------- END SOURCE ----------


Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk8u-dev/pull/663 Date: 2025-06-30 05:00:02 +0000
30-06-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25991 Date: 2025-06-26 01:43:51 +0000
26-06-2025

The observations on Windows 11: JDK 8: Failed, RuntimeException thrwon JDK 25ea+12: Failed. Impact -> M (Somewhere in-between the extremes) Likelihood -> L (Uncommon uses) Workaround -> M (Somewhere in-between the extremes) Priority -> P4
21-06-2025