{"_id": "code_q_000003", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\nfinal class JavaScriptInterface {\n\nJavaScriptInterface () { }\n\n@JavascriptInterface\npublic String getUserInfo() {\nreturn currentUser.Info();}\n }", "query_type": "code"} {"_id": "code_q_000008", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\npublic void doExchange() throws Exception {\n...}", "query_type": "code"} {"_id": "code_q_000009", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\n#include \n#include \n\nint main(int argc, char **argv) {\n\nchar cat[] = \"cat \";\nchar *command;\nsize_t commandLength;\n\ncommandLength = strlen(cat) + strlen(argv[1]) + 1;\ncommand = (char *) malloc(commandLength);\nstrncpy(command, cat, commandLength);\nstrncat(command, argv[1], (commandLength - strlen(cat)) );\n\nsystem(command);\nreturn (0);\n }", "query_type": "code"} {"_id": "code_q_000028", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\nchar *test_string;\n\n if (i != err_val)\n\n {\n\ntest_string = \"Hello World!\";\n }\n\n printf(\"%s\", test_string);", "query_type": "code"} {"_id": "code_q_000032", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\n/* Ignore this weakness (hard-coded password) and this weakness (use of password system for authentication) for this example. */\n\nchar *username = \"admin\";\nchar *pass = \"password\";\n\nint AuthenticateUser(char *inUser, char *inPass) {\nif (strncmp(username, inUser, strlen(inUser))) {\nlogEvent(\"Auth failure of username using strlen of inUser\");\nreturn(AUTH_FAIL);}\nif (! strncmp(pass, inPass, strlen(inPass))) {\nlogEvent(\"Auth success of password using strlen of inUser\");\nreturn(AUTH_SUCCESS);}\nelse {\nlogEvent(\"Auth fail of password using sizeof\");\nreturn(AUTH_FAIL);}}\n\nint main (int argc, char **argv) {\n\nint authResult;\n\nif (argc < 3) {\nExitError(\"Usage: Provide a username and password\");}\nauthResult = AuthenticateUser(argv[1], argv[2]);\nif (authResult == AUTH_SUCCESS) {\nDoAuthenticatedTask(argv[1]);}\nelse {\nExitError(\"Authentication failed\");}\n }", "query_type": "code"} {"_id": "code_q_000036", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Go]\nfunc serve(w http.ResponseWriter, r *http.Request) {\n\n var body []byte\n\n if r.Body != nil {\n\n if data, err := io.ReadAll(r.Body); err == nil {\n\n body = data\n\n }\n }\n }", "query_type": "code"} {"_id": "code_q_000045", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Perl]\n$sock = acceptSocket(1234);\n($cmd, $args) = ParseClientRequest($sock);\nif ($cmd eq \"AUTH\") {\n\n($username, $pass) = split(/\\s+/, $args, 2);\n$result = AuthenticateUser($username, $pass);\nwriteSocket($sock, \"$result\\n\");\n\n # does not close the socket on failure; assumes the\n\n # user will try again\n\n }\nelsif ($cmd eq \"CHANGE-ADDRESS\") {\nif (validateAddress($args)) {\n$res = UpdateDatabaseRecord($username, \"address\", $args);\nwriteSocket($sock, \"SUCCESS\\n\");}\nelse {\nwriteSocket($sock, \"FAILURE -- address is malformed\\n\");}}", "query_type": "code"} {"_id": "code_q_000049", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SQL]\nSELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='$user_input' ORDER BY PRICE", "query_type": "code"} {"_id": "code_q_000068", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[PHP]\n// Define the target location where the picture being\n\n // uploaded is going to be saved.\n\n$target = \"pictures/\" . basename($_FILES['uploadedfile']['name']);\n\n // Move the uploaded file to the new location.\n\nif(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target))\n{\necho \"The picture has been successfully uploaded.\";}\nelse\n{\necho \"There was an error uploading the picture, please try again.\";}", "query_type": "code"} {"_id": "code_q_000069", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[VHDL]\n-- The following VHDL example is written for VHDL-93 or later.\n\n\t\t\tsignal secure : boolean; -- implicitly initialized to ‘false’\n\n\t\t\tsignal policy_ok : boolean;\n\n\t\t\tsignal lock_ready : boolean;\n\n\t\t\t...\n\n\t\t\t-- synthesis translate_off\n\n\t\t\tsecure <= security_check(policy_ok, lock_ready); -- TODO: restore this after debugging\n\n\t\t\t-- synthesis translate_on\n\n\t\t\tprotected_mode_enabled <= secure;\n\n[Verilog]\nreg secure;\n\n\t\t\twire policy_ok;\n\n\t\t\twire lock_ready;\n\n\t\t\twire protected_mode_enabled;\n\n\t\t\t...\n\n\t\t\talways @(*) begin\n\n\t\t\t secure = 1'b0; // default value\n\n\t\t\t // synopsys translate_off\n\n\t\t\t secure = security_check(policy_ok, lock_ready); // TODO: restore this after debugging\n\n\t\t\t // synopsys translate_on\n\n\t\t\tend\n\n\t\t\tassign protected_mode_enabled = secure;", "query_type": "code"} {"_id": "code_q_000073", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\nString author = request.getParameter(AUTHOR_PARAM);\n...\nCookie cookie = new Cookie(\"author\", author);\ncookie.setMaxAge(cookieExpiration);\nresponse.addCookie(cookie);", "query_type": "code"} {"_id": "code_q_000080", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\nif (csr_exception_i.valid && csr_exception_i.cause[63] && commit_instr_i[0].fu != CSR) begin\n\n\t\t\t\t\t\t\t\texception_o = csr_exception_i;\n\n\t\t\t\t\t\t\t\texception_o.tval = commit_instr_i[0].ex.tval;\n\n\t\t\t\t\t\t\tend", "query_type": "code"} {"_id": "code_q_000090", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\n...\n\n logic [31:0] data_d, data_q\n\n logic [512-1:0] pass_data;\n\n ...\n\n Write: begin\n\n ...\n\n if (pass_mode) begin\n\n pass_data = { {60{8'h00}}, data_d};\n\n state_d = PassChk;\n\n pass_mode = 1'b0;\n\n ...\n\n end\n\n ...", "query_type": "code"} {"_id": "code_q_000093", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\n...\n\n\t\talways @(posedge clk_i)\n\n\t\t\tbegin\n\n\t\t\t\tif(~(rst_ni && ~jtag_unlock && ~rst_9))\n\n\t\t\t\t\tbegin\n\n\t\t\t\t\t\tfor (j=0; j < 6; j=j+1) begin\n\n\t\t\t\t\t\t\treglk_mem[j] <= 'h0;\n\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\n\n\t\t...", "query_type": "code"} {"_id": "code_q_000099", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\npublic class RegistrationForm extends org.apache.struts.validator.ValidatorForm {\n\n// private variables for registration form\nprivate String name;\nprivate String email;\n...\n\npublic RegistrationForm() {\nsuper();}\n\npublic ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {\nActionErrors errors = new ActionErrors();\nif (getName() == null || getName().length() < 1) {\nerrors.add(\"name\", new ActionMessage(\"error.name.required\"));}\nreturn errors;}\n\n// getter and setter methods for private variables\n...\n\n}", "query_type": "code"} {"_id": "code_q_000100", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\nchar b[2000];\n\nFILE *f = fopen(\"dbl_cls.c\", \"r\");\n\nif (f)\n\n{\n\nb[0] = 0;\n\n\tfread(b, 1, sizeof(b) - 1, f);\n\n\tprintf(\"%s\\n'\", b);\n\n\tint r1 = fclose(f);\n\n\tprintf(\"\\n-----------------\\n1 close done '%d'\\n\", r1);\n\n\tint r2 = fclose(f);\t// Double close\n\n\tprintf(\"2 close done '%d'\\n\", r2);\n}", "query_type": "code"} {"_id": "code_q_000105", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Verilog]\n// Parameterized Register module example\n\n\t\t\t// Secure_mode : REGISTER_DEFAULT[0] : When set to 1 register is read only and not writable//\n\n\t\t\tmodule register_example\n\n\t\t\t#(\n\n\t\t\tparameter REGISTER_WIDTH = 8, // Parameter defines width of register, default 8 bits\n\n\t\t\tparameter [REGISTER_WIDTH-1:0] REGISTER_DEFAULT = 2**REGISTER_WIDTH -2 // Default value of register computed from Width. Sets all bits to 1s except bit 0 (Secure _mode)\n\n\t\t\t)\n\n\t\t\t(\n\n\t\t\tinput [REGISTER_WIDTH-1:0] Data_in,\n\n\t\t\tinput Clk,\n\n\t\t\tinput resetn,\n\n\t\t\tinput write,\n\n\t\t\toutput reg [REGISTER_WIDTH-1:0] Data_out\n\n\t\t\t);\n\n\t\t\treg Secure_mode;\n\n\t\t\talways @(posedge Clk or negedge resetn)\n\n\t\t\t if (~resetn)\n\n\t\t\t begin\n\n\t\t\t Data_out <= REGISTER_DEFAULT; // Register content set to Default at reset\n\n\t\t\t Secure_mode <= REGISTER_DEFAULT[0]; // Register Secure_mode set at reset\n\n\t\t\t end\n\n\t\t\t else if (write & ~Secure_mode)\n\n\t\t\t begin\n\n\t\t\t Data_out <= Data_in;\n\n\t\t\t end\n\n\t\t\tendmodule\n\n\t\t\tmodule register_top\n\n\t\t\t(\n\n\t\t\tinput Clk,\n\n\t\t\tinput resetn,\n\n\t\t\tinput write,\n\n\t\t\tinput [31:0] Data_in,\n\n\t\t\toutput reg [31:0] S", "query_type": "code"} {"_id": "code_q_000106", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\nint processMessagesFromServer(char *hostaddr, int port) {\n\n...\nint servsock;\nint connected;\nstruct sockaddr_in servaddr;\n\n // create socket to connect to server\n\nservsock = socket( AF_INET, SOCK_STREAM, 0);\nmemset( &servaddr, 0, sizeof(servaddr));\nservaddr.sin_family = AF_INET;\nservaddr.sin_port = htons(port);\nservaddr.sin_addr.s_addr = inet_addr(hostaddr);\n\ndo {\n\n // establish connection to server\n\nconnected = connect(servsock, (struct sockaddr *)&servaddr, sizeof(servaddr));\n\n // if connected then read and process messages from server\n\nif (connected > -1) {\n\n // read and process messages\n\n...\n }\n\n // keep trying to establish connection to the server\n\n} while (connected < 0);\n\n // close socket and return success or failure\n\n...\n }", "query_type": "code"} {"_id": "code_q_000107", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\n/* process message accepts a two-dimensional character array of the form [length][body] containing the message to be processed */\n\nint processMessage(char **message)\n{\n\nchar *body;\n\nint length = getMessageLength(message[0]);\n\nif (length > 0) {\nbody = &message[1][0];\nprocessMessageBody(body);\nreturn(SUCCESS);}\nelse {\nprintf(\"Unable to process message; invalid message length\");\nreturn(FAIL);}\n }", "query_type": "code"} {"_id": "code_q_000110", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\n@Stateless\npublic class ConverterSessionBean extends Component implements KeyListener, ConverterSessionRemote {\n\n /* member variables for receiving keyboard input using AWT API */\n\n...\nprivate StringBuffer enteredText = new StringBuffer();\n\n /* conversion rate on US dollars to Yen */\n\nprivate BigDecimal yenRate = new BigDecimal(\"115.3100\");\n\npublic ConverterSessionBean() {\n\nsuper();\n\n /* method calls for setting up AWT Component for receiving keyboard input */\n\n...\naddKeyListener(this);\n }\n\npublic BigDecimal dollarToYen(BigDecimal dollars) {\nBigDecimal result = dollars.multiply(yenRate);\nreturn result.setScale(2, BigDecimal.ROUND_DOWN);}\n\n /* member functions for implementing AWT KeyListener interface */\n\npublic void keyTyped(KeyEvent event) {\n...}\n\npublic void keyPressed(KeyEvent e) {\n}\n\npublic void keyReleased(KeyEvent e) {\n}\n\n /* member functions for receiving keyboard input and displaying output */\n\npublic void pa", "query_type": "code"} {"_id": "code_q_000115", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[JavaScript]\n

(i === s1) is FALSE

\n\n

(s4 === i) is FALSE

\n\n

(s4 === s1) is FALSE

\n\n var i = 65;\n\n var s1 = '65';\n\n var s4 = new String('65');\n\n if (i === s1)\n\n {\n\ndocument.getElementById(\"ieq3s1\").innerHTML = \"(i === s1) is TRUE\";\n }\n\n if (s4 === i)\n\n {\n\ndocument.getElementById(\"s4eq3i\").innerHTML = \"(s4 === i) is TRUE\";\n }\n\n if (s4 === s1)\n\n {\n\ndocument.getElementById(\"s4eq3s1\").innerHTML = \"(s4 === s1) is TRUE\";\n }", "query_type": "code"} {"_id": "code_q_000121", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[PHP]\n$userName = $_POST[\"user\"];\n$command = 'ls -l /home/' . $userName;\nsystem($command);", "query_type": "code"} {"_id": "code_q_000127", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[HTML]\n
\n\n\n
", "query_type": "code"} {"_id": "code_q_000133", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\nIntent intent = new Intent();\nintent.setAction(\"com.example.service.UserExists\");\nintent.putExtra(\"Username\", uname_string);\nsendStickyBroadcast(intent);", "query_type": "code"} {"_id": "code_q_000138", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[PHP]\n$xmlContent = file_get_contents('php://input');\n\n if (empty($xmlContent)) {\n\n http_response_code(400);\n\n exit('No XML content received.');\n\n }\n\n $xml = simplexml_load_string($xmlContent, 'SimpleXMLElement');\n\n echo $xml->asXML();", "query_type": "code"} {"_id": "code_q_000147", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[PHP]\n$redirect_url = $_GET['url'];\nheader(\"Location: \" . $redirect_url);", "query_type": "code"} {"_id": "code_q_000151", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\n...\nchar source[21] = \"the character string\";\nchar dest[12];\nstrncpy(dest, source, sizeof(source)-1);\n...", "query_type": "code"} {"_id": "code_q_000154", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Perl]\nsub GetUntrustedInput {\nreturn($ARGV[0]);}\n\nsub encode {\nmy($str) = @_;\n$str =~ s/\\&/\\&/gs;\n$str =~ s/\\\"/\\"/gs;\n$str =~ s/\\'/\\'/gs;\n$str =~ s/\\/\\>/gs;\nreturn($str);}\n\nsub doit {\nmy $uname = encode(GetUntrustedInput(\"username\"));\nprint \"Welcome, $uname!

\\n\";\nsystem(\"cd /home/$uname; /bin/ls -l\");\n\n }", "query_type": "code"} {"_id": "code_q_000155", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\nif (csr_we || csr_read) begin\n\n\t\t\t\t\t\t\t\tif ((riscv::priv_lvl_t'(priv_lvl_o & csr_addr.csr_decode.priv_lvl) != csr_addr.csr_decode.priv_lvl) && !(csr_addr.address==riscv::CSR_MEPC)) begin\n\n\t\t\t\t\t\t\t\t\tcsr_exception_o.cause = riscv::ILLEGAL_INSTR;\n\n\t\t\t\t\t\t\t\t\tcsr_exception_o.valid = 1'b1;\n\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t// check access to debug mode only CSRs\n\n\t\t\t\t\t\t\t\tif (csr_addr_i[11:4] == 8'h7b && !debug_mode_q) begin\n\n\t\t\t\t\t\t\t\t\tcsr_exception_o.cause = riscv::ILLEGAL_INSTR;\n\n\t\t\t\t\t\t\t\t\tcsr_exception_o.valid = 1'b1;\n\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tend", "query_type": "code"} {"_id": "code_q_000162", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\nint proc_msg(char *s, int msg_len)\n\n{\n\nint pre_len = sizeof(\"preamble: \"); // Note space at the end of the string - assume all strings have preamble with space\n\nchar buf[pre_len - msg_len];\n\n... Do processing here and set status\n\nreturn status;\n}\n\nchar *s = \"preamble: message\\n\";\n\nchar *sl = strchr(s, ':'); // Number of characters up to ':' (not including space)\n\nint jnklen = sl == NULL ? 0 : sl - s; // If undefined pointer, use zero length\n\nint ret_val = proc_msg (\"s\", jnklen); // Violate assumption of preamble length, end up with negative value, blow out stack", "query_type": "code"} {"_id": "code_q_000167", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\n...\n\n\t\t\t\tmodule mod_exp\n\n\t\t\t\t\t...\n\n\t\t\t\t\t`UPDATE: begin\n\n\t\t\t\t\t\tif (exponent_reg != 'd0) begin\n\n\t\t\t\t\t\t\tif (exponent_reg[0])\n\n\t\t\t\t\t\t\t\tresult_reg <= result_next;\n\n\t\t\t\t\t\t\tbase_reg <= base_next;\n\n\t\t\t\t\t\t\texponent_reg <= exponent_next;\n\n\t\t\t\t\t\t\tstate <= `UPDATE;\n\n\t\t\t\t\t...\n\n\t\t\t\tendmodule", "query_type": "code"} {"_id": "code_q_000169", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Verilog]\nalways @(posedge clk) begin\n\n\t\t\t\t\t if (en) lock_jtag <= d;\n\n\t\t\t\t\t end", "query_type": "code"} {"_id": "code_q_000171", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\npublic class Main {\n\npublic static void main(String[] args) {\n\ndouble s = 10.0;\n\ndouble r = 1.0;\n\ndouble pi = 3.14159;\n\ndouble surface_area;\n\nif(r > 0.0) {\n\n// complex math equations\n\nsurface_area = pi * r * s + pi * Math.pow(r, 2);\n\n}\n\nif(r > 1.0) {\n\n// a complex set of math\n\nsurface_area = pi * r * s + pi * Math.pow(r, 2);\n\n}\n\n}\n\n}", "query_type": "code"} {"_id": "code_q_000172", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[C]\n#define JAN 1\n#define FEB 2\n#define MAR 3\n\nshort getMonthlySales(int month) {...}\n\nfloat calculateRevenueForQuarter(short quarterSold) {...}\n\nint determineFirstQuarterRevenue() {\n\n // Variable for sales revenue for the quarter\n\nfloat quarterRevenue = 0.0f;\n\nshort JanSold = getMonthlySales(JAN); /* Get sales in January */\nshort FebSold = getMonthlySales(FEB); /* Get sales in February */\nshort MarSold = getMonthlySales(MAR); /* Get sales in March */\n\n // Calculate quarterly total\n\nshort quarterSold = JanSold + FebSold + MarSold;\n\n // Calculate the total revenue for the quarter\n\nquarterRevenue = calculateRevenueForQuarter(quarterSold);\n\nsaveFirstQuarterRevenue(quarterRevenue);\n\nreturn 0;\n }", "query_type": "code"} {"_id": "code_q_000180", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[HTML]\n

\n\n\n
\n\n\n
\n\n[PHP]\n// initiate the session in order to validate sessions\n\nsession_start();\n\n //if the session is registered to a valid user then allow update\n\nif (! session_is_registered(\"username\")) {\n\necho \"invalid session detected!\";\n\n // Redirect user to login page\n\n[...]\n\nexit;\n }\n\n // The user session is valid, so process the request\n\n // and update the information\n\nupdate_profile();\n\nfunction update_profile {\n\n // read in the data from $POST and send an update\n\n // to the database\n\nSendUpdateToDatabase($_SESSION['username'], $_POST['email']);\n[...]\necho \"Your profile has been successfully updated.\";\n }", "query_type": "code"} {"_id": "code_q_000182", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Java]\ntry {\nFile file = new File(\"object.obj\");\nObjectInputStream in = new ObjectInputStream(new FileInputStream(file));\njavax.swing.JButton button = (javax.swing.JButton) in.readObject();\nin.close();}", "query_type": "code"} {"_id": "code_q_000186", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Verilog]\n// 2x1 Multiplexor using logic-gates\n\n\t\t\t\t\t\tmodule glitchEx(\n\n\t\t\t\t\t\t\tinput wire in0, in1, sel,\n\n\t\t\t\t\t\t\toutput wire z\n\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\twire not_sel;\n\n\t\t\t\t\t\twire and_out1, and_out2;\n\n\t\t\t\t\t\tassign not_sel = ~sel;\n\n\t\t\t\t\t\tassign and_out1 = not_sel & in0;\n\n\t\t\t\t\t\tassign and_out2 = sel & in1;\n\n\t\t\t\t\t\t// Buggy line of code:\n\n\t\t\t\t\t\tassign z = and_out1 | and_out2; // glitch in signal z\n\n\t\t\t\t\t\tendmodule", "query_type": "code"} {"_id": "code_q_000189", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[Python]\ndef killProcess(processID):\nos.kill(processID, signal.SIGKILL)", "query_type": "code"} {"_id": "code_q_000195", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\nmodule aes1_wrapper #(\n\n ...\n\n assign core_key0 = debug_mode_i ? 'b0 : {\n\n key_reg0[7],\n\n key_reg0[6],\n\n key_reg0[5],\n\n key_reg0[4],\n\n key_reg0[3],\n\n key_reg0[2],\n\n key_reg0[1],\n\n key_reg0[0]};\n\n assign core_key1 = {\n\n key_reg1[7],\n\n key_reg1[6],\n\n key_reg1[5],\n\n key_reg1[4],\n\n key_reg1[3],\n\n key_reg1[2],\n\n key_reg1[1],\n\n key_reg1[0]};\n\n ...\n\n endmodule", "query_type": "code"} {"_id": "code_q_000197", "text": "Find a secure defensive implementation to replace this vulnerable code:\n[SystemVerilog]\n...\n\n\t\tlogic [31-1:0] data_d, data_q;\n\n\t\t...\n\n\t\tlogic [512-1:0] pass_data;\n\n\t\t...\n\n\t\t\tWrite: begin\n\n\t\t\t\t...\n\n\t\t\t\t\tif (pass_mode) begin\n\n\t\t\t\t\t\t\tpass_data = { {60{8'h00}}, data_d};\n\n\t\t\t\t\t\t\tstate_d = PassChk;\n\n\t\t\t\t\t\t\tpass_mode = 1'b0;\n\n\t\t\t\t\t...\n\n\t\t\tend\n\n\t\t...", "query_type": "code"} {"_id": "code_q_000213", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse CMSTP to proxy execution of malicious code. The Microsoft Connection Manager Profile Installer (CMSTP.exe) is a command-line program used to install Connection Manager service profiles.(Citation: Microsoft Connection Manager Oct 2009) CMSTP.exe accepts an installation information file (INF) as a parameter and installs a service profile leveraged for remote access connections. Adversaries may supply CMSTP.exe with INF files infected with malicious commands.(Citation: Twitter CMSTP Usage Jan 2018) Similar to [Regsvr32]( / ”Squiblydoo”, CMSTP.exe may be abused to load and execute DLLs(Citation: MSitPros CMSTP Aug 2017) and/or COM scriptlets (SCT) from remote servers.(Citation: Twitter CMSTP Jan 2018)(Citation: GitHub Ultimate AppLocker Bypass List)(Citation: Endurant CMS", "query_type": "nl"} {"_id": "code_q_000220", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse task scheduling functionality to facilitate initial or recurring execution of malicious code. Utilities exist within all major operating systems to schedule programs or scripts to be executed at a specified date and time. A task can also be scheduled on a remote system, provided the proper authentication is met (ex: RPC and file and printer sharing in Windows environments). Scheduling a task on a remote system typically may require being a member of an admin or otherwise privileged group on the remote system.(Citation: TechNet Task Scheduler Security) Adversaries may use task scheduling to execute programs at system startup or on a scheduled basis for persistence. These mechanisms can also be abused to run a process under the context of a specified account (such as on", "query_type": "nl"} {"_id": "code_q_000222", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may gather the component that can be used during targeting. Even if internal instances exist, organizations may have public-facing email infrastructure and addresses for employees. Adversaries may easily gather the component, since they may be readily available and exposed via online or other accessible data sets (ex: [Social Media]( or [Search Victim-Owned Websites]( HackersArise Email)(Citation: CNET Leaks) the component could also be enumerated via more active means (i.e. [Active Scanning]( such as probing and analyzing responses from authentication services that may reveal valid usernames in a system.(Citation: GrimBlog UsernameEnum) For example, adversaries may be able to enumerate the component in Office 365 environments by querying a variety of publicly available API end", "query_type": "nl"} {"_id": "code_q_000228", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse the cron utility to perform task scheduling for initial or recurring execution of malicious code.(Citation: 20 macOS Common Tools and Techniques) The cron utility is a time-based job scheduler for Unix-like operating systems. The crontab file contains the schedule of cron entries to be run and the specified times for execution. Any crontab files are stored in operating system-specific file paths. An adversary may use cron in Linux or Unix environments to execute programs at system startup or on a scheduled basis for [Persistence]( In ESXi environments, cron jobs must be created directly via the crontab file (e.g., `/var/spool/cron/crontabs/root`).(Citation: CloudSEK ESXiArgs 2023)\n\nTactics: execution, p", "query_type": "nl"} {"_id": "code_q_000233", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may gather information about the victim's networks that can be used during targeting. Information about networks may include a variety of details, including administrative data (ex: IP ranges, domain names, etc.) as well as specifics regarding its topology and operations. Adversaries may gather this information in various ways, such as direct collection actions via [Active Scanning]( or [Phishing for Information]( Information about networks may also be exposed to adversaries via online or other accessible data sets (ex: [Search Open Technical Databases]( WHOIS)(Citation: DNS Dumpster)(Citation: Circl Passive DNS) Gathering this information may reveal opportunities for other forms of reconnaissance (ex: [Active Scanning]( or [Search Open Websites/Domains]( establishing operation", "query_type": "nl"} {"_id": "code_q_000240", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may create an account to maintain access to victim systems.(Citation: Symantec WastedLocker June 2020) With a sufficient level of access, creating such accounts may be used to establish secondary credentialed access that does not require persistent remote access tools to be deployed on the system. Accounts may be created on the local system or within a domain or cloud tenant. In cloud environments, adversaries may create accounts that only have access to specific services, which can reduce the chance of detection.\n\nTactics: persistence\n\nPlatforms: Windows, IaaS, Linux, macOS, Network Devices, Containers, SaaS, Office Suite, Identity Provider, ESXi", "query_type": "nl"} {"_id": "code_q_000242", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may destroy data and files on specific systems or in large numbers on a network to interrupt availability to systems, services, and network resources. the component is likely to render stored data irrecoverable by forensic techniques through overwriting files or data on local and remote drives.(Citation: Symantec Shamoon 2012)(Citation: FireEye Shamoon Nov 2016)(Citation: Palo Alto Shamoon Nov 2016)(Citation: Kaspersky StoneDrill 2017)(Citation: Unit 42 Shamoon3 2018)(Citation: Talos Olympic Destroyer 2018) Common operating system file deletion commands such as del and rm often only remove pointers to files without wiping the contents of the files themselves, making the files recoverable by proper forensic methodology. This behavior is distinct from [D", "query_type": "nl"} {"_id": "code_q_000257", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may attempt to extract credential material from the the component (SAM) database either through in-memory techniques or through the Windows Registry where the SAM database is stored. The SAM is a database file that contains local accounts for the host, typically those found with the net user command. Enumerating the SAM database requires SYSTEM level access. A number of tools can be used to retrieve the SAM file through in-memory techniques: * pwdumpx.exe * [gsecdump]( * [Mimikatz]( * secretsdump.py Alternatively, the SAM can be extracted from the Registry with Reg: * reg save HKLM\\sam sam * reg save HKLM\\system system Creddump7 can then be used to process the SAM database locally to retrieve hashes.(Citation: GitHub Creddump7) Notes: * RI", "query_type": "nl"} {"_id": "code_q_000263", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may gather information about identities and roles within the victim organization that can be used during targeting. Information about business roles may reveal a variety of targetable details, including identifiable information for key personnel as well as what data/resources they have access to. Adversaries may gather this information in various ways, such as direct elicitation via [Phishing for Information]( Information about business roles may also be exposed to adversaries via online or other accessible data sets (ex: [Social Media]( or [Search Victim-Owned Websites]( ThreatPost Broadvoice Leak) Gathering this information may reveal opportunities for other forms of reconnaissance (ex: [Phishing for Information]( or [Search Open Websites/Domains]( establishing operational re", "query_type": "nl"} {"_id": "code_q_000277", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may communicate using a protocol and port pairing that are typically not associated (for example, HTTPS over port 8088(Citation: Symantec Elfin Mar 2019) or port 587(Citation: Fortinet Agent Tesla April 2018) as opposed to the traditional port 443). Adversaries may make changes to the standard port used by a protocol to bypass filtering or muddle analysis/parsing of network data. Adversaries may also make changes to victim systems to abuse non-standard ports. For example, Registry keys and other configuration settings can be used to modify protocol and port pairings.(Citation: change_rdp_port_conti)\n\nTactics: command-and-control\n\nPlatforms: ESXi, Linux, macOS, Windows", "query_type": "nl"} {"_id": "code_q_000281", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may perform the component (DoS) attacks to degrade or block the availability of services to users. Endpoint DoS can be performed by exhausting the system resources those services are hosted on or exploiting the system to cause a persistent crash condition. Example services include websites, email services, DNS, and web-based applications. Adversaries have been observed conducting DoS attacks for political purposes(Citation: FireEye OpPoisonedHandover February 2016) and to support other malicious activities, including distraction(Citation: FSISAC FraudNetDoS September 2012), hacktivism, and extortion.(Citation: Symantec DDoS October 2014) An Endpoint DoS denies the availability of a service without saturating the network used to provide access to the service. Adversaries can tar", "query_type": "nl"} {"_id": "code_q_000287", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may use a connection proxy to direct network traffic between systems or act as an intermediary for network communications to a command and control server to avoid direct connections to their infrastructure. Many tools exist that enable traffic redirection through proxies or port redirection, including [HTRAN]( ZXProxy, and ZXPortMap.(Citation: Trend Micro APT Attack Tools) Adversaries use these types of proxies to manage command and control communications, reduce the number of simultaneous outbound network connections, provide resiliency in the face of connection loss, or to ride over existing trusted communications paths between victims to avoid suspicion. Adversaries may chain together multiple proxies to further disguise the source of malicious traffic. Adversaries can also ", "query_type": "nl"} {"_id": "code_q_000289", "text": "Retrieve a detection rule that identifies this adversary behavior: An adversary may rely upon a user opening a the component in order to gain execution. Users may be subjected to social engineering to get them to open a file that will lead to code execution. This user action will typically be observed as follow-on behavior from [Spearphishing Attachment]( Adversaries may use several types of files that require a user to execute them, including .doc, .pdf, .xls, .rtf, .scr, .exe, .lnk, .pif, .cpl, .reg, and .iso.(Citation: Mandiant Trojanized Windows 10) Adversaries may employ various forms of [Masquerading]( and [Obfuscated Files or Information]( to increase the likelihood that a user will open and successfully execute a the component. These methods may include using a familiar naming convention and/or password protecting the file and supplying instructio", "query_type": "nl"} {"_id": "code_q_000296", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may steal data by exfiltrating it over a different protocol than that of the existing command and control channel. The data may also be sent to an alternate network location from the main command and control server. Alternate protocols include FTP, SMTP, HTTP/S, DNS, SMB, or any other network protocol not being used as the main command and control channel. Adversaries may also opt to encrypt and/or obfuscate these alternate channels. [the component]( can be done using various common operating system utilities such as [Net]( or FTP.(Citation: Palo Alto OilRig Oct 2016) On macOS and Linux curl may be used to invoke protocols such as HTTP/S or FTP/S to exfiltrate data from a system.(Citation: 20 macOS Common Tools and Techniques) Many IaaS and SaaS platforms (such as ", "query_type": "nl"} {"_id": "code_q_000307", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may create, acquire, or steal the component materials to sign their malware or tools. the component provides a level of authenticity on a binary from the developer and a guarantee that the binary has not been tampered with.(Citation: Wikipedia the component) The certificates used during an operation may be created, acquired, or stolen by the adversary.(Citation: Securelist Digital Certificates)(Citation: Symantec Digital Certificates) Unlike [Invalid Code Signature]( this activity will result in a valid signature. the component to verify software on first run can be used on modern Windows and macOS systems. It is not used on Linux due to the decentralized nature of the platform.(Citation: Wikipedia the component)(Citation: EclecticLightChecksonEXECodeSigning) the component cert", "query_type": "nl"} {"_id": "code_q_000310", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may acquire credentials from Keychain. Keychain (or Keychain Services) is the macOS credential management system that stores account names, passwords, private keys, certificates, sensitive application data, payment data, and secure notes. There are three types of Keychains: Login Keychain, System Keychain, and Local Items (iCloud) Keychain. The default Keychain is the Login Keychain, which stores user passwords and information. The System Keychain stores items accessed by the operating system, such as items shared among users on a host. The Local Items (iCloud) Keychain is used for items synced with Apple’s iCloud service. Keychains can be viewed and edited through the Keychain Access application or using the command-line utility security. Keychain files are locate", "query_type": "nl"} {"_id": "code_q_000332", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may install a root certificate on a compromised system to avoid warnings when connecting to adversary controlled web servers. Root certificates are used in public key cryptography to identify a root certificate authority (CA). When a root certificate is installed, the system or application will trust certificates in the root's chain of trust that have been signed by the root certificate.(Citation: Wikipedia Root Certificate) Certificates are commonly used for establishing secure TLS/SSL communications within a web browser. When a user attempts to browse a website that presents a certificate that is not trusted an error message will be displayed to warn the user of the security risk. Depending on the security settings, the browser may not allow the user to establish a connection", "query_type": "nl"} {"_id": "code_q_000335", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may send spearphishing messages with a malicious attachment to elicit sensitive information that can be used during targeting. Spearphishing for information is an attempt to trick targets into divulging information, frequently credentials or other actionable information. Spearphishing for information frequently involves social engineering techniques, such as posing as a source with a reason to collect information (ex: [Establish Accounts]( or [Compromise Accounts]( and/or sending multiple, seemingly urgent messages. All forms of spearphishing are electronically delivered social engineering targeted at a specific individual, company, or industry. In this scenario, adversaries attach a file to the spearphishing email. In some cases, they may rely upon the recipient populating inf", "query_type": "nl"} {"_id": "code_q_000337", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may use Windows logon scripts automatically executed at logon initialization to establish persistence. Windows allows logon scripts to be run whenever a specific user or group of users log into a system.(Citation: TechNet Logon Scripts) This is done via adding a path to a script to the HKCU\\Environment\\UserInitMprLogonScript Registry key.(Citation: Hexacorn Logon Scripts) Adversaries may use these scripts to maintain persistence on a single system. Depending on the access configuration of the logon scripts, either local credentials or an administrator account may be necessary.\n\nTactics: persistence, privilege-escalation\n\nPlatforms: Windows", "query_type": "nl"} {"_id": "code_q_000343", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse internet the component to establish persistent access to victim systems. the component or plugins are small programs that can add functionality to and customize aspects of internet browsers. They can be installed directly via a local file or custom URL or through a browser's app store - an official online platform where users can browse, install, and manage extensions for a specific web browser. Extensions generally inherit the web browser's permissions previously granted.(Citation: Wikipedia Browser Extension)(Citation: Chrome Extensions Definition) Malicious extensions can be installed into a browser through malicious app store downloads masquerading as legitimate extensions, through social engineering, or by an adversary that has already compromised a system. Secur", "query_type": "nl"} {"_id": "code_q_000346", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may use an existing, legitimate external Web service as a means for sending commands to and receiving output from a compromised system over the Web service channel. Compromised systems may leverage popular websites and social media to host command and control (C2) instructions. Those infected systems can then send the output from those commands back over that Web service channel. The return traffic may occur in a variety of ways, depending on the Web service being utilized. For example, the return traffic may take the form of the compromised system posting a comment on a forum, issuing a pull request to development project, updating a document hosted on a Web service, or by sending a Tweet. Popular websites and social media acting as a mechanism for C2 may give a significant am", "query_type": "nl"} {"_id": "code_q_000352", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may attempt to get a listing of network connections to or from the compromised system they are currently accessing or from remote systems by querying for information over the network. An adversary who gains access to a system that is part of a cloud-based environment may map out Virtual Private Clouds or Virtual Networks in order to determine what systems and services are connected. The actions performed are likely the same types of discovery techniques depending on the operating system, but the resulting information may include details about the networked cloud environment relevant to the adversary's goals. Cloud providers may have different ways in which their virtual networks operate.(Citation: Amazon AWS VPC Guide)(Citation: Microsoft Azure Virtual Network Overview)(Citatio", "query_type": "nl"} {"_id": "code_q_000353", "text": "Retrieve a detection rule that identifies this adversary behavior: An adversary may add additional roles or permissions to an adversary-controlled cloud account to maintain persistent access to a tenant. For example, adversaries may update IAM policies in cloud-based environments or add a new global administrator in Office 365 environments.(Citation: AWS IAM Policies and Permissions)(Citation: Google Cloud IAM Policies)(Citation: Microsoft Support O365 Add Another Admin, October 2019)(Citation: Microsoft O365 Admin Roles) With sufficient permissions, a compromised account can gain almost unlimited access to data and settings (including the ability to reset the passwords of other admins).(Citation: Expel AWS Attacker)(Citation: Microsoft O365 Admin Roles) This account modification may immediately follow [Create Account]( or other malicious account activity", "query_type": "nl"} {"_id": "code_q_000355", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may stage collected data in a central location or directory prior to Exfiltration. Data may be kept in separate files or combined into one file through techniques such as [Archive Collected Data]( Interactive command shells may be used, and common functionality within [cmd]( and bash may be used to copy data into a staging location.(Citation: PWC Cloud Hopper April 2017) In cloud environments, adversaries may stage data within a particular instance or virtual machine before exfiltration. An adversary may [Create Cloud Instance]( and stage data in that instance.(Citation: Mandiant M-Trends 2020) Adversaries may choose to stage data from a victim network in a centralized location prior to Exfiltration to minimize the number of connections made to their C2 server and better evade ", "query_type": "nl"} {"_id": "code_q_000360", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may employ an encryption algorithm to conceal command and control traffic rather than relying on any inherent protections provided by a communication protocol. Despite the use of a secure algorithm, these implementations may be vulnerable to reverse engineering if secret keys are encoded and/or generated within malware samples/configuration files.\n\nTactics: command-and-control\n\nPlatforms: ESXi, Linux, macOS, Network Devices, Windows", "query_type": "nl"} {"_id": "code_q_000365", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may disable or modify the component (MFA) mechanisms to enable persistent access to compromised accounts. Once adversaries have gained access to a network by either compromising an account lacking MFA or by employing an MFA bypass method such as [the component Request Generation]( adversaries may leverage their access to modify or completely disable MFA defenses. This can be accomplished by abusing legitimate features, such as excluding users from Azure AD Conditional Access Policies, registering a new yet vulnerable/adversary-controlled MFA method, or by manually patching MFA programs and configuration files to bypass expected functionality.(Citation: Mandiant APT42)(Citation: Azure AD Conditional Access Exclusions) For example, modifying the Windows hosts file (`C:\\windows\\sy", "query_type": "nl"} {"_id": "code_q_000367", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may take advantage of trusted developer utilities to proxy execution of malicious payloads. There are many utilities used for software development related tasks that can be used to execute code in various forms to assist in development, debugging, and reverse engineering.(Citation: engima0x3 DNX Bypass)(Citation: engima0x3 RCSI Bypass)(Citation: Exploit Monday WinDbg)(Citation: LOLBAS Tracker) These utilities may often be signed with legitimate certificates that allow them to execute on a system and proxy execution of malicious code through a trusted process that effectively bypasses application control solutions. Smart App Control is a feature of Windows that blocks applications it considers potentially malicious from running by verifying unsigned applications against a known ", "query_type": "nl"} {"_id": "code_q_000368", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may stage collected data in a central location or directory on the local system prior to Exfiltration. Data may be kept in separate files or combined into one file through techniques such as [Archive Collected Data]( Interactive command shells may be used, and common functionality within [cmd]( and bash may be used to copy data into a staging location. Adversaries may also stage collected data in various available formats/locations of a system, including local storage databases/repositories or the Windows Registry.(Citation: Prevailion DarkWatchman 2021)\n\nTactics: collection\n\nPlatforms: ESXi, Linux, macOS, Windows", "query_type": "nl"} {"_id": "code_q_000373", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may leverage information repositories to mine valuable information. Information repositories are tools that allow for storage of information, typically to facilitate collaboration or information sharing between users, and can store a wide variety of data that may aid adversaries in further objectives, such as Credential Access, Lateral Movement, or Defense Evasion, or direct access to the target information. Adversaries may also abuse external sharing features to share sensitive documents with recipients outside of the organization (i.e., [Transfer Data to Cloud Account]( The following is a brief list of example information that may hold potential value to an adversary and may also be found on an information repository: * Policies, procedures, and standards * Physical / logical", "query_type": "nl"} {"_id": "code_q_000375", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may attempt to get a listing of valid accounts, usernames, or email addresses on a system or within a compromised environment. This information can help adversaries determine which accounts exist, which can aid in follow-on behavior such as brute-forcing, spear-phishing attacks, or account takeovers (e.g., [Valid Accounts]( Adversaries may use several methods to enumerate accounts, including abuse of existing tools, built-in commands, and potential misconfigurations that leak account names and roles or permissions in the targeted environment. For examples, cloud environments typically provide easily accessible interfaces to obtain user lists.(Citation: AWS List Users)(Citation: Google Cloud - IAM Servie Accounts List API) On hosts, adversaries can use default [PowerShell]( and ", "query_type": "nl"} {"_id": "code_q_000379", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may make use of the component (DGAs) to dynamically identify a destination domain for command and control traffic rather than relying on a list of static IP addresses or domains. This has the advantage of making it much harder for defenders to block, track, or take over the command and control channel, as there potentially could be thousands of domains that malware can check for instructions.(Citation: Cybereason Dissecting DGAs)(Citation: Cisco Umbrella DGA)(Citation: Unit 42 DGA Feb 2019) DGAs can take the form of apparently random or “gibberish” strings (ex: istgmxdejdnxuyla.ru) when they construct domain names by generating each letter. Alternatively, some DGAs employ whole words as the unit by concatenating words together instead of letters (ex: cityjulydish.net). Many DGA", "query_type": "nl"} {"_id": "code_q_000382", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse legitimate extensible development features of servers to establish persistent access to systems. Enterprise server applications may include features that allow developers to write and install software or scripts to extend the functionality of the main application. Adversaries may install malicious components to extend and abuse server applications.(Citation: volexity_0day_sophos_FW)\n\nTactics: persistence\n\nPlatforms: Windows, Linux, macOS, Network Devices, ESXi", "query_type": "nl"} {"_id": "code_q_000386", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may enumerate information about browsers to learn more about compromised environments. Data saved by browsers (such as bookmarks, accounts, and browsing history) may reveal a variety of personal information about users (e.g., banking sites, relationships/interests, social media, etc.) as well as details about internal network resources such as servers, tools/dashboards, or other related infrastructure.(Citation: Kaspersky Autofill) Browser information may also highlight additional targets after an adversary has access to valid credentials, especially [Credentials In Files]( associated with logins cached by a browser. Specific storage locations vary based on platform and/or application, but browser information is typically stored in local files and databases (e.g., `%APPDATA%/Go", "query_type": "nl"} {"_id": "code_q_000387", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may send phishing messages to gain access to victim systems. All forms of phishing are electronically delivered social engineering. Phishing can be targeted, known as spearphishing. In spearphishing, a specific individual, company, or industry will be targeted by the adversary. More generally, adversaries can conduct non-targeted phishing, such as in mass malware spam campaigns. Adversaries may send victims emails containing malicious attachments or links, typically to execute malicious code on victim systems. Phishing may also be conducted via third-party services (like social media platforms) or delivered via calendar invites. Phishing may also involve social engineering techniques, such as posing as a trusted source, as well as evasive techniques such as removing or manipula", "query_type": "nl"} {"_id": "code_q_000392", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse mmc.exe to proxy execution of malicious .msc files. Microsoft Management Console (MMC) is a binary that may be signed by Microsoft and is used in several ways in either its GUI or in a command prompt.(Citation: win_mmc)(Citation: what_is_mmc) MMC can be used to create, open, and save custom consoles that contain administrative tools created by Microsoft, called snap-ins. These snap-ins may be used to manage Windows systems locally or remotely. MMC can also be used to open Microsoft created .msc files to manage system configuration.(Citation: win_msc_files_overview) For example, mmc C:\\Users\\foo\\admintools.msc /a will open a custom, saved console msc file in author mode.(Citation: win_mmc) Another common example is mmc gpedit.msc, which will o", "query_type": "nl"} {"_id": "code_q_000394", "text": "Retrieve a detection rule that identifies this adversary behavior: Adversaries may abuse the component (IPC) mechanisms for local code or command execution. IPC is typically used by processes to share data, communicate with each other, or synchronize execution. IPC is also commonly used to avoid situations such as deadlocks, which occur when processes are stuck in a cyclic waiting pattern. Adversaries may abuse IPC to execute arbitrary code or commands. IPC mechanisms may differ depending on OS, but typically exists in a form accessible through programming languages/libraries or native interfaces such as Windows [Dynamic Data Exchange]( or [Component Object Model]( Linux environments support several different IPC mechanisms, two of which being sockets and pipes.(Citation: Linux IPC) Higher level execution mediums, such as those of [Command and Scripting I", "query_type": "nl"} {"_id": "code_q_000401", "text": "Find a secure code implementation example satisfying this security guidance: - [this weakness: XPath Injection]( - [lxml: XPath Variables]( - [W3C XPath 3.1: Variable References](", "query_type": "nl"} {"_id": "code_q_000408", "text": "Find a secure code implementation example satisfying this security guidance: The preferred patterns are: - **parameterized queries** when including dynamic data in SQL requests; - for structural parts that cannot be parameterized (table names, column names, sort direction), map user choices to a **strict allow-list** of fixed, application-owned values. Relying on manually escaping dynamic inputs is error-prone and is strongly discouraged. ### Parameterized Queries Define the SQL structure separately from its data values and bind those values through the database API, as shown in the [Basic SQL injection](#basic-sql-injection) example. Concatenating untrusted values into the query before preparing it defeats this protection. See the [Query Parameterization Cheat Sheet", "query_type": "nl"} {"_id": "code_q_000409", "text": "Find a secure code implementation example satisfying this security guidance: - The best practice now is to determine the capabilities that a browser supports and augment with substitutes only for capabilities that are not directly supported. Do not fall back to obsolete browser plugins — Adobe Flash Player reached end-of-life on 31 December 2020 and is removed from all browsers; Java applets, Silverlight, and ActiveX are likewise unsupported. Native HTML5 (`