Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-3547

Path traversal via resources parameter in ssx and jsx enpoints - incomplete CVE-2025-55748 fix

    XMLWordPrintable

Details

    • Unit, Integration
    • Unknown
    • N/A

    Description

      The fix for CVE-2025-55748 is insufficient, allowing for path traversal via the "resource" parameter to retrieve sensitive configuration files.

       

      An example payload which could be used to access the config file (containing the superadmin password) is /bin/jsx/Main/WebHome?resource=/../../WEB-INF/xwiki.cfg

       

      The fix included in the ClassLoaderUtils.java resolveResourceName method is incomplete.

      
          private static String resolveResourceName(String prefixPath, String resourcePath)
          {
              String fullPath;
              if (StringUtils.isEmpty(prefixPath)) {
                  fullPath = resourcePath;
      
                  // Prevent access to resources from other directories
                  // TODO: find or implement something closed to Servlet ClassLoader behavior to be as accurate as possible
                  // and be able to reuse the normalized result
                  Path normalizedResource = Paths.get(fullPath).normalize();
                  if (normalizedResource.startsWith("../")) {
                      throw new IllegalArgumentException(String.format(
                          "The provided resource name [%s] is trying to navigate out of the mandatory root location",
                          resourcePath));
                  }
              } else {
                  fullPath = prefixPath + resourcePath;
      
                  // Prevent access to resources from other directories
                  // TODO: find or implement something closed to Servlet ClassLoader behavior to be as accurate as possible
                  // and be able to reuse the normalized result
                  Path normalizedResource = Paths.get(fullPath).normalize();
                  if (!normalizedResource.startsWith(prefixPath)) {
                      throw new IllegalArgumentException(String.format(
                          "The provided resource name [%s] is trying to navigate out of the mandatory prefix [%s]",
                          resourcePath, prefixPath));
                  }
              }
      
              // We cannot sent back the normalized version as it might produce a result which is not compatible with the
              // ClassLoader (for example, on Windows Path#normalize() is replacing all "/" by "\", which is not a path
              // separator in ClassLoader)
      
              return fullPath;
          }
      

      Submitting a payload starting with "/" instead of a "../" sequence does not trigger the path traversal exception. However, after the checks, the method returns fullPath instead of the normalized normalizedResource, which results in the same vulnerability as before.

       

      Useful resources:

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              mikestick Michał
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: