如何在 Java (IBM Java) 上转储默认值以检查以下默认值?
"com.sun.jndi.rmi.object.trustURLCodebase"
"com.sun.jndi.cosnaming.object.trustURLCodebase"
Run Code Online (Sandbox Code Playgroud)
类似这样,但对于上述参数:
"com.sun.jndi.rmi.object.trustURLCodebase"
"com.sun.jndi.cosnaming.object.trustURLCodebase"
Run Code Online (Sandbox Code Playgroud)
这是针对CVE-2021-44228缓解审查的。
理想情况下,这可以在 cmd 上检查,而不需要运行测试代码。
这是我尝试的测试代码,但未显示(显示 Null):
java -XX:+PrintFlagsFinal -version
Run Code Online (Sandbox Code Playgroud)
编译并运行:
import java.util.Properties;
class TiloDisplay
{
public static void main(String[] args)
{
Properties prop = System.getProperties();
printProperties(prop);
}
public static void printProperties(Properties prop) {
prop.stringPropertyNames().stream()
.map(key -> key + ": " + prop.getProperty(key))
.forEach(System.out::println);
System.out.println("CVE check part ========================================== " );
System.out.println("CVE check for:: com.sun.jndi.ldap.object.trustURLCodebase: " + prop.getProperty("com.sun.jndi.ldap.object.trustURLCodebase"));
System.out.println("CVE check for:: com.sun.jndi.rmi.object.trustURLCodebase: " + prop.getProperty("com.sun.jndi.rmi.object.trustURLCodebase"));
System.out.println("CVE check for:: com.sun.jndi.cosnaming.object.trustURLCodebase: " + prop.getProperty("com.sun.jndi.cosnaming.object.trustURLCodebase"));
System.out.println("Cross Check: " + prop.getProperty("java.version"));
}
}
Run Code Online (Sandbox Code Playgroud)
回答问题的信件:
默认情况下,相关系统属性似乎没有任何值。如果他们这样做了,您可以检查:
java -XshowSettings:properties -version
Run Code Online (Sandbox Code Playgroud)
请注意,-X标志是非标准的,尽管 IBM Java 支持这一标志(已检查 Semeru 11)。
至于上下文:
实现(至少在OpenJDKfalse中)查询属性值,默认为属性未设置,例如,
java -XshowSettings:properties -version
Run Code Online (Sandbox Code Playgroud)
因此,-XshowSettings问题中的编程检查都无法帮助确定您的 JVM 对于这些功能默认的行为,或者如果您显式设置它们,您正在运行的 JVM 版本是否使用这些属性。
我同意Volkan 的观点,但我还想验证这些(危险的)JNDI功能是否已禁用,无论 Log4j 漏洞如何。不幸的是,尽管我们需要另一种方法来做到这一点,最好是一种独立于实现的方法。