The OWASP Enterprise Security API (ESAPI) is a powerful and widely-used open-source library providing web application security controls. In versions prior to 2.3.., a vulnerability has been identified within the default implementation of Validator.getValidDirectoryPath(String, String, File, boolean) method. This vulnerability could potentially allow an attacker to bypass control-flow checks by manipulating the input string representing the 'input' path.

Affected Versions

ESAPI versions prior to 2.3.. are affected by this vulnerability.

Vulnerability Details

The vulnerability exists in the Validator.getValidDirectoryPath() method of ESAPI. Below is a code snippet showcasing the issue:

public File getValidDirectoryPath( String context, String input, File parent, boolean allowNull ) throws ValidationException {
    File file = getValidFile( context, input, allowNull );
    if ( file.isDirectory() ) {
        String canonicalPath = file.getCanonicalPath();
        String canonicalParent = parent.getCanonicalPath();
        if ( canonicalPath.startsWith( canonicalParent ) ) {
            return file;
        }
    }
    throw new ValidationException( context + ": Invalid directory path", "Invalid directory path" );
}

Here, the tested input string is supposed to be a child of the specified parent directory. However, a flaw exists here wherein the method incorrectly treats the tested input string as a child of the parent directory. If an attacker can manipulate the entire 'input' path, they could potentially bypass control-flow check enforcement.

Mitigation

The vulnerability has been patched in version 2.3.. of ESAPI. It is recommended to update your ESAPI version to 2.3.. or higher. You can download the updated version from the official ESAPI GitHub repository: https://github.com/ESAPI/esapi-java-legacy/releases/tag/2.3..

Workaround

If updating the ESAPI version is not a viable option, an alternative workaround is to implement your own version of the Validator interface. However, the maintainers do not recommend this for most users, as it could lead to unintended consequences and potential security risks.

Original References

1. ESAPI GitHub Repository: https://github.com/ESAPI/esapi-java-legacy
2. ESAPI Release 2.3..: https://github.com/ESAPI/esapi-java-legacy/releases/tag/2.3..
3. CVE-2022-23457 Details: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-23457

Conclusion

The CVE-2022-23457 vulnerability allows an attacker to manipulate the 'input' path, potentially bypassing control-flow checks that could have serious security implications. Updating your ESAPI version to 2.3.. or higher is the recommended solution to mitigate this vulnerability. Make sure to properly evaluate and test any changes implemented in your application's environment to minimize the chances of introducing further security risks.

Timeline

Published on: 04/25/2022 20:15:00 UTC
Last modified on: 07/25/2022 18:21:00 UTC