[英]IBM java get defaults (to mitigate CVE-2021-44228
如何在 Java (IBM Java) 上转储默认值以检查默认值
"com.sun.jndi.rmi.object.trustURLCodebase"
"com.sun.jndi.cosnaming.object.trustURLCodebase"
类似这样的东西,但对于上述参数。
java -XX:+PrintFlagsFinal -version
这是为了 CVE-2021-44228 缓解审查。
理想情况下,这可以在 cmd 上进行检查,而无需运行测试代码。
在这里我尝试不显示的测试代码(显示空)
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"));
}
}
编译运行
javac DisplayApp.java -source 1.8 -target 1.8
java TiloDisplay
CVE-2021-44228 根据攻击者的想象力创造了一个巨大的攻击面,而 RCE 只是其中之一。 我强烈建议您通过依赖针对特定攻击向量的 JVM 功能来避免得出错误的结论; 有更多的向量。 只需将log4j-core
提升到 2.15.0 或设置log4j2.formatMsgNoLookups=true
系统属性。
回答问题的信:
默认情况下,相关系统属性似乎没有任何值。 如果他们这样做了,您可以检查:
$ java -XshowSettings:properties -version
请注意, -X
标志是非标准的,尽管 IBM Java 支持这一标志(检查 Semeru 11)。
至于上下文:
实现(至少在 OpenJDK 中)查询属性值,如果属性未设置,则默认为false
,例如
// System property to control whether classes may be loaded from an
// arbitrary URL code base
String trust = getPrivilegedProperty(
"com.sun.jndi.ldap.object.trustURLCodebase", "false");
trustURLCodebase = "true".equalsIgnoreCase(trust);
因此,问题中的-XshowSettings
和编程检查都无助于确定您的 JVM 对于这些功能的默认行为,或者如果您明确设置它们,您正在运行的 JVM 版本是否使用这些属性。
我同意@Volkan 的观点,但我也想验证这些(危险的)JNDI 功能是否被禁用,无论 Log4J 漏洞利用如何。 不幸的是,尽管我们需要另一种方法来做到这一点,理想情况下是一种独立于实现的方法。
我认为关闭这些功能将阻止使用 JNDI 的 RCE,而不仅仅是使用 Log4J2 的 RCE
log4j2.formatMsgNoLookups -> set to true
"com.sun.jndi.rmi.object.trustURLCodebase" -> set to false
"com.sun.jndi.cosnaming.object.trustURLCodebase" -> set to false
将Log4J2升级到2.15并升级Java到> Java 8u121
升级到 L4J 2.15.x 是不够的。 还有另一个漏洞利用(参见https://www.zdnet.com/article/second-log4j-vulnerability-found-apache-log4j-2-16-0-released/ )并且新版本 L4J 2.16 已经发布,已经禁用默认JNDI 设置( https://logging.apache.org/log4j/2.x/download.html )现在更重要的是升级到 2.16 版本。 但是有许多 L4J 克隆、使用相同 L4J 类的自定义代码,这就是为什么检查 JVM 设置很重要的原因,特别是对于 6u211、7u201 和 8u191 之前的 JDK 版本,并禁用 JNDI + RMI 设置。 2016 年在 BlackHat 上介绍了有关它的更多信息,请参阅https://www.blackhat.com/docs/us-16/materials/us-16-Munoz-A-Journey-From-JNDI-LDAP-Manipulation-To-RCE。 pdf 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.