Skip to content

Fix CWE-311: enforce HTTPS in URLUtils connection methods#191

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/update-urlutils-secure-connection
Draft

Fix CWE-311: enforce HTTPS in URLUtils connection methods#191
Copilot wants to merge 3 commits intomainfrom
copilot/update-urlutils-secure-connection

Conversation

Copy link

Copilot AI commented Mar 4, 2026

URLUtils opened network connections over plain HTTP without any SSL enforcement, violating CWE-311 (Missing Encryption of Sensitive Data).

Changes

  • New toSecureUrl(URL) — upgrades http:// URLs to https:// via string substitution, preserving all URL components (userInfo, port, query, fragment). Non-HTTP schemes (file://, https://) pass through unchanged.
  • Applied in all four connection sitesexists(), getContent(), getContentType(), and getContentLength() now call toSecureUrl() before opening a connection.
public static URL toSecureUrl(final URL url) {
    if (url != null && "http".equalsIgnoreCase(url.getProtocol())) {
        try {
            return new URL("https" + url.toString().substring(4));
        } catch (MalformedURLException e) {
            // fall through and return the original url
        }
    }
    return url;
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.osgeo.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/pds4-jparser/pds4-jparser org.codehaus.plexus.classworlds.launcher.Launcher compile -q (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/pds4-jparser/pds4-jparser org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip (dns block)
  • repository.jboss.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/pds4-jparser/pds4-jparser org.codehaus.plexus.classworlds.launcher.Launcher compile -q (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.12/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.12/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.12 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.12/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/pds4-jparser/pds4-jparser org.codehaus.plexus.classworlds.launcher.Launcher -f pom.xml -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Dspotbugs.skip -Denforcer.skip -Dmaven.javadoc.skip (dns block)
  • www.puppycrawl.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/xml/tools/xml-extractor.jar --fileList=/tmp/codeql-scratch-d67c6d2584ecd749/dbs/java/working/files-to-index1918694113315701307.list --sourceArchiveDir=/tmp/codeql-scratch-d67c6d2584ecd749/dbs/java/src --outputDir=/tmp/codeql-scratch-d67c6d2584ecd749/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Update URLUtils to ensure secure connection</issue_title>
<issue_description>## Vulnerability
Determine if the findings about SQL queries containing user input that is not sanitized are valid, and determine the potential consequences if they are.

File Warning Line Warning Text Notes
pds4-jparser/src/main/java/gov/nasa/arc/pds/tools/util/URLUtils.java 195 Failure to use SSL (CWE-311) Try to set secure before addCookie. ssoCookie.setSecure(true) plain text viewing possible if not set.
pds4-jparser/src/main/java/gov/nasa/arc/pds/tools/util/URLUtils.java 228 Failure to use SSL (CWE-311) Try to set secure before addCookie. ssoCookie.setSecure(true) plain text viewing possible if not set.
pds4-jparser/src/main/java/gov/nasa/arc/pds/tools/util/URLUtils.java 286 Failure to use SSL (CWE-311) Try to set secure before addCookie. ssoCookie.setSecure(true) plain text viewing possible if not set.

Software Version

Version
</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Update URLUtils to ensure secure connection Fix CWE-311: enforce HTTPS in URLUtils connection methods Mar 4, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update URLUtils to ensure secure connection

2 participants