CVE-2022-41958 (published 2022-11-25T18:15Z)

super-xray is a web vulnerability scanning tool. Versions prior to 0.7 assumed trusted input for the program config which is stored in a yaml file. An attacker with local access to the file could exploit this and compromise the program. This issue has been addressed in commit `4d0d5966` and will be included in future releases. Users are advised to upgrade. There are no known workarounds for this issue.

CVSS v3 base score: 7.8, HIGH (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-502
cwe_name: Deserialization of Untrusted Data
description: The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
extended_description: 
            It is often convenient to serialize objects for communication or to save them for later use. However, deserialized data or code can often be modified without using the provided accessor functions if it does not use cryptography to protect itself. Furthermore, any cryptography would still be client-side security -- which is a dangerous security assumption.
            Data that is untrusted can not be trusted to be well-formed.
            When developers place no restrictions on "gadget chains," or series of instances and method invocations that can self-execute during the deserialization process (i.e., before the object is returned to the caller), it is sometimes possible for attackers to leverage them to perform unauthorized actions, like generating a shell.
         
         

Fix information:
repo_url: https://github.com/4ra1n/super-xray
commit_details: repo_url: https://github.com/4ra1n/super-xray
author: 4ra1n
author_date: 2022-11-24 20:45:39+08:00
msg: yaml rce
repository: repo_url: https://github.com/4ra1n/super-xray
repo_name: 4ra1n/super-xray
description: Web漏洞扫描工具XRAY的GUI启动器
repo_language: Java
owner: 4ra1n
file_changes: filename: CHANGELOG.MD
change_type: ModificationType.MODIFY
diff: @@ -97,7 +97,7 @@ Others:
 当环境是`JDK9+`时，反射调用方法即可。修复了一处功能`bug`并优先加载当前目录的`config.yaml`文件，不会删除，实现了保存设置功能。
 
 另外提供了两种`exe`的下载：
-- 内置`JRE`和`xray`的`exe`可以一键启动：`super-xray-0.7-jre-exe.zip`
+- 内置`JRE`的`exe`可以一键启动：`super-xray-0.7-jre-exe.zip`
 - 调用系统`JRE`的`exe`：`super-xray-0.7-system-jre.exe`
 
 第一种不需要安装任何环境，解压后直接使用；第二种需要本地`JAVA_HOME`或环境变量有配置`Java`

programming_language: Markdown
filename: LookupConfigForm.java
change_type: ModificationType.MODIFY
diff: @@ -3,7 +3,9 @@ package com.chaitin.xray.form;
 import com.chaitin.xray.utils.StringUtil;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
+import org.yaml.snakeyaml.LoaderOptions;
 import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
 
 import javax.swing.*;
 import java.awt.*;
@@ -57,7 +59,7 @@ public class LookupConfigForm {
                 return;
             }
             try {
-                Yaml yaml = new Yaml();
+                Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
                 String newConfig = configTextArea.getText();
                 MainForm.configObj = yaml.load(newConfig);
 

programming_language: Java
filename: MainForm.java
change_type: ModificationType.MODIFY
diff: @@ -12,7 +12,9 @@ import com.intellij.uiDesigner.core.GridLayoutManager;
 import com.intellij.uiDesigner.core.Spacer;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
+import org.yaml.snakeyaml.LoaderOptions;
 import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
 
 import javax.swing.*;
 import javax.swing.border.TitledBorder;
@@ -224,7 +226,7 @@ public class MainForm {
         }
         configTemplate = configStr;
 
-        Yaml yaml = new Yaml();
+        Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
         configObj = yaml.load(configStr);
 
         try {
@@ -684,7 +686,7 @@ public class MainForm {
     }
 
     public void refreshConfig() {
-        Yaml yaml = new Yaml();
+        Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
         StringWriter writer = new StringWriter();
         yaml.dump(configObj, writer);
         configStr = writer.toString();

programming_language: Java
filename: Main.java
change_type: ModificationType.MODIFY
diff: @@ -5,7 +5,11 @@ import com.chaitin.xray.utils.JNAUtil;
 
 public class Main {
     public static void main(String[] args)throws Exception {
-        Process p = Runtime.getRuntime().exec("ls");
-        System.out.println(JNAUtil.getProcessID(p));
+        String context = "!!javax.script.ScriptEngineManager [\n" +
+                "  !!java.net.URLClassLoader [[\n" +
+                "    !!java.net.URL [\"file:./yaml.jar\"]\n" +
+                "  ]]\n" +
+                "]";
+        System.out.println(context);
     }
 }

programming_language: Java