-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.json
25 lines (25 loc) · 2.26 KB
/
3.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"file_path": "security_data/gpt3_security_vulnerability_scanner-main/Unsafe Deserialization/SerializeToFile.java",
"vulnerability": "Vulnerabilities Detected:\n1. Insecure Deserialization: Deserializing untrusted data can lead to remote code execution.\n2. Insecure File Permissions: The file being written to or read from may have insecure permissions, allowing unauthorized access.",
"source code": "class Utils\n{\n // Function to serialize an object and write it to a file\n public static void SerializeToFile(Object obj, String filename)\n {\n try\n {\n FileOutputStream file = new FileOutputStream(filename);\n ObjectOutputStream out = new ObjectOutputStream(file);\n\n // Serialization of the object to file\n System.out.println(\"Serializing \" + obj.toString() + \" to \" + filename);\n out.writeObject(obj);\n\n out.close();\n file.close();\n }\n catch(Exception e)\n {\n System.out.println(\"Exception: \" + e.toString());\n }\n }\n\n // Function to deserialize an object from a file\n public static Object DeserializeFromFile(String filename)\n {\n Object obj = new Object();\n\n try\n {\n FileInputStream file = new FileInputStream(filename);\n ObjectInputStream in = new ObjectInputStream(file);\n\n // Deserialization of the object to file\n System.out.println(\"Deserializing from \" + filename);\n obj = in.readObject();\n\n in.close();\n file.close();\n }\n catch(Exception e)\n {\n System.out.println(\"Exception: \" + e.toString());\n }\n\n return obj;\n }\n}\n",
"language": "java",
"cwe_identifier": [
"CWE-502"
],
"pattern_desc": [
"Insecure deserialization detected. Ensure proper validation and handling of serialized data.\n"
],
"line_number": [
32
],
"line_text": [
" ObjectInputStream in = new ObjectInputStream(file);"
],
"pattern_id": [
"insecure_code_detector.rules.semgrep.java.deserialization_insecure_untrusted_data"
],
"rule": [
null
],
"label": 1
}