Cybersecurity researchers recently uncovered a significant directory traversal vulnerability in the Nexus repository, a popular open-source component repository manager. Initially, security analyst X1r0z had reviewed the repository and found no critical issues in the Java Archives (JAR) packages. However, following a vulnerability disclosure by CyberKunlun, the researcher revisited the repository and employed the Jazzer Java fuzzing framework to develop a proof-of-concept (PoC) exploit that demonstrated the flaw.
The technical analysis revealed that Nexus’s handling of public resource requests, such as those for robots.txt, defaulted to Jetty’s WebAppContext#getResource method. This method utilizes Jetty’s PathResource class, which normalizes paths through URIUtil.canonicalPath. However, it fails to properly sanitize the paths before processing, leading to a directory traversal vulnerability. If the path does not start with a “/”, or if canonical paths lead to null, an exception is thrown, highlighting key factors necessary for a successful attack.
To evaluate the exploitability of this vulnerability, the researcher extracted the relevant Jetty path normalization logic into a test harness for the Jazzer fuzzing framework. Jazzer, which integrates with libFuzzer, instruments Java bytecode to track coverage, perform data flow analysis, and detect unsafe functions. By constructing PathResource instances from corrupted inputs and running Jazzer on this harness, it was discovered that fully URL-encoding the path before sending the request could bypass filters and exploit the vulnerable WebResourceServiceImpl module.
This combination of manual analysis and automated fuzzing facilitated the development of an effective proof-of-concept exploit, demonstrating the critical nature of the identified vulnerability. Although the fuzzing process might generate false positives and require multiple runs for validation, techniques like Jazzer remain highly advantageous for vulnerability research. This approach allows researchers to discover subtle vulnerabilities and develop robust exploits across various Java codebases, ultimately enhancing security measures in enterprise environments.
Reference: