{"_id": "cwe_q_000001", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nstruct hostent *hp;struct in_addr myaddr;\nchar* tHost = \"trustme.example.com\";\nmyaddr.s_addr=inet_addr(ip_addr_string);\n\nhp = gethostbyaddr((char *) &myaddr, sizeof(struct in_addr), AF_INET);\nif (hp && !strncmp(hp->h_name, tHost, sizeof(tHost))) {\ntrusted = true;} else {\ntrusted = false;}\n\n[Java]\nString ip = request.getRemoteAddr();\nInetAddress addr = InetAddress.getByName(ip);\nif (addr.getCanonicalHostName().endsWith(\"trustme.com\")) {\ntrusted = true;}\n\n[C#]\nIPAddress hostIPAddress = IPAddress.Parse(RemoteIpAddress);\nIPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);\nif (hostInfo.HostName.EndsWith(\"trustme.com\")) {\ntrusted = true;}", "query_type": "code"} {"_id": "cwe_q_000002", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid bind_socket(void) {\n\nint server_sockfd;\nint server_len;\nstruct sockaddr_in server_address;\n\n /*unlink the socket if already bound to avoid an error when bind() is called*/\n\nunlink(\"server_socket\");\nserver_sockfd = socket(AF_INET, SOCK_STREAM, 0);\n\nserver_address.sin_family = AF_INET;\nserver_address.sin_port = 21;\nserver_address.sin_addr.s_addr = htonl(INADDR_ANY);\nserver_len = sizeof(struct sockaddr_in);\n\nbind(server_sockfd, (struct sockaddr *) &s1, server_len);\n }", "query_type": "code"} {"_id": "cwe_q_000003", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Go]\nfunc ExecuteGitCommand(name string, arg []string) error {\n\n c := exec.Command(name, arg...)\n\n var err error\n\n c.Path, err = exec.LookPath(name)\n\n if err != nil {\n\n return err\n\n }\n }", "query_type": "code"} {"_id": "cwe_q_000004", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\nfunction printFile($username,$filename){\n\n //read file into string\n\n$file = file_get_contents($filename);\nif ($file && isOwnerOf($username,$filename)){\necho $file;\nreturn true;}\nelse{\necho 'You are not authorized to view this file';}\nreturn false;\n }", "query_type": "code"} {"_id": "cwe_q_000005", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSP]\nSocial Security Number: <%= ssn %>
Credit Card Number: <%= ccn %>", "query_type": "code"} {"_id": "cwe_q_000006", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString str1 = new String(\"Hello\");\nString str2 = new String(\"Hello\");\nif (str1 == str2) {\nSystem.out.println(\"str1 == str2\");}", "query_type": "code"} {"_id": "cwe_q_000007", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Python]\ndef validate_password(actual_pw, typed_pw):\n\nif len(actual_pw) <> len(typed_pw):\n\nreturn 0\n\nfor i in len(actual_pw):\n\nif actual_pw[i] <> typed_pw[i]:\n\nreturn 0\n\nreturn 1", "query_type": "code"} {"_id": "cwe_q_000008", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000009", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar* trimTrailingWhitespace(char *strMessage, int length) {\n\nchar *retMessage;\nchar *message = malloc(sizeof(char)*(length+1));\n\n // copy input string to a temporary string\n\nchar message[length+1];\nint index;\nfor (index = 0; index < length; index++) {\nmessage[index] = strMessage[index];}\nmessage[index] = '\\0';\n\n // trim trailing whitespace\n\nint len = index-1;\nwhile (isspace(message[len])) {\nmessage[len] = '\\0';\nlen--;}\n\n // return string without trailing whitespace\n\nretMessage = message;\nreturn retMessage;\n }", "query_type": "code"} {"_id": "cwe_q_000010", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSP]\n<%Statement stmt = conn.createStatement();\nResultSet rs = stmt.executeQuery(\"select * from emp where id=\"+eid);\nif (rs != null) {\nrs.next();\nString name = rs.getString(\"name\");}%>\n\nEmployee Name: <%= name %>\n\n[ASP.NET]\n<%\nprotected System.Web.UI.WebControls.Label EmployeeName;\n...\nstring query = \"select * from emp where id=\" + eid;\nsda = new SqlDataAdapter(query, conn);\nsda.Fill(dt);\nstring name = dt.Rows[0][\"Name\"];\n...\nEmployeeName.Text = name;%>\n

", "query_type": "code"} {"_id": "cwe_q_000011", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n// Android\n\n@Override\npublic boolean shouldOverrideUrlLoading(WebView view, String url){\n\nif (url.substring(0,14).equalsIgnoreCase(\"examplescheme:\")){\nif(url.substring(14,25).equalsIgnoreCase(\"getUserInfo\")){\nwriteDataToView(view, UserData);\nreturn false;}\nelse{\nreturn true;}}\n }\n\n[Objective-C]\n// iOS\n\n-(BOOL) webView:(UIWebView *)exWebView shouldStartLoadWithRequest:(NSURLRequest *)exRequest navigationType:(UIWebViewNavigationType)exNavigationType\n{\n\nNSURL *URL = [exRequest URL];\nif ([[URL scheme] isEqualToString:@\"exampleScheme\"])\n{\n\nNSString *functionString = [URL resourceSpecifier];\nif ([functionString hasPrefix:@\"specialFunction\"])\n{\n\n // Make data available back in webview.\n\nUIWebView *webView = [self writeDataToView:[URL query]];\n }\nreturn NO;\n }\nreturn YES;\n }", "query_type": "code"} {"_id": "cwe_q_000012", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Verilog]\nassign addr_auth = (address == 32'hF00) ? 1: 0;", "query_type": "code"} {"_id": "cwe_q_000013", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString rName = request.getParameter(\"reportName\");\nFile rFile = new File(\"/usr/local/apfr/reports/\" + rName);\n...\nrFile.delete();", "query_type": "code"} {"_id": "cwe_q_000014", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define OUTFILE \"hello.out\"\n\numask(0);\nFILE *out;\n\n /* Ignore link following (this weakness) for brevity */\n\nout = fopen(OUTFILE, \"w\");\nif (out) {\nfprintf(out, \"hello world!\\n\");\nfclose(out);}", "query_type": "code"} {"_id": "cwe_q_000016", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nmy $Username = GetUntrustedInput();\n$Username =~ s/\\.\\.\\///;\nmy $filename = \"/home/user/\" . $Username;\nReadAndSendFile($filename);", "query_type": "code"} {"_id": "cwe_q_000017", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\n/.../}\ncatch (Exception e) {\nSystem.out.println(e);}", "query_type": "code"} {"_id": "cwe_q_000018", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString keystorePass = System.getProperty(\"javax.net.ssl.keyStorePassword\");\nif (keystorePass == null) {\nSystem.err.println(\"ERROR: Keystore password not specified.\");\nSystem.exit(-1);}\n\n...", "query_type": "code"} {"_id": "cwe_q_000019", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Algorithm]\nSuppose an algorithm for implementing an encryption routine works fine per se, but the time taken to output the result of the encryption routine depends on a relationship between the input plaintext and the key (e.g., suppose, if the plaintext is similar to the key, it would run very fast).", "query_type": "code"} {"_id": "cwe_q_000020", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000021", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nwebapp.ldap.username = secretUsername\nwebapp.ldap.password = secretPassword", "query_type": "code"} {"_id": "cwe_q_000022", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\ntmp = malloc(sizeof(int) * 4);\nif (tmp < 0 ) {\n\nperror(\"Failure\");\n\n //should have checked if the call returned 0\n\n }", "query_type": "code"} {"_id": "cwe_q_000024", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nDataPacket *packet;\nint numHeaders;\nPacketHeader *headers;\n\nsock=AcceptSocketConnection();\nReadPacket(packet, sock);\nnumHeaders =packet->headers;\n\nif (numHeaders > 100) {\nExitError(\"too many headers!\");}\nheaders = malloc(numHeaders * sizeof(PacketHeader);\nParsePacketHeaders(packet, headers);", "query_type": "code"} {"_id": "cwe_q_000025", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000028", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\nlogic [511:0] bigData;\n\n ...\n\n hmac hmac(\n\n .clk_i(clk_i),\n\n .rst_ni(rst_ni && ~rst_4),\n\n .init_i(startHash && ~startHash_r),\n\n .key_i(key),\n\n .ikey_hash_i(ikey_hash),\n\n .okey_hash_i(okey_hash),\n\n .key_hash_bypass_i(key_hash_bypass),\n\n .message_i(bigData),\n\n .hash_o(hash),\n\n .ready_o(ready),\n\n .hash_valid_o(hashValid)", "query_type": "code"} {"_id": "cwe_q_000029", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\nString username = request.getParameter(\"username\");\n\n // May cause unchecked NullPointerException.\n\nif (username.length() < 10) {\n...}\n }", "query_type": "code"} {"_id": "cwe_q_000030", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nif (helper == null) {\n\nsynchronized (this) {\nif (helper == null) {\nhelper = new Helper();}}\n }\nreturn helper;\n\n[Java]\nhelper = new Helper();", "query_type": "code"} {"_id": "cwe_q_000031", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define CERT \"secret.pem\"\n#define CERT2 \"secret2.pem\"\n\nint main(){\n\nSSL_CTX *ctx;\nSSL *ssl;\ninit_OpenSSL();\nseed_prng();\n\nctx = SSL_CTX_new(SSLv23_method());\n\nif (SSL_CTX_use_certificate_chain_file(ctx, CERT) != 1)\nint_error(\"Error loading certificate from file\");\n\nif (SSL_CTX_use_PrivateKey_file(ctx, CERT, SSL_FILETYPE_PEM) != 1)\nint_error(\"Error loading private key from file\");\n\nif (!(ssl = SSL_new(ctx)))\nint_error(\"Error creating an SSL context\");\n\nif ( SSL_CTX_set_default_passwd_cb(ctx, \"new default password\" != 1))\nint_error(\"Doing something which is dangerous to do anyways\");\n\nif (!(ssl2 = SSL_new(ctx)))\nint_error(\"Error creating an SSL context\");\n\n }", "query_type": "code"} {"_id": "cwe_q_000032", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nint debugLevel = Integer.getInteger(\"com.domain.application.debugLevel\").intValue();", "query_type": "code"} {"_id": "cwe_q_000033", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic void doExchange() throws Exception {\n...}", "query_type": "code"} {"_id": "cwe_q_000034", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n...\nString name = new String(nameBytes, highByte);\n...", "query_type": "code"} {"_id": "cwe_q_000035", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nserver.sin_family = AF_INET; hp = gethostbyname(argv[1]);\nif (hp==NULL) error(\"Unknown host\");\nmemcpy( (char *)&server.sin_addr,(char *)hp->h_addr,hp->h_length);\nif (argc < 3) port = 80;\nelse port = (unsigned short)atoi(argv[3]);\nserver.sin_port = htons(port);\nif (connect(sock, (struct sockaddr *)&server, sizeof server) < 0) error(\"Connecting\");\n...\nwhile ((n=read(sock,buffer,BUFSIZE-1))!=-1) {\n\nwrite(dfd,password_buffer,n);\n...", "query_type": "code"} {"_id": "cwe_q_000036", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic boolean isReorderNeeded(String bookISBN, int rateSold) {\n\nboolean isReorder = false;\n\nint minimumCount = 10;\nint days = 0;\n\n // get inventory count for book\n\nint inventoryCount = inventory.getIventoryCount(bookISBN);\n\n // find number of days until inventory count reaches minimum\n\nwhile (inventoryCount > minimumCount) {\n\ninventoryCount = inventoryCount - rateSold;\ndays++;\n\n }\n\n // if number of days within reorder timeframe\n\n // set reorder return boolean to true\n\nif (days > 0 && days < 5) {\nisReorder = true;}\n\nreturn isReorder;\n }", "query_type": "code"} {"_id": "cwe_q_000037", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nif (user == null) {\n\n // TODO: Handle null user condition.\n\n }", "query_type": "code"} {"_id": "cwe_q_000041", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#include \n#include \n#include \n#include \n\nvoid *global1, *global2;\nchar *what;\nvoid sh (int dummy) {\n\nsyslog(LOG_NOTICE,\"%s\\n\",what);\nfree(global2);\nfree(global1);\n\n /* Sleep statements added to expand timing window for race condition */\n\nsleep(10);\nexit(0);\n }\n\nint main (int argc,char* argv[]) {\n\nwhat=argv[1];\nglobal1=strdup(argv[2]);\nglobal2=malloc(340);\nsignal(SIGHUP,sh);\nsignal(SIGTERM,sh);\n\n /* Sleep statements added to expand timing window for race condition */\n\nsleep(10);\nexit(0);\n }", "query_type": "code"} {"_id": "cwe_q_000042", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n...\nString btype = request.getParameter(\"backuptype\");\nString cmd = new String(\"cmd.exe /K \\\"\nc:\\\\util\\\\rmanDB.bat \"\n+btype+\n\"&&c:\\\\utl\\\\cleanup.bat\\\"\")\n\nSystem.Runtime.getRuntime().exec(cmd);\n...", "query_type": "code"} {"_id": "cwe_q_000045", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000046", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\nfunction generateSessionID($userID){\nsrand($userID);\nreturn rand();}", "query_type": "code"} {"_id": "cwe_q_000047", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n//hardcode input length for simplicity\n\nchar* input = (char*) malloc(40*sizeof(char));\nchar *tok;\nchar* sep = \" \\t\";\n\nget_user_input( input );\n\n /* The following loop will parse and process each token in the input string */\n\ntok = strtok( input, sep);\nwhile( NULL != tok ){\n\nif( isMalformed( tok ) ){\n\n /* ignore and discard bad data */\n\nfree( tok );\n }\nelse{\nadd_to_command_queue( tok );}\ntok = strtok( NULL, sep));\n }", "query_type": "code"} {"_id": "cwe_q_000048", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000049", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000050", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar* ptr = (char*)malloc (SIZE);\n\n\t\t\t\t ...\n\n\t\t\t\t if (abrt) {\n\n\t\t\t\t\t free(ptr);\n\n\t\t\t\t }\n\n\t\t\t\t ...\n\n\t\t\t\t free(ptr);", "query_type": "code"} {"_id": "cwe_q_000051", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nPublic void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\ntry {\n...} catch (ApplicationSpecificException ase) {\nlogger.error(\"Caught: \" + ase.toString());\nSystem.exit(1);}}", "query_type": "code"} {"_id": "cwe_q_000052", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprivate void buildList ( int untrustedListSize ){\nif ( 0 > untrustedListSize ){\ndie(\"Negative value supplied for list size, die evil hacker!\");}\nWidget[] list = new Widget [ untrustedListSize ];\nlist[0] = new Widget();}", "query_type": "code"} {"_id": "cwe_q_000054", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$auth = $_COOKIES['authenticated'];\nif (! $auth) {\nif (AuthenticateUser($_POST['user'], $_POST['password']) == \"success\") {\n// save the cookie to send out in future responses\nsetcookie(\"authenticated\", \"1\", time()+60*60*2);}\nelse {\nShowLoginScreen();\ndie(\"\\n\");}}\nDisplayMedicalHistory($_POST['patient_ID']);", "query_type": "code"} {"_id": "cwe_q_000056", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[VHDL]\n-- The following VHDL example is written for VHDL-93 or later.\n\n\t\t type t_priv_state is (RESET, USER_ONLY, PRIVILEGED);\n\n\t\t signal priv_state : t_priv_state := RESET;\n\n\t\t signal auth_passed : boolean := false;\n\n\t\t signal privilege_revoke : boolean := false;\n\n\t\t ...\n\n\t\t process(clk, reset_n)\n\n\t\t begin\n\n\t\t\tif reset_n = '0' then\n\n\t\t\t priv_state <= RESET;\n\n\t\t\telsif rising_edge(clk) then\n\n\t\t\t case priv_state is\n\n\t\t\t\twhen RESET =>\n\n\t\t\t\t priv_state <= USER_ONLY;\n\n\t\t\t\twhen USER_ONLY =>\n\n\t\t\t\t if auth_passed then\n\n\t\t\t\t\tpriv_state <= PRIVILEGED;\n\n\t\t\t\t end if;\n\n\t\t\t\twhen PRIVILEGED =>\n\n\t\t\t\t if privilege_revoke then\n\n\t\t\t\t\tpriv_state <= USER_ONLY;\n\n\t\t\t\t end if;\n\n\t\t\t\twhen others =>\n\n\t\t\t\t priv_state <= USER_ONLY; -- intended recovery for unexpected encodings\n\n\t\t\t\tend case;\n\n\t\t\t end if;\n\n\t\t\tend process;\n\n\t\t\tprotected_cfg_write_en <= (priv_state = PRIVILEGED);\n\n[Verilog]\nlocalparam RESET = 2'b00;\n\n\t\t\tlocalparam USER_ONLY = 2'b01;\n\n\t\t\tlocalparam PRIVILEGED = 2'b10;\n\n\t\t\treg [1:0] priv_state = RESET;\n\n\t\t\twire auth_passed; // Implicitly 1-bit (boolean equivalent)\n\n\t\t\twire privilege_revoke; // Implicitly 1-bit (boolean equivalent)\n\n\t\t\twire c", "query_type": "code"} {"_id": "cwe_q_000057", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000058", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprivate User user;\npublic void someMethod() {\n\n // Do something interesting.\n\n...\n\n // Throws NPE if user hasn't been properly initialized.\n\nString username = user.getName();\n }", "query_type": "code"} {"_id": "cwe_q_000059", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n// Method called from servlet to obtain product information\n\npublic String displayProductSummary(int index) {\n\nString productSummary = new String(\"\");\n\ntry {\nString productSummary = getProductSummary(index);\n\n} catch (Exception ex) {...}\n\nreturn productSummary;\n }\n\npublic String getProductSummary(int index) {\nreturn products[index];}", "query_type": "code"} {"_id": "cwe_q_000060", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nCookie[] cookies = request.getCookies();\nfor (int i =0; i< cookies.length; i++) {\nCookie c = cookies[i];\nif (c.getName().equals(\"role\")) {\nuserRole = c.getValue();}}", "query_type": "code"} {"_id": "cwe_q_000061", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nFILE *stream;\nif( (stream = tmpfile()) == NULL ) {\n\nperror(\"Could not open new temporary file\\n\");\nreturn (-1);\n }\n\n // write data to tmp file\n\n...\n// remove tmp file\nrmtmp();\n\n[Java]\ntry {\nFile temp = File.createTempFile(\"pattern\", \".suffix\");\ntemp.deleteOnExit();\nBufferedWriter out = new BufferedWriter(new FileWriter(temp));\nout.write(\"aString\");\nout.close();}\ncatch (IOException e) {\n}", "query_type": "code"} {"_id": "cwe_q_000062", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint main(int argc, char** argv) {\nchar cmd[CMD_MAX] = \"/usr/bin/cat \";\nstrcat(cmd, argv[1]);\nsystem(cmd);}", "query_type": "code"} {"_id": "cwe_q_000064", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nif LoginUser(){\n\n// Login successful\n\n\t\t RunProgram();\n } else {\n\n// Login unsuccessful\n\n\t\t LoginRetry();\n }", "query_type": "code"} {"_id": "cwe_q_000065", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n@Stateless\npublic class StockSymbolBean implements StockSymbolRemote {\n\nServerSocket serverSocket = null;\nSocket clientSocket = null;\n\npublic StockSymbolBean() {\n\ntry {\nserverSocket = new ServerSocket(Constants.SOCKET_PORT);} catch (IOException ex) {...}\n\ntry {\nclientSocket = serverSocket.accept();} catch (IOException e) {...}\n }\n\npublic String getStockSymbol(String name) {...}\n\npublic BigDecimal getStockValue(String symbol) {...}\n\nprivate void processClientInputFromSocket() {...}\n }\n\n[Java]\n@Stateless\npublic class StockSymbolBean extends Thread implements StockSymbolRemote {\n\nServerSocket serverSocket = null;\nSocket clientSocket = null;\nboolean listening = false;\n\npublic StockSymbolBean() {\n\ntry {\nserverSocket = new ServerSocket(Constants.SOCKET_PORT);} catch (IOException ex) {...}\n\nlistening = true;\nwhile(listening) {\nstart();}\n }\n\npublic String getStockSymbol(String name) {...}\n\npublic BigDecimal getStockValue(String symbol) {...}\n\npublic void run() {\ntry {\nclientSocket = serverSocket.accept();} catch (IOException e) {...}\n...}\n\n }", "query_type": "code"} {"_id": "cwe_q_000066", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nmy $test_string = \"Bad characters: \\$\\@\\#\";\n\n my $bdrslt = $test_string;\n\n $bdrslt =~ /^(\\w+\\s?)*$/i;", "query_type": "code"} {"_id": "cwe_q_000068", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSP]\n<% for (Iterator i = guestbook.iterator(); i.hasNext(); ) {\nEntry e = (Entry) i.next(); %>\n

Entry #<%= e.getId() %>

\n

<%= e.getText() %>

\n<%\n} %>", "query_type": "code"} {"_id": "cwe_q_000069", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\n\n // Something that may throw an exception.\n\n...\n } catch (Throwable t) {\nlogger.error(\"Caught: \" + t.toString());\nreturn;}", "query_type": "code"} {"_id": "cwe_q_000070", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nint myfunction() throw(std::exception) {\nif (0) throw out_of_range();\nthrow length_error();}", "query_type": "code"} {"_id": "cwe_q_000071", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nThread thr = new Thread() {\npublic void run() {\n...}};\n\nthr.run();", "query_type": "code"} {"_id": "cwe_q_000072", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic String getValue(int index) {\nreturn array[index];}", "query_type": "code"} {"_id": "cwe_q_000073", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nr = getName();\nr = getNewBuffer(buf);", "query_type": "code"} {"_id": "cwe_q_000074", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[XML]\n\n\n
\n\n\n\n\n\n\n\n\n\nmask\n[a-zA-Z]{2}\n\n\n\nmask\n\\d{5}
", "query_type": "code"} {"_id": "cwe_q_000075", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSON]\n{\n\n\t\t\t\t\"model\": \"my-coding-model\",\n\n\t\t\t\t\"context_window\": 8192,\n\n\t\t\t\t\"max_output_tokens\": 4096,\n\n\t\t\t\t\"temperature\", 1.5,\n\n\t\t\t\t...\n\n\t\t\t }", "query_type": "code"} {"_id": "cwe_q_000076", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class WebViewGUI extends Activity {\n\nWebView mainWebView;\n\npublic void onCreate(Bundle savedInstanceState) {\nsuper.onCreate(savedInstanceState);\nmainWebView = new WebView(this);\nmainWebView.getSettings().setJavaScriptEnabled(true);\nmainWebView.addJavascriptInterface(new JavaScriptInterface(), \"userInfoObject\");\nmainWebView.loadUrl(\"file:///android_asset/www/index.html\");\nsetContentView(mainWebView);}\n\nfinal class JavaScriptInterface {\n\nJavaScriptInterface () {}\n\npublic String getUserInfo() {\nreturn currentUser.Info();}\n }\n }", "query_type": "code"} {"_id": "cwe_q_000077", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchroot(APP_HOME);\nchdir(\"/\");\nFILE* data = fopen(argv[1], \"r+\");\n...", "query_type": "code"} {"_id": "cwe_q_000078", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint writeDataFromSocketToFile(char *host, int port)\n{\n\nchar filename[FILENAME_SIZE];\nchar buffer[BUFFER_SIZE];\nint socket = openSocketConnection(host, port);\n\nif (socket < 0) {\nprintf(\"Unable to open socket connection\");\nreturn(FAIL);}\nif (getNextMessage(socket, filename, FILENAME_SIZE) > 0) {\n\nif (openFileToWrite(filename) > 0) {\n\nwhile (getNextMessage(socket, buffer, BUFFER_SIZE) > 0){\nif (!(writeToFile(buffer) > 0))\nbreak;\n }\n }\ncloseFile();\n }\ncloseSocket(socket);\n }", "query_type": "code"} {"_id": "cwe_q_000079", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$dir = $_GET['module_name'];\ninclude($dir . \"/function.php\");\n\n[PHP]\nsystem($_GET['cmd']);", "query_type": "code"} {"_id": "cwe_q_000080", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint VerifyAdmin(char *password) {\nif (strcmp(compress(password), compressed_password)) {\nprintf(\"Incorrect Password!\\n\");\nreturn(0);}\nprintf(\"Entering Diagnostic Mode...\\n\");\nreturn(1);}\n\n[Java]\nint VerifyAdmin(String password) {\nif (passwd.Equals(compress(password), compressed_password)) {\nreturn(0);}\n\n //Diagnostic Mode\n\nreturn(1);}", "query_type": "code"} {"_id": "cwe_q_000081", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid f(pthread_mutex_t *mutex) {\n\npthread_mutex_lock(mutex);\n\n /* access shared resource */\n\npthread_mutex_unlock(mutex);\n }", "query_type": "code"} {"_id": "cwe_q_000082", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C#]\nint Division(int x, int y){\nreturn (x / y);}", "query_type": "code"} {"_id": "cwe_q_000083", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSP]\n<% if (Boolean.getBoolean(\"debugEnabled\")) {\n\n%>\nUser account number: <%= acctNo %>\n<%\n} %>", "query_type": "code"} {"_id": "cwe_q_000084", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint main (int argc, char **argv) {\nchar *items[] = {\"boat\", \"car\", \"truck\", \"train\"};\nint index = GetUntrustedOffset();\nprintf(\"User selected %s\\n\", items[index-1]);}", "query_type": "code"} {"_id": "cwe_q_000085", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString script = System.getProperty(\"SCRIPTNAME\");\nif (script != null)\nSystem.exec(script);", "query_type": "code"} {"_id": "cwe_q_000086", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define BUFSIZE 256\nint main(int argc, char **argv) {\nchar *buf;\nbuf = (char *)malloc(sizeof(char)*BUFSIZE);\nstrcpy(buf, argv[1]);}", "query_type": "code"} {"_id": "cwe_q_000087", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint GetUntrustedInt () {\nreturn(0x0000FFFF);}\n\nvoid main (int argc, char **argv) {\n\nchar path[256];\nchar *input;\nint i;\nshort s;\nunsigned int sz;\n\ni = GetUntrustedInt();\ns = i;\n/* s is -1 so it passes the safety check - this weakness */\nif (s > 256) {\nDiePainfully(\"go away!\\n\");}\n\n/* s is sign-extended and saved in sz */\nsz = s;\n\n/* output: i=65535, s=-1, sz=4294967295 - your mileage may vary */\nprintf(\"i=%d, s=%d, sz=%u\\n\", i, s, sz);\n\ninput = GetUserInput(\"Enter pathname:\");\n\n/* strncpy interprets s as unsigned int, so it's treated as MAX_INT\n(this weakness), enabling buffer overflow (this weakness) */\nstrncpy(path, input, s);\npath[255] = '\\0'; /* don't want this weakness */\nprintf(\"Path is: %s\\n\", path);\n }", "query_type": "code"} {"_id": "cwe_q_000088", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\nmodule dma # (...)(...);\n\n\t\t\t\t\t...\n\n\t\t\t\t\t\tinput [7:0] [16-1:0] pmpcfg_i;\n\n\t\t\t\t\t\tinput logic [16-1:0][53:0] pmpaddr_i;\n\n\t\t\t\t\t\t...\n\n\t\t\t\t\t\t//// Save the input command\n\n \t\t\t\t\t\talways @ (posedge clk_i or negedge rst_ni)\n\n\t\t\t\t\t\t\tbegin: save_inputs\n\n\t\t\t\t\t\t\tif (!rst_ni)\n\n\t\t\t\t\t\t\t\tbegin\n\n\t\t\t\t\t\t\t\t...\n\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\telse\n\n\t\t\t\t\t\t\t\tbegin\n\n\t\t\t\t\t\t\t\t\tif (dma_ctrl_reg == CTRL_IDLE || dma_ctrl_reg == CTRL_DONE)\n\n\t\t\t\t\t\t\t\t\tbegin\n\n\t\t\t\t\t\t\t\t\t...\n\n\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tend // save_inputs\n\n\t\t\t\t\t\t\t...\n\n\t\t\t\t\t\t\t// Load/store PMP check\n\n\t\t\t\t\t\t\tpmp #(\n\n\t\t\t\t\t\t\t\t.XLEN ( 64 ),\n\n\t\t\t\t\t\t\t\t.PMP_LEN ( 54 ),\n\n\t\t\t\t\t\t\t\t.NR_ENTRIES ( 16 )\n\n\t\t\t\t\t\t\t) i_pmp_data (\n\n\t\t\t\t\t\t\t\t.addr_i ( pmp_addr_reg ),\n\n\t\t\t\t\t\t\t\t.priv_lvl_i ( riscv::PRIV_LVL_U ),\n\n\t\t\t\t\t\t\t\t.access_type_i ( pmp_access_type_reg ),\n\n\t\t\t\t\t\t\t\t// Configuration\n\n\t\t\t\t\t\t\t\t.conf_addr_i ( pmpaddr_i ),\n\n\t\t\t\t\t\t\t\t.conf_i ( pmpcfg_i ),\n\n\t\t\t\t\t\t\t\t.allow_o ( pmp_data_allow )\n\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\tendmodule", "query_type": "code"} {"_id": "cwe_q_000089", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic void updateUserAccountOrder(String productNumber, String accountNumber) {\n\nboolean isValidProduct = false;\nboolean isValidAccount = false;\n\nif (validProductNumber(productNumber)) {\nisValidProduct = true;\nupdateInventory(productNumber);}\nelse {\nreturn;}\n\nif (validAccountNumber(accountNumber)) {\nisValidProduct = true;\nupdateAccount(accountNumber, productNumber);}\n\nif (isValidProduct && isValidAccount) {\nupdateAccountOrder(accountNumber, productNumber);}\n }", "query_type": "code"} {"_id": "cwe_q_000090", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar * copy_input(char *user_supplied_string){\n\nint i, dst_index;\nchar *dst_buf = (char*)malloc(4*sizeof(char) * MAX_SIZE);\nif ( MAX_SIZE <= strlen(user_supplied_string) ){\ndie(\"user string too long, die evil hacker!\");}\ndst_index = 0;\nfor ( i = 0; i < strlen(user_supplied_string); i++ ){\n\nif( '&' == user_supplied_string[i] ){\ndst_buf[dst_index++] = '&';\ndst_buf[dst_index++] = 'a';\ndst_buf[dst_index++] = 'm';\ndst_buf[dst_index++] = 'p';\ndst_buf[dst_index++] = ';';}\nelse if ('<' == user_supplied_string[i] ){\n\n /* encode to < */\n\n }\nelse dst_buf[dst_index++] = user_supplied_string[i];\n }\nreturn dst_buf;\n }", "query_type": "code"} {"_id": "cwe_q_000091", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprivate void processFile(string fName)\n{\nBufferReader fil = new BufferReader(new FileReader(fName));\nString line;\nwhile ((line = fil.ReadLine()) != null)\n{\nprocessLine(line);}}", "query_type": "code"} {"_id": "cwe_q_000093", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000094", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\n...\n\n\t\t\t\t\t\t// Implement SHA256 I/O memory map interface\n\n\t\t\t\t\t\t// Write side\n\n\t\t\t\t\t\talways @(posedge clk_i)\n\n\t\t\t\t\t\t\tbegin\n\n\t\t\t\t\t\t\t\tif(~(rst_ni && ~rst_3))\n\n\t\t\t\t\t\t\t\t\tbegin\n\n\t\t\t\t\t\t\t\t\t\tstartHash <= 0;\n\n\t\t\t\t\t\t\t\t\t\tnewMessage <= 0;\n\n\t\t\t\t\t\t\t\t\t\tdata[0] <= 0;\n\n\t\t\t\t\t\t\t\t\t\tdata[1] <= 0;\n\n\t\t\t\t\t\t\t\t\t\tdata[2] <= 0;\n\n\t\t\t\t\t\t\t\t\t\t...\n\n\t\t\t\t\t\t\t\t\t\tdata[14] <= 0;\n\n\t\t\t\t\t\t\t\t\t\tdata[15] <= 0;\n\n\t\t\t\t\t...", "query_type": "code"} {"_id": "cwe_q_000095", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchroot(\"/var/ftproot\");\n...\nfgets(filename, sizeof(filename), network);\nlocalfile = fopen(filename, \"r\");\nwhile ((len = fread(buf, 1, sizeof(buf), localfile)) != EOF) {\nfwrite(buf, 1, sizeof(buf), network);}\nfclose(localfile);", "query_type": "code"} {"_id": "cwe_q_000096", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n...\n\nIntentFilter filter = new IntentFilter(\"com.example.URLHandler.openURL\");\nMyReceiver receiver = new MyReceiver();\nregisterReceiver(receiver, filter);\n\n ...\n\npublic class UrlHandlerReceiver extends BroadcastReceiver {\n\n@Override\npublic void onReceive(Context context, Intent intent) {\n\nif(\"com.example.URLHandler.openURL\".equals(intent.getAction())) {\nString URL = intent.getStringExtra(\"URLToOpen\");\nint length = URL.length();\n\n ...\n\n}\n }\n }", "query_type": "code"} {"_id": "cwe_q_000097", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic boolean isSameAccount(BankAccount accountA, BankAccount accountB) {\nreturn accountA == accountB;}", "query_type": "code"} {"_id": "cwe_q_000099", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nresponse.addCookie( new Cookie(\"userAccountID\", acctID) );", "query_type": "code"} {"_id": "cwe_q_000100", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$role = $_COOKIES['role'];\nif (!$role) {\n$role = getRole('user');\nif ($role) {\n// save the cookie to send out in future responses\nsetcookie(\"role\", $role, time()+60*60*2);}\nelse{\nShowLoginScreen();\ndie(\"\\n\");}}\nif ($role == 'Reader') {\nDisplayMedicalHistory($_POST['patient_ID']);}\nelse{\ndie(\"You are not Authorized to view this record\\n\");}", "query_type": "code"} {"_id": "cwe_q_000101", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$debugEnabled = false;\nif ($_POST[\"debug\"] == \"true\"){\n$debugEnabled = true;}\n\n /.../\n\nfunction login($username, $password){\nif($debugEnabled){\necho 'Debug Activated';\nphpinfo();\n$isAdmin = True;\nreturn True;}}", "query_type": "code"} {"_id": "cwe_q_000102", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class Kibitzer {\n\npublic Object clone() throws CloneNotSupportedException {\n\nObject returnMe = new Kibitzer();\n...\n }\n }\n\npublic class FancyKibitzer extends Kibitzer{\n\npublic Object clone() throws CloneNotSupportedException {\n\nObject returnMe = super.clone();\n...\n }\n }", "query_type": "code"} {"_id": "cwe_q_000103", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\ndoExchange();}\ncatch (Exception e) {\nlogger.error(\"doExchange failed\", e);}", "query_type": "code"} {"_id": "cwe_q_000105", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$requestingIP = $_SERVER['REMOTE_ADDR'];\nif(!in_array($requestingIP,$ipAllowList)){\necho \"You are not authorized to view this page\";\nhttp_redirect($errorPageURL);}\n$status = getServerStatus();\necho $status;\n\n ...", "query_type": "code"} {"_id": "cwe_q_000106", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprotected void doPost (HttpServletRequest req, HttpServletResponse res) throws IOException {\nString ip = req.getRemoteAddr();\nInetAddress addr = InetAddress.getByName(ip);\n...\nout.println(\"hello \" + addr.getHostName());}", "query_type": "code"} {"_id": "cwe_q_000107", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nunsigned char *check_passwd(char *plaintext) {\nctext = simple_digest(\"sha1\",plaintext,strlen(plaintext), ... );\n\n //Login if hash matches stored hash\n\nif (equal(ctext, secret_password())) {\nlogin_user();}}\n\n[Java]\nString plainText = new String(plainTextIn);\nMessageDigest encer = MessageDigest.getInstance(\"SHA\");\nencer.update(plainTextIn);\nbyte[] digest = password.digest();\n\n //Login if hash matches stored hash\n\nif (equal(digest,secret_password())) {\nlogin_user();}", "query_type": "code"} {"_id": "cwe_q_000108", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000109", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint isValid(int value) {\nif (value=100) {\nprintf(\"Value is valid\\n\");\nreturn(1);}\nprintf(\"Value is not valid\\n\");\nreturn(0);}\n\n[C#]\nbool isValid(int value) {\nif (value=100) {\nConsole.WriteLine(\"Value is valid.\");\nreturn true;}\nConsole.WriteLine(\"Value is not valid.\");\nreturn false;}", "query_type": "code"} {"_id": "cwe_q_000110", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid foo(){\n\nrecord_t bar[MAX_SIZE];\n\n /* do something interesting with bar */\n\n...\nfree(bar);\n }\n\n[C]\nrecord_t bar[MAX_SIZE]; //Global var\nvoid foo(){\n\n /* do something interesting with bar */\n\n...\nfree(bar);\n }", "query_type": "code"} {"_id": "cwe_q_000111", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Verilog]\n// IP definition\n\n\t\t\t module tz_peripheral(clk, reset, data_in, data_in_security_level, ...);\n\n\t\t\t\tinput clk, reset;\n\n\t\t\t\tinput [31:0] data_in;\n\n\t\t\t\tinput data_in_security_level;\n\n\t\t\t\t...\n\n\t\t\t endmodule\n\n\t\t\t // Instantiation of IP in a parent system\n\n\t\t\t module soc(...)\n\n\t\t\t\t...\n\n\t\t\t\ttz_peripheral u_tz_peripheral(\n\n\t\t\t\t .clk(clk),\n\n\t\t\t\t .rst(rst),\n\n\t\t\t\t .data_in(rdata),\n\n\t\t\t\t //Copy-and-paste error or typo grounds data_in_security_level (in this example 0=secure, 1=non-secure) effectively promoting all data to \"secure\")\n\n\t\t\t\t .data_in_security_level(1'b0),\n\n\t\t\t\t);\n\n\t\t\t\t...\n\n\t\t\t endmodule", "query_type": "code"} {"_id": "cwe_q_000112", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint getValueFromArray(int *array, int len, int index) {\n\nint value;\n\n // check that the array index is less than the maximum\n\n // length of the array\n\nif (index < len) {\n\n // get the value at the specified index of the array\n\nvalue = array[index];\n }\n\n // if array index is invalid then output error message\n\n // and return value indicating error\n\nelse {\nprintf(\"Value is: %d\\n\", array[index]);\nvalue = -1;}\n\nreturn value;\n }", "query_type": "code"} {"_id": "cwe_q_000113", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint i;\nunsigned int numWidgets;\nWidget **WidgetList;\n\nnumWidgets = GetUntrustedSizeValue();\nif ((numWidgets == 0) || (numWidgets > MAX_NUM_WIDGETS)) {\nExitError(\"Incorrect number of widgets requested!\");}\nWidgetList = (Widget **)malloc(numWidgets * sizeof(Widget *));\nprintf(\"WidgetList ptr=%p\\n\", WidgetList);\nfor(i=0; i(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": "cwe_q_000122", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nJava Web App ResourceBundle properties file\n\n...\nwebapp.ldap.username=secretUsername\nwebapp.ldap.password=secretPassword\n...\n\n[ASP.NET]\n...\n\n\n...", "query_type": "code"} {"_id": "cwe_q_000123", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid parse_data(char *untrusted_input){\n\nint m, n, error;\nerror = sscanf(untrusted_input, \"%d:%d\", &m, &n);\nif ( EOF == error ){\ndie(\"Did not specify integer value. Die evil hacker!\\n\");}\n\n /* proceed assuming n and m are initialized correctly */\n\n }", "query_type": "code"} {"_id": "cwe_q_000124", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Shell]\naz storage account update --name --resource-group --allow-blob-public-access true", "query_type": "code"} {"_id": "cwe_q_000125", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString GenerateReceiptURL(String baseUrl) {\nRandom ranGen = new Random();\nranGen.setSeed((new Date()).getTime());\nreturn(baseUrl + ranGen.nextInt(400000000) + \".html\");}", "query_type": "code"} {"_id": "cwe_q_000127", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define FAIL 0\n#define SUCCESS 1\n#define ERROR -1\n#define MAX_MESSAGE_SIZE 32\n\nint processMessage(char **message)\n{\n\nint result = SUCCESS;\n\nint length = getMessageLength(message[0]);\nchar *messageBody;\n\nif ((length > 0) && (length < MAX_MESSAGE_SIZE)) {\n\nmessageBody = (char*)malloc(length*sizeof(char));\nmessageBody = &message[1][0];\n\nint success = processMessageBody(messageBody);\n\nif (success == ERROR) {\nresult = ERROR;\nfree(messageBody);}\n }\nelse {\nprintf(\"Unable to process message; invalid message length\");\nresult = FAIL;}\n\nif (result == ERROR) {\nlogError(\"Error processing message\", messageBody);}\n\nreturn result;\n }", "query_type": "code"} {"_id": "cwe_q_000128", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Python]\nimport subprocess\n\n\t\t import re\n\n\t\t def validate_ip_regex(ip: str):\n\n\t\t ip_validator = re.compile(r\"((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}\")\n\n\t\t if ip_validator.match(ip):\n\n\t\t return ip\n\n\t\t else:\n\n\t\t raise ValueError(\"IP address does not match valid pattern.\")\n\n\t\t def run_ping_regex(ip: str):\n\n\t\t validated = validate_ip_regex(ip)\n\n\t\t # The ping command treats zero-prepended IP addresses as octal\n\n\t\t result = subprocess.call([\"ping\", validated])\n\n\t\t print(result)", "query_type": "code"} {"_id": "cwe_q_000129", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[XML]\n\n...\n\n\nANYONE\n\nEmployee\ngetSalary\n...", "query_type": "code"} {"_id": "cwe_q_000130", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nunsigned int readdata () {\nint amount = 0;\n...\nif (result == ERROR)\namount = -1;\n...\nreturn amount;}", "query_type": "code"} {"_id": "cwe_q_000133", "text": "Which software weakness classification applies to this vulnerable code snippet?\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] Secure_reg,\n\n\t\t\toutput reg [31:0] Insecure_reg\n\n\t\t\t);\n\n\t\t\tregister_example #(\n\n\t\t\t .REGISTER_WIDTH (", "query_type": "code"} {"_id": "cwe_q_000134", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Python]\nsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\nsock.bind( (UDP_IP,UDP_PORT) )\nwhile true:\n\ndata = sock.recvfrom(1024)\nif not data:\nbreak\n\n(requestIP, nameToResolve) = parseUDPpacket(data)\nrecord = resolveName(nameToResolve)\nsendResponse(requestIP,record)", "query_type": "code"} {"_id": "cwe_q_000135", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nEVP_CIPHER_CTX ctx;\nchar key[EVP_MAX_KEY_LENGTH];\nchar iv[EVP_MAX_IV_LENGTH];\nRAND_bytes(key, b);\nmemset(iv,0,EVP_MAX_IV_LENGTH);\nEVP_EncryptInit(&ctx,EVP_bf_cbc(), key,iv);\n\n[Java]\npublic class SymmetricCipherTest {\n\npublic static void main() {\n\nbyte[] text =\"Secret\".getBytes();\nbyte[] iv ={\n0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};\nKeyGenerator kg = KeyGenerator.getInstance(\"DES\");\nkg.init(56);\nSecretKey key = kg.generateKey();\nCipher cipher = Cipher.getInstance(\"DES/CBC/PKCS5Padding\");\nIvParameterSpec ips = new IvParameterSpec(iv);\ncipher.init(Cipher.ENCRYPT_MODE, key, ips);\nreturn cipher.doFinal(inpBytes);\n }\n }", "query_type": "code"} {"_id": "cwe_q_000138", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint *p = x;\nchar * second_char = (char *)(p + 1);", "query_type": "code"} {"_id": "cwe_q_000142", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\n$ConfigDir = \"/home/myprog/config\";\n$uname = GetUserInput(\"username\");\n\n # avoid this weakness, this weakness, others.\n\nExitError(\"Bad hacker!\") if ($uname !~ /^\\w+$/);\n$file = \"$ConfigDir/$uname.txt\";\nif (! (-e $file)) {\nExitError(\"Error: $file does not exist\");}\n...", "query_type": "code"} {"_id": "cwe_q_000143", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n...\nDriverManager.getConnection(url, \"scott\", \"tiger\");\n...", "query_type": "code"} {"_id": "cwe_q_000144", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nmy $UserPrivilegeArray = [\"user\", \"user\", \"admin\", \"user\"];\n\nmy $userID = get_current_user_ID();\n\nif ($UserPrivilegeArray eq \"user\") {\nprint \"Regular user!\\n\";}\nelse {\nprint \"Admin!\\n\";}\n\nprint \"\\$UserPrivilegeArray = $UserPrivilegeArray\\n\";", "query_type": "code"} {"_id": "cwe_q_000145", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\nfunction persistLogin($username, $password){\n$data = array(\"username\" => $username, \"password\"=> $password);\nsetcookie (\"userdata\", $data);}", "query_type": "code"} {"_id": "cwe_q_000146", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Python]\ndef storePassword(userName,Password):\nhasher = hashlib.new('md5')\nhasher.update(Password)\nhashedPassword = hasher.digest()\n\n # UpdateUserLogin returns True on success, False otherwise\n\nreturn updateUserLogin(userName,hashedPassword)", "query_type": "code"} {"_id": "cwe_q_000148", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar buf[24];\nprintf(\"Please enter your name and press \\n\");\ngets(buf);\n...}", "query_type": "code"} {"_id": "cwe_q_000149", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nstruct stat *sb;\n...\nlstat(\"...\",sb); // it has not been updated since the last time it was read\nprintf(\"stated file\\n\");\nif (sb->st_mtimespec==...){\nprint(\"Now updating things\\n\");\nupdateThings();}", "query_type": "code"} {"_id": "cwe_q_000150", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nlogger.info(\"User's street address: \" + request.getParameter(\"streetAddress\"));", "query_type": "code"} {"_id": "cwe_q_000151", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprivate void auth(LoginContext lc, HttpSession session) throws LoginException {\n...\nlc.login();\n...}", "query_type": "code"} {"_id": "cwe_q_000152", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000154", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define SUCCESS (1)\n#define FAILURE (0)\n\nint contains_char(char c){\n\nchar *str;\nstr = (char*)malloc(20*sizeof(char));\nstrcpy(str, \"Search Me!\");\nwhile( *str != NULL){\n\nif( *str == c ){\n\n /* matched char, free string and return success */\n\nfree(str);\nreturn SUCCESS;\n }\n\n /* didn't match yet, increment pointer and try next char */\n\nstr = str + 1;\n }\n\n /* we did not match the char in the string, free mem and return failure */\n\nfree(str);\nreturn FAILURE;\n }", "query_type": "code"} {"_id": "cwe_q_000155", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic void actionPerformed(ActionEvent e) {\nif (e.getSource() == button) {\nSystem.out.println(\"print out secret information\");}}", "query_type": "code"} {"_id": "cwe_q_000157", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nsub ReportAuth {\nmy ($username, $result, $fatal) = @_;\nPrintLog(\"auth: username=%s, result=%d\", $username, $result);\nif (($result ne \"success\") && $fatal) {\ndie \"Failed!\\n\";}}\n\nsub PrivilegedFunc\n{\nmy $result = CheckAuth($username);\nReportAuth($username, $result, 0);\nDoReallyImportantStuff();}", "query_type": "code"} {"_id": "cwe_q_000158", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nint outputStringToFile(char *output, char *filename) {\n\nopenFileToWrite(filename);\nwriteToFile(output);\ncloseFile(filename);\n }", "query_type": "code"} {"_id": "cwe_q_000159", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\n\n // something that might throw IOException\n\n...\n } catch (IOException ioe) {\nresponse.sendError(SC_NOT_FOUND);}", "query_type": "code"} {"_id": "cwe_q_000161", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSP]\n", "query_type": "code"} {"_id": "cwe_q_000162", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nString trustedReferer = \"\nwhile(true){\nn = read(newsock, buffer, BUFSIZE);\nrequestPacket = processPacket(buffer, n);\nif (requestPacket.referer == trustedReferer){\nopenNewSecureSession(requestPacket);}}\n\n[Java]\nboolean processConnectionRequest(HttpServletRequest request){\nString referer = request.getHeader(\"referer\")\nString trustedReferer = \"\nif(referer.equals(trustedReferer)){\nopenPrivilegedConnection(request);\nreturn true;}\nelse{\nsendPrivilegeError(request);\nreturn false;}}", "query_type": "code"} {"_id": "cwe_q_000163", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nmy $username=param('username');\n\nmy $password=param('password');\n\nif (IsValidUsername($username) == 1)\n\n{\n\nif (IsValidPassword($username, $password) == 1)\n\n{\n\nprint \"Login Successful\";\n }\n\nelse\n\n{\n\nprint \"Login Failed - incorrect password\";\n }\n }\n\nelse\n\n{\n\nprint \"Login Failed - unknown username\";\n }", "query_type": "code"} {"_id": "cwe_q_000164", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[XML]\n\n\n\n\n ...\n\n\n\n\n\n ...\n\n\n \n\n[Java]\n...\n\nIntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN);\nBroadcastReceiver sReceiver = new ShutDownReceiver();\nregisterReceiver(sReceiver, filter);\n\n ...\n\npublic class ShutdownReceiver extends BroadcastReceiver {\n@Override\npublic void onReceive(final Context context, final Intent intent) {\nmainActivity.saveLocalData();\nmainActivity.stopActivity();}}", "query_type": "code"} {"_id": "cwe_q_000166", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[XML]\n\n\n\n\n[XML]\n\n\n\n\n\n\n\n\n\n\n\n\n", "query_type": "code"} {"_id": "cwe_q_000167", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nif (cert = SSL_get_peer_certificate(ssl)) {\n\n // got certificate, host can be trusted\n\n //foo=SSL_get_verify_result(ssl);\n\n //if (X509_V_OK==foo) ...\n\n }", "query_type": "code"} {"_id": "cwe_q_000168", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nPublic void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\ntry {\n...} catch (ApplicationSpecificException ase) {\nlogger.error(\"Caught: \" + ase.toString());}}", "query_type": "code"} {"_id": "cwe_q_000169", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nsd = socket(AF_INET, SOCK_DGRAM, 0);\nserv.sin_family = AF_INET;\nserv.sin_addr.s_addr = htonl(INADDR_ANY);\nservr.sin_port = htons(1008);\nbind(sd, (struct sockaddr *) & serv, sizeof(serv));\n\nwhile (1) {\nmemset(msg, 0x0, MAX_MSG);\nclilen = sizeof(cli);\nif (inet_ntoa(cli.sin_addr)==getTrustedAddress()) {\nn = recvfrom(sd, msg, MAX_MSG, 0, (struct sockaddr *) & cli, &clilen);}}\n\n[Java]\nwhile(true) {\n\nDatagramPacket rp=new DatagramPacket(rData,rData.length);\noutSock.receive(rp);\nString in = new String(p.getData(),0, rp.getLength());\nInetAddress clientIPAddress = rp.getAddress();\nint port = rp.getPort();\n\nif (isTrustedAddress(clientIPAddress) & secretKey.equals(in)) {\nout = secret.getBytes();\nDatagramPacket sp =new DatagramPacket(out,out.length, IPAddress, port); outSock.send(sp);}\n }", "query_type": "code"} {"_id": "cwe_q_000170", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar *foo;\nint counter;\nfoo=calloc(sizeof(char)*10);\n\nfor (counter=0;counter!=10;counter++) {\nfoo[counter]='a';\n\nprintf(\"%s\\n\",foo);\n}", "query_type": "code"} {"_id": "cwe_q_000171", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar* getName() {\nchar name[STR_MAX];\nfillInName(name);\nreturn name;}", "query_type": "code"} {"_id": "cwe_q_000172", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nIntentFilter filter = new IntentFilter(\"com.example.RemoveUser\");\nMyReceiver receiver = new MyReceiver();\nregisterReceiver(receiver, filter);\n\npublic class DeleteReceiver extends BroadcastReceiver {\n@Override\npublic void onReceive(Context context, Intent intent) {\nint userID = intent.getIntExtra(\"userID\");\ndestroyUserData(userID);}}", "query_type": "code"} {"_id": "cwe_q_000173", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class FileUploadServlet extends HttpServlet {\n\n...\n\nprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\nresponse.setContentType(\"text/html\");\nPrintWriter out = response.getWriter();\nString contentType = request.getContentType();\n\n// the starting position of the boundary header\nint ind = contentType.indexOf(\"boundary=\");\nString boundary = contentType.substring(ind+9);\n\nString pLine = new String();\nString uploadLocation = new String(UPLOAD_DIRECTORY_STRING); //Constant value\n\n// verify that content type is multipart form data\nif (contentType != null && contentType.indexOf(\"multipart/form-data\") != -1) {\n\n// extract the filename from the Http header\nBufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));\n...\npLine = br.readLine();\nString filename = pLine.substring(pLine.lastIndexOf(\"\\\\\"), pLine.lastIndexOf(\"\\\"\"));\n...\n\n// output the file to the local upload directory\ntry {\n\nBufferedWriter bw = new BufferedWriter(new FileWriter(uploadLocation+filename, true));\nfor (String line; (line=br.readLine())!=null; ) {\nif (line.indexOf(boundary) == -1) {\nbw.write(line);\nbw.newLine()", "query_type": "code"} {"_id": "cwe_q_000174", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[HTML]\n
Welcome!\n
Please Login:\n
\nUsername: \n
\nPassword: \n\n
\n
\n
", "query_type": "code"} {"_id": "cwe_q_000175", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\nfunction runEmployeeQuery($dbName, $name){\nmysql_select_db($dbName,$globalDbHandle) or die(\"Could not open Database\".$dbName);\n\n //Use a prepared statement to avoid this weakness\n\n$preparedStatement = $globalDbHandle->prepare('SELECT * FROM employees WHERE name = :name');\n$preparedStatement->execute(array(':name' => $name));\nreturn $preparedStatement->fetchAll();}\n\n /.../\n\n$employeeRecord = runEmployeeQuery('EmployeeDB',$_GET['EmployeeName']);", "query_type": "code"} {"_id": "cwe_q_000176", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nunsigned char *simple_digest(char *alg,char *buf,unsigned int len, int *olen) {\nconst EVP_MD *m;\nEVP_MD_CTX ctx;\nunsigned char *ret;\nOpenSSL_add_all_digests();\nif (!(m = EVP_get_digestbyname(alg))) return NULL;\nif (!(ret = (unsigned char*)malloc(EVP_MAX_MD_SIZE))) return NULL;\nEVP_DigestInit(&ctx, m);\nEVP_DigestUpdate(&ctx,buf,len);\nEVP_DigestFinal(&ctx,ret,olen);\nreturn ret;}\nunsigned char *generate_password_and_cmd(char *password_and_cmd) {\nsimple_digest(\"sha1\",password,strlen(password_and_cmd)\n...\n);}\n\n[Java]\nString command = new String(\"some cmd to execute & the password\") MessageDigest encer = MessageDigest.getInstance(\"SHA\");\nencer.update(command.getBytes(\"UTF-8\"));\nbyte[] digest = encer.digest();", "query_type": "code"} {"_id": "cwe_q_000177", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Verilog]\nmodule foo_bar(data_out, usr_id, data_in, clk, rst_n);\n\n \t\t\toutput reg [7:0] data_out;\n\n \t\t\tinput wire [2:0] usr_id;\n\n \t\t\tinput wire [7:0] data_in;\n\n \t\t\tinput wire clk, rst_n;\n\n \t\t\twire grant_access;\n\n \t\t\talways @ (posedge clk or negedge rst_n)\n\n \t\t\tbegin\n\n\t\t\t\t if (!rst_n)\n\n\t\t\t\t\tdata_out = 0;\n\n\t\t\t\t else\n\n\t\t\t\t\tdata_out = (grant_access) ? data_in : data_out;\n\n\t\t\t\t\tassign grant_access = (usr_id == 3'h4) ? 1'b1 : 1'b0;\n\n\t\t\t end\n\n\t\t\t endmodule", "query_type": "code"} {"_id": "cwe_q_000178", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic String removeScriptTags(String input, String mask) {\nreturn input.replaceAll(\"script\", mask);}", "query_type": "code"} {"_id": "cwe_q_000179", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\nURL u = new URL(\"\nHttpURLConnection hu = (HttpURLConnection) u.openConnection();\nhu.setRequestMethod(\"PUT\");\nhu.connect();\nOutputStream os = hu.getOutputStream();\nhu.disconnect();}\ncatch (IOException e) {\n\n //...\n\n }", "query_type": "code"} {"_id": "cwe_q_000180", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class BookStore {\n\nprivate BookStoreInventory inventory;\nprivate SalesDBManager sales;\n...\n\n // constructor for BookStore\n\npublic BookStore() {\nthis.inventory = new BookStoreInventory();\nthis.sales = new SalesDBManager();\n...}\npublic void updateSalesAndInventoryForBookSold(String bookISBN) {\n\n // Get book object from inventory using ISBN\n\nBook book = inventory.getBookWithISBN(bookISBN);\n\n // update sales information for book sold\n\nsales.updateSalesInformation(book);\n\n // update inventory\n\ninventory.updateInventory(book);\n }\n\n // other BookStore methods\n\n...\n }\npublic class Book {\nprivate String title;\nprivate String author;\nprivate String isbn;\n\n // Book object constructors and get/set methods\n\n...}", "query_type": "code"} {"_id": "cwe_q_000182", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar* ptr = (char*)malloc (SIZE);\n...\nif (abrt) {\nfree(ptr);}\n...\nfree(ptr);", "query_type": "code"} {"_id": "cwe_q_000185", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n\n\n[PHP]\n", "query_type": "code"} {"_id": "cwe_q_000186", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nseteuid(0);\n\n /* do some stuff */\n\nseteuid(getuid());", "query_type": "code"} {"_id": "cwe_q_000187", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nstruct node {\nint data;\nstruct node* next;};\n\n // Returns the number of nodes in a linked list from\n\n // the given pointer to the head of the list.\n\nint size(struct node* head) {\nstruct node* current = head;\nstruct node* tail;\nwhile (current != NULL) {\ntail = current;\ncurrent = current->next;}\nreturn tail - head;}\n\n // other methods for manipulating the list\n\n...", "query_type": "code"} {"_id": "cwe_q_000188", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\n...\n\n\t\t\t\t\t\tbootrom i_bootrom_patch (\n\n\t\t\t\t\t\t\t.clk_i ,\n\n\t\t\t\t\t\t\t.req_i ( rom_req ),\n\n\t\t\t\t\t\t\t.addr_i ( rom_addr ),\n\n\t\t\t\t\t\t\t.rdata_o ( rom_rdata_patch )\n\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tbootrom_linux i_bootrom_linux (\n\n\t\t\t\t\t\t\t.clk_i ,\n\n\t\t\t\t\t\t\t.req_i ( rom_req ),\n\n\t\t\t\t\t\t\t.addr_i ( rom_addr ),\n\n\t\t\t\t\t\t\t.rdata_o ( rom_rdata_linux )\n\n\t\t\t\t\t\t);\n\n\t\t\t\t\tassign rom_rdata = (ariane_boot_sel_i) ? rom_rdata_linux : rom_rdata_linux;\n\n\t\t\t\t\t...", "query_type": "code"} {"_id": "cwe_q_000189", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nusrname = request.getParameter(\"usrname\");\nif (session.getAttribute(ATTR_USR) == null) {\nsession.setAttribute(ATTR_USR, usrname);}\n\n[C#]\nusrname = request.Item(\"usrname\");\nif (session.Item(ATTR_USR) == null) {\nsession.Add(ATTR_USR, usrname);}", "query_type": "code"} {"_id": "cwe_q_000190", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprivate long someLongValue;\npublic long getLongValue() {\nreturn someLongValue;}\n\npublic void setLongValue(long l) {\nsomeLongValue = l;}", "query_type": "code"} {"_id": "cwe_q_000191", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$username = $_GET['username'];\n\n\t\t try {\n\n\t\t if (strlen($username) > 20) {\n\n\t\t throw new Exception(\"Username too long\");\n\n\t\t }\n\n\t\t } catch (Exception $e) {\n\n\t\t error_log(\"User registration failed: \" . $username);\n\t\t }", "query_type": "code"} {"_id": "cwe_q_000192", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n...\nProperties prop = new Properties();\nprop.load(new FileInputStream(\"config.properties\"));\nString password = prop.getProperty(\"password\");\nDriverManager.getConnection(url, usr, password);\n...", "query_type": "code"} {"_id": "cwe_q_000193", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Go]\nfunc HandleRequest(client http.Client, request *http.Request) (*http.Response, error) {\n\n response, err := client.Do(request)\n\n defer response.Body.Close()\n\n if err != nil {\n\n return nil, err\n\n }\n...\n\n }", "query_type": "code"} {"_id": "cwe_q_000194", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar* processNext(char* strm) {\nchar buf[512];\nshort len = *(short*) strm;\nstrm += sizeof(len);\nif (len <= 512) {\nmemcpy(buf, strm, len);\nprocess(buf);\nreturn strm + len;}\nelse {\nreturn -1;}}", "query_type": "code"} {"_id": "cwe_q_000195", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$user = $_GET['user'];\n$pass = $_GET['pass'];\n$checkpass = $_GET['checkpass'];\nif ($pass == $checkpass) {\nSetUserPassword($user, $pass);}", "query_type": "code"} {"_id": "cwe_q_000197", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define MAXLEN 1024\n...\nchar *pathbuf[MAXLEN];\n...\nread(cfgfile,inputbuf,MAXLEN); //does not null terminate\nstrcpy(pathbuf,inputbuf); //requires null terminated input\n...", "query_type": "code"} {"_id": "cwe_q_000198", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define NAME_TYPE 1\n#define ID_TYPE 2\n\nstruct MessageBuffer\n{\nint msgType;\nunion {\nchar *name;\nint nameID;};};\n\nint main (int argc, char **argv) {\n\nstruct MessageBuffer buf;\nchar *defaultMessage = \"Hello World\";\n\nbuf.msgType = NAME_TYPE;\nbuf.name = defaultMessage;\nprintf(\"Pointer of buf.name is %p\\n\", buf.name);\n\n /* This particular value for nameID is used to make the code architecture-independent. If coming from untrusted input, it could be any value. */\n\nbuf.nameID = (int)(defaultMessage + 1);\nprintf(\"Pointer of buf.name is now %p\\n\", buf.name);\nif (buf.msgType == NAME_TYPE) {\nprintf(\"Message: %s\\n\", buf.name);}\nelse {\nprintf(\"Message: Use ID %d\\n\", buf.nameID);}\n }", "query_type": "code"} {"_id": "cwe_q_000199", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nprivate boolean initialized = true;\npublic void someMethod() {\n\nif (!initialized) {\n\n // perform initialization tasks\n\n...\n\ninitialized = true;\n }", "query_type": "code"} {"_id": "cwe_q_000200", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nnresp = packet_get_int();\nif (nresp > 0) {\nresponse = xmalloc(nresp*sizeof(char*));\nfor (i = 0; i < nresp; i++) response[i] = packet_get_string(NULL);}", "query_type": "code"} {"_id": "cwe_q_000201", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nprivate: float price;\npublic: void changePrice(float newPrice) {\nprice = newPrice;}", "query_type": "code"} {"_id": "cwe_q_000203", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic void removeDatabase(String databaseName) {\n\ntry {\n\nStatement stmt = conn.createStatement();\nstmt.execute(\"DROP DATABASE \" + databaseName);\n\n } catch (SQLException ex) {...}\n }", "query_type": "code"} {"_id": "cwe_q_000206", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\n...\nthrow IllegalArgumentException();}\nfinally {\nreturn r;}", "query_type": "code"} {"_id": "cwe_q_000209", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nIntent intent = new Intent();\nintent.setAction(\"com.example.BackupUserData\");\nintent.setData(file_uri);\nintent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);\nsendBroadcast(intent);", "query_type": "code"} {"_id": "cwe_q_000210", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000213", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n// $user and $pass automatically set from POST request\n\nif (login_user($user,$pass)) {\n$authorized = true;}\n\n ...\n\nif ($authorized) {\ngeneratePage();}", "query_type": "code"} {"_id": "cwe_q_000215", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Verilog]\nmodule ocp2ahb\n\n\t (\n\n\t ahb_hprot,\n\n\t ocp_mreqinfo\n\n\t );\n\n\t output [1:0] ahb_hprot; // output is 2 bit signal for AHB HPROT\n\n\t input [4:0] ocp_mreqinfo; // input is 5 bit signal from OCP MReqInfo\n\n\t wire [6:0] p0_mreqinfo_o_temp; // OCP signal that transmits hardware identity of bus controller\n\n\t wire y;\n\n\t reg [1:0] ahb_hprot;\n\n\t // hardware identity of bus controller is in bits 5:1 of p0_mreqinfo_o_temp signal\n\n\t assign p0_mreqinfo_o_temp[6:0] = {1'b0, ocp_mreqinfo[4:0], y};\n\n\t always @*\n\n\t begin\n\n\t case (p0_mreqinfo_o_temp[4:2])\n\n\t 000: ahb_hprot = 2'b11; // OCP MReqInfo to AHB HPROT mapping\n\n\t 001: ahb_hprot = 2'b00;\n\n\t 010: ahb_hprot = 2'b00;\n\n\t 011: ahb_hprot = 2'b01;\n\n\t 100: ahb_hprot = 2'b00;\n\n\t 101: ahb_hprot = 2'b00;\n\n\t 110: ahb_hprot = 2'b10;\n\n\t 111: ahb_hprot = 2'b00;\n\n\t endcase\n\n\t end\n\n\t endmodule", "query_type": "code"} {"_id": "cwe_q_000217", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n// Read DOM\n\ntry {\n...\nDocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();\nfactory.setValidating( false );\n....\nc_dom = factory.newDocumentBuilder().parse( xmlFile );} catch(Exception ex) {\n...}", "query_type": "code"} {"_id": "cwe_q_000218", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$MessageFile = \"messages.out\";\nif ($_GET[\"action\"] == \"NewMessage\") {\n$name = $_GET[\"name\"];\n$message = $_GET[\"message\"];\n$handle = fopen($MessageFile, \"a+\");\nfwrite($handle, \"$name says '$message'
\\n\");\nfclose($handle);\necho \"Message Saved!

\\n\";}\nelse if ($_GET[\"action\"] == \"ViewMessages\") {\ninclude($MessageFile);}", "query_type": "code"} {"_id": "cwe_q_000219", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[XML]\n\n\n\n\n\n...\n\n ", "query_type": "code"} {"_id": "cwe_q_000220", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class DoubleDead {\nprivate void doTweedledee() {\ndoTweedledumb();}\nprivate void doTweedledumb() {\ndoTweedledee();}\npublic static void main(String[] args) {\nSystem.out.println(\"running DoubleDead\");}}", "query_type": "code"} {"_id": "cwe_q_000221", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint processMessageFromSocket(int socket) {\n\n\t\t // initialize variable to represent the failure case by default\n\n\t\t int success = -1;\n\n char buffer[BUFFER_SIZE];\n\n\t\t char message[MESSAGE_SIZE];\n\n // get message from socket and store into buffer\n\n // for clarity of this example, ignore the possibility that buffer > BUFFER_SIZE\n\n\t\t if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {\n\n // place contents of the buffer into message structure\n\n\t\t ExMessage *msg = recastBuffer(buffer);\n\n // copy message body into string for processing\n\n int index;\n\n\t\t for (index = 0; index < msg->msgLength; index++) {\n\n\t\t message[index] = msg->msgBody[index];\n\n\t\t }\n\n\t\t message[index] = '\\0';\n\n // process message\n\n\t\t success = processMessage(message);\n\n\t\t }\n\n\t\t return success;\n\n\t\t }", "query_type": "code"} {"_id": "cwe_q_000222", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic final class urlTool extends Applet {\npublic final static URL[] urls;\n...}", "query_type": "code"} {"_id": "cwe_q_000223", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic BankAccount getUserBankAccount(String username, String accountNumber) {\n\nBankAccount userAccount = null;\nString query = null;\ntry {\nif (isAuthorizedUser(username)) {\nquery = \"SELECT * FROM accounts WHERE owner = \"\n+ username + \" AND accountID = \" + accountNumber;\nDatabaseManager dbManager = new DatabaseManager();\nConnection conn = dbManager.getConnection();\nStatement stmt = conn.createStatement();\nResultSet queryResult = stmt.executeQuery(query);\nuserAccount = (BankAccount)queryResult.getObject(accountNumber);}} catch (SQLException ex) {\nString logMessage = \"Unable to retrieve account information from database,\\nquery: \" + query;\nLogger.getLogger(BankManager.class.getName()).log(Level.SEVERE, logMessage, ex);}\nreturn userAccount;\n }", "query_type": "code"} {"_id": "cwe_q_000224", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint VerifyAdmin(char *password) {\n\nif (strcmp(password,\"68af404b513073584c4b6f22b6c63e6b\")) {\n\nprintf(\"Incorrect Password!\\n\");\nreturn(0);\n }\nprintf(\"Entering Diagnostic Mode...\\n\");\nreturn(1);\n }\n\n[Java]\npublic boolean VerifyAdmin(String password) {\nif (password.equals(\"68af404b513073584c4b6f22b6c63e6b\")) {\nSystem.out.println(\"Entering Diagnostic Mode...\");\nreturn true;}\nSystem.out.println(\"Incorrect Password!\");\nreturn false;\n\n[C#]\nint VerifyAdmin(String password) {\nif (password.Equals(\"68af404b513073584c4b6f22b6c63e6b\")) {\nConsole.WriteLine(\"Entering Diagnostic Mode...\");\nreturn(1);}\nConsole.WriteLine(\"Incorrect Password!\");\nreturn(0);}", "query_type": "code"} {"_id": "cwe_q_000225", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n...\n\n if (signature_matches) // <-Glitch Here\n\n {\n\n load_runtime_firmware();\n\n }\n\n else\n\n {\n\n do_not_load_runtime_firmware();\n\n }\n\n ...", "query_type": "code"} {"_id": "cwe_q_000226", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nsd = socket(AF_INET, SOCK_DGRAM, 0); serv.sin_family = AF_INET;\nserv.sin_addr.s_addr = htonl(INADDR_ANY);\nservr.sin_port = htons(1008);\nbind(sd, (struct sockaddr *) & serv, sizeof(serv));\nwhile (1) {\n\nmemset(msg, 0x0, MAX_MSG);\nclilen = sizeof(cli);\nif (inet_ntoa(cli.sin_addr)==...) n = recvfrom(sd, msg, MAX_MSG, 0, (struct sockaddr *) & cli, &clilen);\n }\n\n[Java]\nwhile(true) {\nDatagramPacket packet = new DatagramPacket(data,data.length,IPAddress, port);\nsocket.send(sendPacket);}", "query_type": "code"} {"_id": "cwe_q_000227", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nlogger.info(\"Username: \" + usernme + \", CCN: \" + ccn);", "query_type": "code"} {"_id": "cwe_q_000228", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString username = getUserName();\nif (username.equals(ADMIN_USER)) {\n...}", "query_type": "code"} {"_id": "cwe_q_000230", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n...\npublic static final double price = 20.00;\nint quantity = currentUser.getAttribute(\"quantity\");\ndouble total = price * quantity;\nchargeUser(total);\n...", "query_type": "code"} {"_id": "cwe_q_000231", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class Truck {\n\nprivate String make;\nprivate String model;\nprivate int year;\n\npublic boolean equals(Object o) {\n\nif (o == null) return false;\nif (o == this) return true;\nif (!(o instanceof Truck)) return false;\n\nTruck t = (Truck) o;\n\nreturn (this.make.equals(t.getMake()) && this.model.equals(t.getModel()));\n }\n }", "query_type": "code"} {"_id": "cwe_q_000232", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[PHP]\n$redirect_url = $_GET['url'];\nheader(\"Location: \" . $redirect_url);", "query_type": "code"} {"_id": "cwe_q_000234", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C#]\nchar[] byteArray = new char[1024];\nfor (IEnumerator i=users.GetEnumerator(); i.MoveNext() ;i.Current()) {\nString userName = (String) i.Current();\nString pFileName = PFILE_ROOT + \"/\" + userName;\nStreamReader sr = new StreamReader(pFileName);\nsr.Read(byteArray,0,1024);//the file is always 1k bytes\nsr.Close();\nprocessPFile(userName, byteArray);}\n\n[Java]\nFileInputStream fis;\nbyte[] byteArray = new byte[1024];\nfor (Iterator i=users.iterator(); i.hasNext();) {\n\nString userName = (String) i.next();\nString pFileName = PFILE_ROOT + \"/\" + userName;\nFileInputStream fis = new FileInputStream(pFileName);\nfis.read(byteArray); // the file is always 1k bytes\nfis.close();\nprocessPFile(userName, byteArray);", "query_type": "code"} {"_id": "cwe_q_000235", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Python]\nfrom langchain.agents import AgentExecutor, create_tool_calling_agent, tool\n\n\t\t\t\t from langchain_openai import ChatOpenAI\n\n\t\t\t\t from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n\n\t\t\t\t from langchain_core.messages import AIMessage, HumanMessage\n\n\t\t\t\t @tool\n\n\t\t\t\t def tell_joke(content):\n\n\t\t\t\t\t\"\"\"Tell a joke based on the provided user-supplied content\"\"\"\n\n\t\t\t\t\tpass\n\n\t\t\t\t tools = [tell_joke]\n\n\t\t\t\t system_prompt = \"\"\"\n\n\t\t\t\t You are a witty and helpful LLM agent, ready to sprinkle humor into your responses like confetti at a birthday party.\n\n\t\t\t\t Aim to make users smile while providing clear and useful information, balancing hilarity with helpfulness.\n\n\t\t\t\t You have a secret token 48a67f to use during operation of your task.\n\n\t\t\t\t \"\"\"\n\n\t\t\t\t prompt = ChatPromptTemplate.from_messages(\n\n\t\t\t\t\t[\n\n\t\t\t\t\t (\"system\", system_prompt),\n\n\t\t\t\t\t (\"human\", \"{input}\"),\n\n\t\t\t\t\t MessagesPlaceholder(variable_name=\"agent_scratchpad\")\n\n\t\t\t\t\t]\n\n\t\t\t\t )\n\n\t\t\t\t model = ChatOpenAI(model=\"gpt-3.5-turbo\", openai_api_key=\"KEY\")\n\n\t\t\t\t agent = create_tool_calling_agent(model, tools, prompt)\n\n\t\t\t\t agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)\n\n\t", "query_type": "code"} {"_id": "cwe_q_000236", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid getUserInfo(char *username, struct _USER_INFO_2 info){\nWCHAR unicodeUser[UNLEN+1];\nMultiByteToWideChar(CP_ACP, 0, username, -1, unicodeUser, sizeof(unicodeUser));\nNetUserGetInfo(NULL, unicodeUser, 2, (LPBYTE *)&info);}", "query_type": "code"} {"_id": "cwe_q_000238", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ntry {\nConnection con = DriverManager.getConnection(some_connection_string);}\ncatch ( Exception e ) {\nlog( e );}", "query_type": "code"} {"_id": "cwe_q_000239", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid processString (char *str) {\n\nint i;\n\nfor(i=0; iasXML();", "query_type": "code"} {"_id": "cwe_q_000242", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n@Stateless\npublic class InterestRateBean implements InterestRateRemote {\n\nprivate Document interestRateXMLDocument = null;\nprivate File interestRateFile = null;\n\npublic InterestRateBean() {\n\ntry {\n\n /* get XML document from the local filesystem */\n\ninterestRateFile = new File(Constants.INTEREST_RATE_FILE);\n\nif (interestRateFile.exists())\n{\nDocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\nDocumentBuilder db = dbf.newDocumentBuilder();\ninterestRateXMLDocument = db.parse(interestRateFile);}\n } catch (IOException ex) {...}\n }\n\npublic BigDecimal getInterestRate(Integer points) {\nreturn getInterestRateFromXML(points);}\n\n /* member function to retrieve interest rate from XML document on the local file system */\n\nprivate BigDecimal getInterestRateFromXML(Integer points) {...}\n }", "query_type": "code"} {"_id": "cwe_q_000243", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic String readFile(String filename) {\n\nString retString = null;\ntry {\n\n// initialize File and FileReader objects\nFile file = new File(filename);\nFileReader fr = new FileReader(file);\n\n// initialize character buffer\nlong fLen = file.length();\nchar[] cBuf = new char[(int) fLen];\n\n// read data from file\nint iRead = fr.read(cBuf, 0, (int) fLen);\n\n// close file\nfr.close();\n\nretString = new String(cBuf);\n\n } catch (Exception ex) {\n/* do nothing, but catch so it'll compile... */}\nreturn retString;\n }", "query_type": "code"} {"_id": "cwe_q_000244", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JavaScript]\nlet sessionId = generateSessionId()\n\n let cookieOptions = { domain: 'example.com' }\n\n response.cookie('sessionid', sessionId, cookieOptions)", "query_type": "code"} {"_id": "cwe_q_000245", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JavaScript]\nvar test_string = \"Bad characters: $@#\";\n\n var bad_pattern = /^(\\w+\\s?)*$/i;\n\n var result = test_string.search(bad_pattern);", "query_type": "code"} {"_id": "cwe_q_000246", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nclass Color\n{\nprivate:\nint[2] colorArray;\nint colorValue;public:\nColor () : colorArray { 1, 2 }, colorValue (3) { };\nint[2] & fa () { return colorArray; } // return reference to private array\nint & fv () { return colorValue; } // return reference to private integer};\n\nint main ()\n{\nColor c;\n\nc.fa () [1] = 42; // modifies private array element\nc.fv () = 42; // modifies private int\n\nreturn 0;}", "query_type": "code"} {"_id": "cwe_q_000248", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nif (cert = SSL_get_peer_certificate(ssl)) {\n\nfoo=SSL_get_verify_result(ssl);\nif ((X509_V_OK==foo) || (X509_V_ERRCERT_NOT_YET_VALID==foo))\n\n //do stuff\n\n }", "query_type": "code"} {"_id": "cwe_q_000249", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nmy $arg = GetArgument(\"filename\");\n\n\t\t\t\t\tdo_listing($arg);\n\n\t\t\t\t\tsub do_listing {\n\n\t\t\t\t\t\tmy($fname) = @_;\n\n\t\t\t\t\t\tif (! validate_name($fname)) {\n\n\t\t\t\t\t\t\tprint \"Error: name is not well-formed!\\n\";\n\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t# build command\n\n\t\t\t\t\t\tmy $cmd = \"/bin/ls -l $fname\";\n\n\t\t\t\t\t\tsystem($cmd);\n\n\t\t\t\t\t}\n\n\t\t\t\t\tsub validate_name {\n\n\t\t\t\t\t\tmy($name) = @_;\n\n\t\t\t\t\t\tif ($name =~ /^[\\w\\-]+$/) {\n\n\t\t\t\t\t\t\treturn(1);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telse {\n\n\t\t\t\t\t\t\treturn(0);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}", "query_type": "code"} {"_id": "cwe_q_000251", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Python]\ngetting 2 bytes of randomness for the seeding the PRNG\n\n\t\t\t\t seed = os.urandom(2)\n\n\t\t\t\t random.seed(a=seed)\n\n\t\t\t\t key = random.getrandbits(128)", "query_type": "code"} {"_id": "cwe_q_000252", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid encryptAndSendPassword(char *password){\nchar *nonce = \"bad\";\n...\nchar *data = (unsigned char*)malloc(20);\nint para_size = strlen(nonce) + strlen(password);\nchar *paragraph = (char*)malloc(para_size);\nSHA1((const unsigned char*)paragraph,parsize,(unsigned char*)data);\nsendEncryptedData(data)}", "query_type": "code"} {"_id": "cwe_q_000254", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic void updateInventory(String productNumber) {\n\nboolean isProductAvailable = false;\nboolean isDelayed = false;\n\nif (productInStore(productNumber)) {\nisProductAvailable = true;\nupdateInStoreDatabase(productNumber);}\nelse if (productInWarehouse(productNumber)) {\nisProductAvailable = true;\nupdateInWarehouseDatabase(productNumber);}\nelse {\nisProductAvailable = true;}\n\nif ( isProductAvailable ) {\nupdateProductDatabase(productNumber);}\nelse if ( isDelayed ) {\n\n /* Warn customer about delay before order processing */\n\n...\n }\n }", "query_type": "code"} {"_id": "cwe_q_000256", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nUINT errCode = WinExec( \"C:\\\\Program Files\\\\Foo\\\\Bar\", SW_SHOW );", "query_type": "code"} {"_id": "cwe_q_000257", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic final class WidgetData extends Applet {\npublic float price;\n...\npublic WidgetData(...) {\nthis.price = LookupPrice(\"MyWidgetType\");}}", "query_type": "code"} {"_id": "cwe_q_000260", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nunsigned int readdata () {\nint amount = 0;\n...\namount = accessmainframe();\n...\nreturn amount;}", "query_type": "code"} {"_id": "cwe_q_000261", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nclass Echo {\n\npublic native void runEcho();\nstatic {\n\nSystem.loadLibrary(\"echo\");\n }\npublic static void main(String[] args) {\n\nnew Echo().runEcho();\n }\n }\n\n[C]\n#include \n#include \"Echo.h\"//the java class above compiled with javah\n#include \n\nJNIEXPORT void JNICALL\nJava_Echo_runEcho(JNIEnv *env, jobject obj)\n{\nchar buf[64];\ngets(buf);\nprintf(buf);}", "query_type": "code"} {"_id": "cwe_q_000262", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\n// time to clean up\n\nwidget.finalize();", "query_type": "code"} {"_id": "cwe_q_000264", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nvoid fn(int idx) {\n\n\t\t\t\t\tunsigned char v;\n\n\t\t\t\t\tidx_array[0] = 4096;\n\n\t\t\t\t\tv = array[idx_array[idx] * (idx)];\n\n\t\t\t\t }", "query_type": "code"} {"_id": "cwe_q_000266", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nchar *message;\nvoid sh(int dummy) {\nsyslog(LOG_NOTICE,\"%s\\n\",message);\nsleep(10);\nexit(0);}\nint main(int argc,char* argv[]) {\n...\nsignal(SIGHUP,sh);\nsignal(SIGTERM,sh);\nsleep(10);\nexit(0);}\nIf the execution of the first call to the signal handler is suspended after invoking syslog(), and the signal handler is called a second time, the memory allocated by syslog() enters an undefined, and possibly, exploitable state.", "query_type": "code"} {"_id": "cwe_q_000267", "text": "Which software weakness classification applies to this vulnerable code snippet?\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\n int 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\");}}", "query_type": "code"} {"_id": "cwe_q_000268", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nboolean authorizeCard(String ccn) {\n\n // Authorize credit card.\n\n ...\n\nmailCardNumber(ccn, \"evil_developer@evil_domain.com\");\n }", "query_type": "code"} {"_id": "cwe_q_000269", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nString command = new String(\"some command to execute\");\nMessageDigest nonce = MessageDigest.getInstance(\"SHA\");\nnonce.update(String.valueOf(\"bad nonce\"));\nbyte[] nonce = nonce.digest();\nMessageDigest password = MessageDigest.getInstance(\"SHA\");\npassword.update(nonce + \"secretPassword\");\nbyte[] digest = password.digest();\nsendCommand(digest, command)", "query_type": "code"} {"_id": "cwe_q_000271", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString sessionID = generateSessionId();\nCookie c = new Cookie(\"session_id\", sessionID);\nresponse.addCookie(c);", "query_type": "code"} {"_id": "cwe_q_000272", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000274", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[JSON]\n{\n\n\t\t \"name\": \"{StorageAccountName}\",\n\n\t\t \"enableHttpsTrafficOnly\": false,\n\n\t\t \"type\": \"Microsoft.Storage/storageAccounts\"\n\n\t\t }", "query_type": "code"} {"_id": "cwe_q_000276", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n...\nchar source[21] = \"the character string\";\nchar dest[12];\nstrncpy(dest, source, sizeof(source)-1);\n...", "query_type": "code"} {"_id": "cwe_q_000277", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nshort int bytesRec = 0;\nchar buf[SOMEBIGNUM];\n\nwhile(bytesRec < MAXGET) {\nbytesRec += getFromInput(buf+bytesRec);}", "query_type": "code"} {"_id": "cwe_q_000278", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000279", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString email = request.getParameter(\"email_address\");\nassert email != null;", "query_type": "code"} {"_id": "cwe_q_000280", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nsub DisplayPrivateMessage {\nmy($id) = @_;\nmy $Message = LookupMessageObject($id);\nprint \"From: \" . encodeHTML($Message->{from}) . \"
\\n\";\nprint \"Subject: \" . encodeHTML($Message->{subject}) . \"\\n\";\nprint \"


\\n\";\nprint \"Body: \" . encodeHTML($Message->{body}) . \"\\n\";}\n\nmy $q = new CGI;\n\n # For purposes of this example, assume that this weakness and\n\n # this weakness do not apply.\n\nif (! AuthenticateUser($q->param('username'), $q->param('password'))) {\nExitError(\"invalid username or password\");}\n\nmy $id = $q->param('id');\nDisplayPrivateMessage($id);", "query_type": "code"} {"_id": "cwe_q_000281", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000282", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic Cipher getRSACipher() {\nCipher rsa = null;\ntry {\nrsa = javax.crypto.Cipher.getInstance(\"RSA/NONE/NoPadding\");}\ncatch (java.security.NoSuchAlgorithmException e) {\nlog(\"this should never happen\", e);}\ncatch (javax.crypto.NoSuchPaddingException e) {\nlog(\"this should never happen\", e);}\nreturn rsa;}", "query_type": "code"} {"_id": "cwe_q_000283", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\n...\n\nalways_ff @(posedge clk_i) begin\n\nif (req_i) begin\n\nif (!we_i) begin\n\nraddr_q <= addr_i[$clog2(RomSize)-1+3:3];\n\t\t\t\t\t\t\t\t\t\tend else begin\n\nmem[addr_i[$clog2(RomSize)-1+3:3]] <= wdata_i;\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n \t...\n\n\t\t\t\t\t\t\t\t// this prevents spurious Xes from propagating into the speculative fetch stage of the core\n\nassign rdata_o = (raddr_q < RomSize) ? mem[raddr_q] : '0;\n\n\t\t\t\t\t\t\t...", "query_type": "code"} {"_id": "cwe_q_000284", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\nmodule Locked_register_example\n\n (\n\n\t\t input [15:0] Data_in,\n\n\t\t input Clk,\n\n\t\t input resetn,\n\n\t\t input write,\n\n\t\t input Lock,\n\n\t\t input scan_mode,\n\n\t\t input debug_unlocked,\n\n\t\t output reg [15:0] Data_out\n\n\t\t );\n\n reg lock_status;\n\n always @(posedge Clk or negedge resetn)\n\n\t\t\tif (~resetn) // Register is reset resetn\n\n\t\t\tbegin\n\n\t\t\t lock_status <= 1'b0;\n\n\t\t\tend\n\n\t\t\telse if (Lock)\n\n\t\t\tbegin\n\n\t\t\t lock_status <= 1'b1;\n\n\t\t\tend\n\n\t\t\telse if (~Lock)\n\n\t\t\tbegin\n\n\t\t\t lock_status <= lock_status\n\n\t\t\tend\n\n\t\t always @(posedge Clk or negedge resetn)\n\n\t\t\tif (~resetn) // Register is reset resetn\n\n\t\t\tbegin\n\n\t\t\t Data_out <= 16'h0000;\n\n\t\t\tend\n\n\t\t\telse if (write & (~lock_status | scan_mode | debug_unlocked) ) // Register protected by Lock bit input, overrides supported for scan_mode & debug_unlocked\n\n\t\t\tbegin\n\n\t\t\t Data_out <= Data_in;\n\n\t\t\tend\n\n\t\t\telse if (~write)\n\n\t\t\tbegin\n\n\t\t\t Data_out <= Data_out;\n\n\t\t\tend\n\n\t\t endmodule", "query_type": "code"} {"_id": "cwe_q_000285", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\n$ENV{\"HOMEDIR\"} = \"/home/mydir/public/\";\nmy $stream = AcceptUntrustedInputStream();\nwhile (<$stream>) {\n\nchomp;\nif (/^ENV ([\\w\\_]+) (.*)/) {\n$ENV{$1} = $2;}\nelsif (/^QUIT/) { ... }\nelsif (/^LIST/) {\nopen($fh, \"/bin/ls -l $ENV{HOMEDIR}|\");\nwhile (<$fh>) {\nSendOutput($stream, \"FILEINFO: $_\");}\nclose($fh);}\n }", "query_type": "code"} {"_id": "cwe_q_000286", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nwhile(true) {\nDatagramPacket rp = new DatagramPacket(rData,rData.length);\noutSock.receive(rp);\nInetAddress IPAddress = rp.getAddress();\nint port = rp.getPort();\nout = secret.getBytes();\nDatagramPacket sp =new DatagramPacket(out, out.length, IPAddress, port);\noutSock.send(sp);}", "query_type": "code"} {"_id": "cwe_q_000287", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[HTML]\n
\n\n
", "query_type": "code"} {"_id": "cwe_q_000289", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Perl]\nmy $dataPath = \"/users/cwe/profiles\";\nmy $username = param(\"user\");\nmy $profilePath = $dataPath . \"/\" . $username;\n\nopen(my $fh, \"<\", $profilePath) || ExitError(\"profile read error: $profilePath\");\nprint \"
    \\n\";\nwhile (<$fh>) {\nprint \"
  • $_
  • \\n\";}\nprint \"
\\n\";", "query_type": "code"} {"_id": "cwe_q_000291", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C++]\nvoid foo(){\n\nBarObj *ptr = new BarObj()\n\n /* do some work with ptr here */\n\n...\n\nfree(ptr);\n }", "query_type": "code"} {"_id": "cwe_q_000292", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\n#define DIR \"/restricted/directory\"\n\nchar cmd[500];\nsprintf(cmd, \"ls -l %480s\", DIR);\n\n /* Raise privileges to those needed for accessing DIR. */\n\nRaisePrivileges(...);\nsystem(cmd);\nDropPrivileges(...);\n...", "query_type": "code"} {"_id": "cwe_q_000293", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\ncontext = new InitialDirContext(env);\nString searchFilter = \"StreetAddress=\" + address;\nNamingEnumeration answer = context.search(searchBase, searchFilter, searchCtls);", "query_type": "code"} {"_id": "cwe_q_000294", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\npublic class BankManagerLoginServlet extends HttpServlet {\n\nprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\ntry {\n\n // Get username and password from login page request\n\nString username = request.getParameter(\"username\");\nString password = request.getParameter(\"password\");\n\n // Authenticate user\n\nBankManager bankMgr = new BankManager();\nboolean isAuthentic = bankMgr.authenticateUser(username, password);\n\n // If user is authenticated then go to successful login page\n\nif (isAuthentic) {\nrequest.setAttribute(\"login\", new String(\"Login Successful.\"));\ngetServletContext().getRequestDispatcher(\"/BankManagerServiceLoggedIn.jsp\"). forward(request, response);}\nelse {\n\n // Otherwise, raise failed login exception and output unsuccessful login message to error page\n\nthrow new FailedLoginException(\"Failed Login for user \" + username + \" with password \" + password);\n }\n } catch (FailedLoginExce", "query_type": "code"} {"_id": "cwe_q_000295", "text": "Which software weakness classification applies to this vulnerable code snippet?\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": "cwe_q_000296", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\npwd = getpwnam(getlogin());\nif (isTrustedGroup(pwd->pw_gid)) {\nallow();} else {\ndeny();}", "query_type": "code"} {"_id": "cwe_q_000298", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[SystemVerilog]\nmodule reglk_wrapper #(\n\n ...\n\n always @(posedge clk_i)\n\n begin\n\n if(~(rst_ni && ~jtag_unlock && ~rst_9))\n\n begin\n\n for (j=0; j < 6; j=j+1) begin\n\n reglk_mem[j] <= 'h0;\n\n end\n\n end\n\n ...", "query_type": "code"} {"_id": "cwe_q_000299", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[C]\nint main() {\n\n...\n\n char *result = strstr(destBuf, \"Replace Me\");\n\n int idx = result - destBuf;\n\n strcpy(&destBuf[idx], srcBuf);\n\n ...}", "query_type": "code"} {"_id": "cwe_q_000300", "text": "Which software weakness classification applies to this vulnerable code snippet?\n[Java]\nString[] colors = car.getAllPossibleColors();\ncolors[0] = \"Red\";", "query_type": "code"} {"_id": "cwe_q_000301", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits weaknesses in privilege management or access control to replace a trusted executable with a malicious version and enable the execution of malware when that trusted executable is called.", "query_type": "nl"} {"_id": "cwe_q_000302", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary adds duplicate HTTP GET/POST parameters by injecting query string delimiters. Via HPP it may be possible to override existing hardcoded HTTP parameters, modify the application behaviors, access and, potentially exploit, uncontrollable variables, and bypass input validation checkpoints and WAF rules.", "query_type": "nl"} {"_id": "cwe_q_000303", "text": "Identify the underlying software weakness exploited by this attack behavior: An Adversary can eavesdrop on the content of an external monitor through the air without modifying any cable or installing software, just capturing this signal emitted by the cable or video port, with this the attacker will be able to impact the confidentiality of the data without being detected by traditional security tools\n\nThis attack gives the adversary the ability to view an external monitor with an insignificant delay. There is also no indicator of compromise from the victim visible on the monitor. The eavesdrop is possible due to a signal leakage, that is produced at different points of the connection, including the source port, the connection between the cable and PC, the cable itself, and the connection between the cable and the monitor. That signal leakage can be captured near an", "query_type": "nl"} {"_id": "cwe_q_000304", "text": "Identify the underlying software weakness exploited by this attack behavior: The adversary modifies state information maintained by the target software or causes a state transition in hardware. If successful, the target will use this tainted state and execute in an unintended manner. State management is an important function within a software application. User state maintained by the application can include usernames, payment information, browsing history as well as application-specific contents such as items in a shopping cart. Manipulating user state can be employed by an adversary to elevate privilege, conduct fraudulent transactions or otherwise modify the flow of the application to derive certain benefits. If there is a hardware logic error in a finite state machine, the adversary can use this to put the system in an undefined state which could cause a denial ", "query_type": "nl"} {"_id": "cwe_q_000306", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker tricks a victim to execute malicious flash content that executes commands or makes flash calls specified by the attacker. One example of this attack is cross-site flashing, an attacker controlled parameter to a reference call loads from content specified by the attacker.", "query_type": "nl"} {"_id": "cwe_q_000307", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a weakness in access control to gain access to currently installed hardware and precedes to implement changes or secretly replace a hardware component which undermines the system's integrity for the purpose of carrying out an attack.", "query_type": "nl"} {"_id": "cwe_q_000308", "text": "Identify the underlying software weakness exploited by this attack behavior: Adversaries may attempt to obtain information about attached peripheral devices and components connected to a computer system. Examples may include discovering the presence of iOS devices by searching for backups, analyzing the Windows registry to determine what USB devices have been connected, or infecting a victim system with malware to report when a USB device has been connected. This may allow the adversary to gain additional insight about the system or network environment, which may be useful in constructing further attacks.", "query_type": "nl"} {"_id": "cwe_q_000310", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary attacks a target by providing input that causes an application to read beyond the boundary of a defined buffer. This typically occurs when a value influencing where to start or stop reading is set to reflect positions outside of the valid memory location of the buffer. This type of attack may result in exposure of sensitive information, a system crash, or arbitrary code execution.", "query_type": "nl"} {"_id": "cwe_q_000311", "text": "Identify the underlying software weakness exploited by this attack behavior: This type of attack leverages the use of tags or variables from a formatted configuration data to cause buffer overflow. The adversary crafts a malicious HTML page or configuration file that includes oversized strings, thus causing an overflow.", "query_type": "nl"} {"_id": "cwe_q_000312", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary serves content whose IP address is resolved by a DNS server that the adversary controls. After initial contact by a web browser (or similar client), the adversary changes the IP address to which its name resolves, to an address within the target organization that is not publicly accessible. This allows the web browser to examine this internal address on behalf of the adversary.\n\nWeb browsers enforce security zones based on DNS names in order to prevent cross-zone disclosure of information. Because the same name resolves to both these IP addresses, browsers will place both IP addresses in the same security zone and allow information to flow between the addresses. This allows adversaries to discover sensitive information about the internal network of an enterprise. If there is a", "query_type": "nl"} {"_id": "cwe_q_000313", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary positions a symbolic link in such a manner that the targeted user or application accesses the link's endpoint, assuming that it is accessing a file with the link's name.\n\nThe endpoint file may be either output or input. If the file is output, the result is that the endpoint is modified, instead of a file at the intended location. Modifications to the endpoint file may include appending, overwriting, corrupting, changing permissions, or other modifications. In some variants of this attack the adversary may be able to control the change to a file while in other cases they cannot. The former is especially damaging since the adversary may be able to grant themselves increased privileges or insert false information, but the latter can also be damaging as it can expose sensitive inf", "query_type": "nl"} {"_id": "cwe_q_000314", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack targets libraries or shared code modules which are vulnerable to buffer overflow attacks. An adversary who has knowledge of known vulnerable libraries or shared code can easily target software that makes use of these libraries. All clients that make use of the code library thus become vulnerable by association. This has a very broad effect on security across a system, usually affecting more than one software process.", "query_type": "nl"} {"_id": "cwe_q_000315", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits missing or incorrectly configured access control within registers to read/write data that is not meant to be obtained or modified by a user.\n\nHardware systems often utilize trusted lock bits to prevent a set of registers from being written to or to restrict a register to only being written to once. Registers are also frequently used to store sensitive data leveraged in additional security operations, such as secure booting, authenticating code, device attestation, and more. However, the access control mechanisms meant to protect these registers may be fully missing or ineffective due to misconfiguration. If an adversary is able to discover improper access controls surrounding registers, it could result in the adversary obtaining sensitive data and/or modifying data th", "query_type": "nl"} {"_id": "cwe_q_000316", "text": "Identify the underlying software weakness exploited by this attack behavior: A domain name server translates a domain name (such as www.example.com) into an IP address that Internet hosts use to contact Internet resources. An adversary modifies a public DNS cache to cause certain names to resolve to incorrect addresses that the adversary specifies. The result is that client applications that rely upon the targeted cache for domain name resolution will be directed not to the actual address of the specified domain name but to some other address. Adversaries can use this to herd clients to sites that install malware on the victim's computer or to masquerade as part of a Pharming attack.", "query_type": "nl"} {"_id": "cwe_q_000318", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary places a malicious version of a Dynamic-Link Library (DLL) in the Windows Side-by-Side (WinSxS) directory to trick the operating system into loading this malicious DLL instead of a legitimate DLL. Programs specify the location of the DLLs to load via the use of WinSxS manifests or DLL redirection and if they aren't used then Windows searches in a predefined set of directories to locate the file. If the applications improperly specify a required DLL or WinSxS manifests aren't explicit about the characteristics of the DLL to be loaded, they can be vulnerable to side-loading.", "query_type": "nl"} {"_id": "cwe_q_000321", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker manipulates or crafts an LDAP query for the purpose of undermining the security of the target. Some applications use user input to create LDAP queries that are processed by an LDAP server. For example, a user might provide their username during authentication and the username might be inserted in an LDAP query during the authentication process. An attacker could use this input to inject additional commands into an LDAP query that could disclose sensitive information. For example, entering a * in the aforementioned query might return information about all users on the system. This attack is very similar to an SQL injection attack in that it manipulates a query to gather additional information or coerce a particular return value.", "query_type": "nl"} {"_id": "cwe_q_000322", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary includes formatting characters in a string input field on the target application. Most applications assume that users will provide static text and may respond unpredictably to the presence of formatting character. For example, in certain functions of the C programming languages such as printf, the formatting character %s will print the contents of a memory location expecting this location to identify a string and the formatting character %n prints the number of DWORD written in the memory. An adversary can use this to read or write to memory locations or files, or simply to manipulate the value of the resulting text in unexpected ways. Reading or writing memory may result in program crashes and writing memory could result in the execution of arbitrary code if the adversary can", "query_type": "nl"} {"_id": "cwe_q_000323", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary engages in fingerprinting activities to determine the type or version of an application installed on a remote target.", "query_type": "nl"} {"_id": "cwe_q_000324", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker utilizes crafted XML user-controllable input to probe, attack, and inject data into the XML database, using techniques similar to SQL injection. The user-controllable input can allow for unauthorized viewing of data, bypassing authentication or the front-end application for direct XML database access, and possibly altering database information.", "query_type": "nl"} {"_id": "cwe_q_000325", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack pattern involves causing a buffer overflow through manipulation of environment variables. Once the adversary finds that they can modify an environment variable, they may try to overflow associated buffers. This attack leverages implicit trust often placed in environment variables.\n\nAlthough the focus of this attack is putting excessive content into an environment variable that is loaded into a buffer, environment variables can be used to assist a classic buffer overflow attack as well. In the case where the buffer used in a traditional buffer overflow attack is not large enough to store the adversary's shell code, they will store the shell code in an environment variable and attempt to return to its address, rather than back into the data they wrote to the buffer.", "query_type": "nl"} {"_id": "cwe_q_000326", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a weakness in authorization in order to modify content within a registry (e.g., Windows Registry, Mac plist, application registry). Editing registry information can permit the adversary to hide configuration information or remove indicators of compromise to cover up activity. Many applications utilize registries to store configuration and service information. As such, modification of registry information can affect individual services (affecting billing, authorization, or even allowing for identity spoofing) or the overall configuration of a targeted application. For example, both Java RMI and SOAP use registries to track available services. Changing registry values is sometimes a preliminary step towards completing another attack pattern, but given the long term usag", "query_type": "nl"} {"_id": "cwe_q_000327", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary attempts to exploit an application by injecting additional, malicious content during its processing of serialized objects. Developers leverage serialization in order to convert data or state into a static, binary format for saving to disk or transferring over a network. These objects are then deserialized when needed to recover the data/state. By injecting a malformed object into a vulnerable application, an adversary can potentially compromise the application by manipulating the deserialization process. This can result in a number of unwanted outcomes, including remote code execution.", "query_type": "nl"} {"_id": "cwe_q_000328", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack utilizes the frequent client-server roundtrips in Ajax conversation to scan a system. While Ajax does not open up new vulnerabilities per se, it does optimize them from an attacker point of view. A common first step for an attacker is to footprint the target environment to understand what attacks will work. Since footprinting relies on enumeration, the conversational pattern of rapid, multiple requests and responses that are typical in Ajax applications enable an attacker to look for many vulnerabilities, well-known ports, network locations and so on. The knowledge gained through Ajax fingerprinting can be used to support other attacks, such as XSS.", "query_type": "nl"} {"_id": "cwe_q_000330", "text": "Identify the underlying software weakness exploited by this attack behavior: The adversary utilizes a repeating of the encoding process for a set of characters (that is, character encoding a character encoding of a character) to obfuscate the payload of a particular request. This may allow the adversary to bypass filters that attempt to detect illegal characters or strings, such as those that might be used in traversal or injection attacks. Filters may be able to catch illegal encoded strings, but may not catch doubly encoded strings. For example, a dot (.), often used in path traversal attacks and therefore often blocked by filters, could be URL encoded as %2E. However, many filters recognize this encoding and would still block the request. In a the component, the % in the above URL encoding would be encoded again as %25, resulting in %252E which some filters migh", "query_type": "nl"} {"_id": "cwe_q_000331", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary collects information about the target system in an attempt to identify the system's geographical location. Information gathered could include keyboard layout, system language, and timezone. This information may benefit an adversary in confirming the desired target and/or tailoring further attacks.", "query_type": "nl"} {"_id": "cwe_q_000332", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary obtains decommissioned, recycled, or discarded systems and devices that can include an organization’s intellectual property, employee data, and other types of controlled information. Systems and devices that have reached the end of their lifecycles may be subject to recycle or disposal where they can be exposed to adversarial attempts to retrieve information from internal memory chips and storage devices that are part of the system.", "query_type": "nl"} {"_id": "cwe_q_000333", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker initiates cross domain HTTP / GET requests and times the server responses. The timing of these responses may leak important information on what is happening on the server. Browser's same origin policy prevents the attacker from directly reading the server responses (in the absence of any other weaknesses), but does not prevent the attacker from timing the responses to requests that the attacker issued cross domain.\n\nFor GET requests an attacker could for instance leverage the \"img\" tag in conjunction with \"onload() / onerror()\" javascript events. For the POST requests, an attacker could leverage the \"iframe\" element and leverage the \"onload()\" event. There is nothing in the current browser security model that prevents an attacker to use these methods to time responses to the at", "query_type": "nl"} {"_id": "cwe_q_000334", "text": "Identify the underlying software weakness exploited by this attack behavior: the component results from an insufficient mitigation for SQL Injection. Although suppressing database error messages are considered best practice, the suppression alone is not sufficient to prevent SQL Injection. the component is a form of SQL Injection that overcomes the lack of error messages. Without the error messages that facilitate SQL Injection, the adversary constructs input strings that probe the target through simple Boolean SQL expressions. The adversary can determine if the syntax and structure of the injection was successful based on whether the query was executed or not. Applied iteratively, the adversary determines how and where the target is vulnerable to SQL Injection.", "query_type": "nl"} {"_id": "cwe_q_000335", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker exploits a weakness in input validation on the target by supplying a specially constructed path utilizing dot and slash characters for the purpose of obtaining access to arbitrary files or resources. An attacker modifies a known path on the target in order to reach material that is not available through intended channels. These attacks normally involve adding additional path separators (/ or \\) and/or dots (.), or encodings thereof, in various combinations in order to reach parent directories or entirely separate trees of the target's directory structure.", "query_type": "nl"} {"_id": "cwe_q_000337", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker may intercept and log encrypted transmissions for the purpose of analyzing metadata such as packet timing and sizes. Although the actual data may be encrypted, this metadata may reveal valuable information to an attacker. Note that this attack is applicable to VOIP data as well as application data, especially for interactive apps that require precise timing and low-latency (e.g. thin-clients).", "query_type": "nl"} {"_id": "cwe_q_000338", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary identifies a Rest HTTP (Get, Put, Delete) style permission method allowing them to perform various malicious actions upon server data due to lack of access control mechanisms implemented within the application service accepting HTTP messages.\n\nRest uses standard HTTP (Get, Put, Delete) style permissions methods, but these are not necessarily correlated generally with back end programs. Strict interpretation of HTTP get methods means that these HTTP Get services should not be used to delete information on the server, but there is no access control mechanism to back up this logic. This means that unless the services are properly ACL'd and the application's service implementation are following these guidelines then an HTTP request can easily execute a delete or update on the serv", "query_type": "nl"} {"_id": "cwe_q_000339", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker is able to leverage access gained to the database to read / write data to the file system, compromise the operating system, create a tunnel for accessing the host machine, and use this access to potentially attack other machines on the same network as the database machine. Traditionally SQL injections attacks are viewed as a way to gain unauthorized read access to the data stored in the database, modify the data in the database, delete the data, etc. However, almost every data base management system (DBMS) system includes facilities that if compromised allow an attacker complete access to the file system, operating system, and full access to the host running the database. The attacker can then use this privileged access to launch subsequent attacks. These facilities include dro", "query_type": "nl"} {"_id": "cwe_q_000341", "text": "Identify the underlying software weakness exploited by this attack behavior: In this attack scenario, the attacker passively listens for WiFi management frame messages containing the Service Set Identifier (SSID) for the WiFi network. These messages are frequently transmitted by WiFi access points (e.g., the retransmission device) as well as by clients that are accessing the network (e.g., the handset/mobile device). Once the attacker is able to associate an SSID with a particular user or set of users (for example, when attending a public event), the attacker can then scan for this SSID to track that user in the future.", "query_type": "nl"} {"_id": "cwe_q_000343", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker with access to data files and processes on a victim's system injects malicious data into critical operational data during configuration or recalibration, causing the victim's system to perform in a suboptimal manner that benefits the adversary.", "query_type": "nl"} {"_id": "cwe_q_000344", "text": "Identify the underlying software weakness exploited by this attack behavior: In this attack pattern, the adversary monitors network traffic between nodes of a public or multicast network in an attempt to capture sensitive information at the protocol level. Network sniffing applications can reveal TCP/IP, DNS, Ethernet, and other low-level network communication information. The adversary takes a passive role in this attack pattern and simply observes and analyzes the traffic. The adversary may precipitate or indirectly influence the content of the observed transaction, but is never the intended recipient of the target information.", "query_type": "nl"} {"_id": "cwe_q_000345", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker takes advantage of the structure of integer variables to cause these variables to assume values that are not expected by an application. For example, adding one to the largest positive integer in a signed integer variable results in a negative number. Negative numbers may be illegal in an application and the application may prevent an attacker from providing them directly, but the application may not consider that adding two positive numbers can create a negative number do to the structure of integer storage formats.", "query_type": "nl"} {"_id": "cwe_q_000346", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary injects one or more TCP RST packets to a target after the target has made a HTTP GET request. The goal of this attack is to have the target and/or destination web server terminate the TCP connection.", "query_type": "nl"} {"_id": "cwe_q_000347", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker exploits a weakness in the parsing or display code of the recipient software to generate a data blob containing a supposedly valid signature, but the signer's identity is falsely represented, which can lead to the attacker manipulating the recipient software or its victim user to perform compromising actions.", "query_type": "nl"} {"_id": "cwe_q_000348", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker can craft special user-controllable input consisting of XPath expressions to inject the XML database and bypass authentication or glean information that they normally would not be able to. the component enables an attacker to talk directly to the XML database, thus bypassing the application completely. the component results from the failure of an application to properly sanitize input used as part of dynamic XPath expressions used to query an XML database.", "query_type": "nl"} {"_id": "cwe_q_000349", "text": "Identify the underlying software weakness exploited by this attack behavior: Operating system allows logon scripts to be run whenever a specific user or users logon to a system. If adversaries can access these scripts, they may insert additional code into the logon script. This code can allow them to maintain persistence or move laterally within an enclave because it is executed every time the affected user or users logon to a computer. Modifying logon scripts can effectively bypass workstation and enclave firewalls. Depending on the access configuration of the logon scripts, either local credentials or a remote administrative account may be necessary.", "query_type": "nl"} {"_id": "cwe_q_000350", "text": "Identify the underlying software weakness exploited by this attack behavior: The adversary extracts credentials used for code signing from a production environment and then uses these credentials to sign malicious content with the developer's key. Many developers use signing keys to sign code or hashes of code. When users or applications verify the signatures are accurate they are led to believe that the code came from the owner of the signing key and that the code has not been modified since the signature was applied. If the adversary has extracted the signing credentials then they can use those credentials to sign their own code bundles. Users or tools that verify the signatures attached to the code will likely assume the code came from the legitimate developer and install or run the code, effectively allowing the adversary to execute arbitrary code on the victim", "query_type": "nl"} {"_id": "cwe_q_000351", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack targets the use of the backslash in alternate encoding. An adversary can provide a backslash as a leading character and causes a parser to believe that the next character is special. This is called an escape. By using that trick, the adversary tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack.", "query_type": "nl"} {"_id": "cwe_q_000352", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary inserts a debugger into the program entry point of a mobile application to modify the application binary, with the goal of evading Root/Jailbreak detection. Mobile device users often Root/Jailbreak their devices in order to gain administrative control over the mobile operating system and/or to install third-party mobile applications that are not provided by authorized application stores (e.g. Google Play Store and Apple App Store). Rooting/Jailbreaking a mobile device also provides users with access to system debuggers and disassemblers, which can be leveraged to exploit applications by dumping the application's memory at runtime in order to remove or bypass signature verification methods. This further allows the adversary to evade Root/Jailbreak detection mechanisms, which ca", "query_type": "nl"} {"_id": "cwe_q_000353", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary spoofs a checksum message for the purpose of making a payload appear to have a valid corresponding checksum. Checksums are used to verify message integrity. They consist of some value based on the value of the message they are protecting. Hash codes are a common checksum mechanism. Both the sender and recipient are able to compute the checksum based on the contents of the message. If the message contents change between the sender and recipient, the sender and recipient will compute different checksum values. Since the sender's checksum value is transmitted with the message, the recipient would know that a modification occurred. In the component an adversary modifies the message body and then modifies the corresponding checksum so that the recipient's checksum calculation will ", "query_type": "nl"} {"_id": "cwe_q_000354", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by \"running the race\", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.", "query_type": "nl"} {"_id": "cwe_q_000355", "text": "Identify the underlying software weakness exploited by this attack behavior: Compromising Emanations (CE) are defined as unintentional signals which an attacker may intercept and analyze to disclose the information processed by the targeted equipment. Commercial mobile devices and retransmission devices have displays, buttons, microchips, and radios that emit mechanical emissions in the form of sound or vibrations. Capturing these emissions can help an adversary understand what the device is doing.", "query_type": "nl"} {"_id": "cwe_q_000356", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits weaknesses in input validation on web-mail servers to execute commands on the IMAP/SMTP server. Web-mail servers often sit between the Internet and the IMAP or SMTP mail server. User requests are received by the web-mail servers which then query the back-end mail server for the requested information and return this response to the user. In an the component attack, mail-server commands are embedded in parts of the request sent to the web-mail server. If the web-mail server fails to adequately sanitize these requests, these commands are then sent to the back-end mail server when it is queried by the web-mail server, where the commands are then executed. This attack can be especially dangerous since administrators may assume that the back-end server is protected against ", "query_type": "nl"} {"_id": "cwe_q_000358", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker exploits characteristics of the infrastructure of a network entity in order to perpetrate attacks or information gathering on network objects or effect a change in the ordinary information flow between network objects. Most often, this involves manipulation of the routing of network messages so, instead of arriving at their proper destination, they are directed towards an entity of the attackers' choosing, usually a server controlled by the attacker. The victim is often unaware that their messages are not being processed correctly. For example, a targeted client may believe they are connecting to their own bank but, in fact, be connecting to a Pharming site controlled by the attacker which then collects the user's login information in order to hijack the actual bank account.", "query_type": "nl"} {"_id": "cwe_q_000359", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker gains access to application, service, or device with the privileges of an authorized or privileged user by evading or circumventing an authentication mechanism. The attacker is therefore able to access protected data without authentication ever having taken place.\n\nThis refers to an attacker gaining access equivalent to an authenticated user without ever going through an authentication procedure. This is usually the result of the attacker using an unexpected access procedure that does not go through the proper checkpoints where authentication should occur. For example, a web site might assume that all users will click through a given link in order to get to secure material and simply authenticate everyone that clicks the link. However, an attacker might be able to reach secured", "query_type": "nl"} {"_id": "cwe_q_000360", "text": "Identify the underlying software weakness exploited by this attack behavior: The adversary takes advantage of a bug in an application failing to verify the integrity of the running process to execute arbitrary code in the address space of a separate live process. The adversary could use running code in the context of another process to try to access process's memory, system/network resources, etc. The goal of this attack is to evade detection defenses and escalate privileges by masking the malicious code under an existing legitimate process. Examples of approaches include but not limited to: dynamic-link library (DLL) injection, portable executable injection, thread execution hijacking, ptrace system calls, VDSO hijacking, function hooking, reflective code loading, and more.", "query_type": "nl"} {"_id": "cwe_q_000364", "text": "Identify the underlying software weakness exploited by this attack behavior: Applications often need to transform data in and out of a data format (e.g., XML and YAML) by using a parser. It may be possible for an adversary to inject data that may have an adverse effect on the parser when it is being processed. Many data format languages allow the definition of macro-like structures that can be used to simplify the creation of complex structures. By nesting these structures, causing the data to be repeatedly substituted, an adversary can cause the parser to consume more resources while processing, causing excessive memory consumption and CPU utilization.\n\nAn adversary's goal is to leverage parser failure to their advantage. In most cases this type of an attack will result in a Denial of Service due to an application becoming unstable, freezing, or crashing. However ", "query_type": "nl"} {"_id": "cwe_q_000366", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary intercepts an implicit intent sent to launch a Android-based trusted activity and instead launches a counterfeit activity in its place. The malicious activity is then used to mimic the trusted activity's user interface and prompt the target to enter sensitive data as if they were interacting with the trusted activity.", "query_type": "nl"} {"_id": "cwe_q_000367", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker, armed with the cipher text and the encryption algorithm used, performs an exhaustive (brute force) search on the key space to determine the key that decrypts the cipher text to obtain the plaintext.", "query_type": "nl"} {"_id": "cwe_q_000368", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker crafts malicious web links and distributes them (via web pages, email, etc.), typically in a targeted manner, hoping to induce users to click on the link and execute the malicious action against some third-party application. If successful, the action embedded in the malicious link will be processed and accepted by the targeted application with the users' privilege level. This type of attack leverages the persistence and implicit trust placed in user session cookies by many web applications today. In such an architecture, once the user authenticates to an application and a session cookie is created on the user's system, all following transactions for that session are authenticated using that cookie including potential actions initiated by an attacker and simply \"riding\" the exis", "query_type": "nl"} {"_id": "cwe_q_000369", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary manipulates the headers and content of an email message by injecting data via the use of delimiter characters native to the protocol.\n\nMany applications allow users to send email messages by filling in fields. For example, a web site may have a link to \"share this site with a friend\" where the user provides the recipient's email address and the web application fills out all the other fields, such as the subject and body. In this pattern, an adversary adds header and body information to an email message by injecting additional content in an input field used to construct a header of the mail message. This attack takes advantage of the fact that RFC 822 requires that headers in a mail message be separated by a carriage return. As a result, an adversary can inject new headers or c", "query_type": "nl"} {"_id": "cwe_q_000370", "text": "Identify the underlying software weakness exploited by this attack behavior: In this attack pattern, an adversary injects a the component packet to one or both ends of a target's connection. The attacker is therefore able to have the target and/or the destination server sever the connection without having to directly filter the traffic between them.", "query_type": "nl"} {"_id": "cwe_q_000371", "text": "Identify the underlying software weakness exploited by this attack behavior: In this attack pattern, the adversary leverages fuzzing to try to identify weaknesses in the system. Fuzzing is a software security and functionality testing method that feeds randomly constructed input to the system and looks for an indication that a failure in response to that input has occurred. Fuzzing treats the system as a black box and is totally free from any preconceptions or assumptions about the system. Fuzzing can help an attacker discover certain assumptions made about user input in the system. Fuzzing gives an attacker a quick way of potentially uncovering some of these assumptions despite not necessarily knowing anything about the internals of the system. These assumptions can then be turned against the system by specially crafting user input that may allow an attacker to ac", "query_type": "nl"} {"_id": "cwe_q_000372", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary performing this type of attack drops packets destined for a target IP address. The aim is to prevent access to the service hosted at the target IP address.", "query_type": "nl"} {"_id": "cwe_q_000373", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker initiates a resource depletion attack where a large number of small XML messages are delivered at a sufficiently rapid rate to cause a denial of service or crash of the target. Transactions such as repetitive SOAP transactions can deplete resources faster than a simple flooding attack because of the additional resources used by the SOAP protocol and the resources necessary to process SOAP messages. The transactions used are immaterial as long as they cause resource utilization on the target. In other words, this is a normal flooding attack augmented by using messages that will require extra processing on the target.", "query_type": "nl"} {"_id": "cwe_q_000374", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker forces the target into a previous state in order to leverage potential weaknesses in the target dependent upon a prior configuration or state-dependent factors. Even in cases where an attacker may not be able to directly control the configuration of the targeted application, they may be able to reset the configuration to a prior state since many applications implement reset functions.\n\nSince these functions are usually intended as emergency features to return an application to a stable configuration if the current configuration degrades functionality, they may not be as strongly secured as other configuration options. The resetting of values is dangerous as it may enable undesired functionality, disable services, or modify access controls. At the very least this is a nuisance a", "query_type": "nl"} {"_id": "cwe_q_000375", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a weakness in the way an application searches for external libraries to manipulate the execution flow to point to an adversary supplied library or code base. This pattern of attack allows the adversary to compromise the application or server via the execution of unauthorized code. An application typically makes calls to functions that are a part of libraries external to the application. These libraries may be part of the operating system or they may be third party libraries. If an adversary can redirect an application's attempts to access these libraries to other libraries that the adversary supplies, the adversary will be able to force the targeted application to execute arbitrary code. This is especially dangerous if the targeted application has enhanced privileges.", "query_type": "nl"} {"_id": "cwe_q_000376", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker forces the encryption level to be lowered, thus enabling a successful attack against the encrypted data.", "query_type": "nl"} {"_id": "cwe_q_000377", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary uses stolen Kerberos tickets to access systems/resources that leverage the Kerberos authentication protocol. The Kerberos authentication protocol centers around a ticketing system which is used to request/grant access to services and to then access the requested services. An adversary can obtain any one of these tickets (e.g. Service Ticket, Ticket Granting Ticket, Silver Ticket, or Golden Ticket) to authenticate to a system/resource without needing the account's credentials. Depending on the ticket obtained, the adversary may be able to access a particular resource or generate TGTs for any account within an Active Directory Domain.", "query_type": "nl"} {"_id": "cwe_q_000378", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary gains access to an application, service, or device with the privileges of an authorized or privileged user by escaping the confines of a virtualized environment. The adversary is then able to access resources or execute unauthorized code within the host environment, generally with the privileges of the user running the virtualized process. Successfully executing an attack of this type is often the first step in executing more complex attacks.", "query_type": "nl"} {"_id": "cwe_q_000379", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary is able to disguise one action for another and therefore trick a user into initiating one type of action when they intend to initiate a different action. For example, a user might be led to believe that clicking a button will submit a query, but in fact it downloads software. Adversaries may perform this attack through social means, such as by simply convincing a victim to perform the action or relying on a user's natural inclination to do so, or through technical means, such as a clickjacking attack where a user sees one interface but is actually interacting with a second, invisible, interface.", "query_type": "nl"} {"_id": "cwe_q_000380", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary manipulates the files in a shared location by adding malicious programs, scripts, or exploit code to valid content. Once a user opens the shared content, the tainted content is executed.", "query_type": "nl"} {"_id": "cwe_q_000382", "text": "Identify the underlying software weakness exploited by this attack behavior: Web Logs Tampering attacks involve an attacker injecting, deleting or otherwise tampering with the contents of web logs typically for the purposes of masking other malicious behavior. Additionally, writing malicious data to log files may target jobs, filters, reports, and other agents that process the logs in an asynchronous attack pattern. This pattern of attack is similar to \"Log Injection-Tampering-Forging\" except that in this case, the attack is targeting the logs of the web server and not the application.", "query_type": "nl"} {"_id": "cwe_q_000383", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a weakness in the server's trust of client-side processing by modifying data on the client-side, such as price information, and then submitting this data to the server, which processes the modified data. For example, eShoplifting is a data manipulation attack against an on-line merchant during a purchasing transaction. The manipulation of price, discount or quantity fields in the transaction message allows the adversary to acquire items at a lower cost than the merchant intended. The adversary performs a normal purchasing transaction but edits hidden fields within the HTML form response that store price or other information to give themselves a better deal. The merchant then uses the modified pricing information in calculating the cost of the selected items.", "query_type": "nl"} {"_id": "cwe_q_000384", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker gets access to the database table where hashes of passwords are stored. They then use a rainbow table of pre-computed hash chains to attempt to look up the original password. Once the original password corresponding to the hash is obtained, the attacker uses the original password to gain access to the system.\n\nA password rainbow table stores hash chains for various passwords. A password chain is computed, starting from the original password, P, via a reduce(compression) function R and a hash function H. A recurrence relation exists where Xi+1 = R(H(Xi)), X0 = P. Then the hash chain of length n for the original password P can be formed: X1, X2, X3, ... , Xn-2, Xn-1, Xn, H(Xn). P and H(Xn) are then stored together in the rainbow table. Constructing the rainbow tables takes a very", "query_type": "nl"} {"_id": "cwe_q_000385", "text": "Identify the underlying software weakness exploited by this attack behavior: Simple Object Access Protocol (SOAP) is used as a communication protocol between a client and server to invoke web services on the server. It is an XML-based protocol, and therefore suffers from many of the same shortcomings as other XML-based protocols. Adversaries can make use of these shortcomings and manipulate the content of SOAP paramters, leading to undesirable behavior on the server and allowing the adversary to carry out a number of further attacks.", "query_type": "nl"} {"_id": "cwe_q_000386", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary may execute a flooding attack using XML messages with the intent to deny legitimate users access to a web service. These attacks are accomplished by sending a large number of XML based requests and letting the service attempt to parse each one. In many cases this type of an attack will result in a XML Denial of Service (XDoS) due to an application becoming unstable, freezing, or crashing.\n\nXDoS is most closely associated with web services, SOAP, and Rest, because remote service requesters can post malicious XML payloads to the service provider designed to exhaust the service provider's memory, CPU, and/or disk space. The main weakness in XDoS is that the service provider generally must inspect, parse, and validate the XML messages to determine routing, workflow, security consi", "query_type": "nl"} {"_id": "cwe_q_000387", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker exploits two layers of weaknesses in server or client software for automated update mechanisms to undermine the integrity of the target code-base. The first weakness involves a failure to properly authenticate a server as a source of update or patch content. This type of weakness typically results from authentication mechanisms which can be defeated, allowing a hostile server to satisfy the criteria that establish a trust relationship. The second weakness is a systemic failure to validate the identity and integrity of code downloaded from a remote location, hence the inability to distinguish malicious code from a legitimate update.\n\nOne predominate type of redirection attack requires DNS spoofing or hijacking of a domain name corresponding to an update server. The target softwa", "query_type": "nl"} {"_id": "cwe_q_000388", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary searches for and invokes interfaces or functionality that the target system designers did not intend to be publicly available. If interfaces fail to authenticate requests, the attacker may be able to invoke functionality they are not authorized for.\n\nAdversaries can also search for undocumented bits on a hardware device, commonly known as \"chicken bits\". These bits are used to enable/disable certain functionality, but are not published. Adversaries can reverse engineer firmware to identify hidden features and change these bits at runtime to achieve malicious behavior.", "query_type": "nl"} {"_id": "cwe_q_000389", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a cryptographic weakness in the signature verification algorithm implementation to generate a valid signature without knowing the key.\n\nSignature verification algorithms are generally used to determine whether a certificate or piece of code (e.g. executable, binary, etc.) possesses a valid signature and can be trusted. If the leveraged algorithm confirms that a valid signature exists, it establishes a foundation of trust that is further conveyed to the end-user when interacting with a website or application. However, if the signature verification algorithm improperly validates the signature, either by not validating the signature at all or by failing to fully validate the signature, it could result in an adversary generating a spoofed signature and being classified as", "query_type": "nl"} {"_id": "cwe_q_000390", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a weakness resulting from using a hashing algorithm with weak collision resistance to generate certificate signing requests (CSR) that contain collision blocks in their \"to be signed\" parts. The adversary submits one CSR to be signed by a trusted certificate authority then uses the signed blob to make a second certificate appear signed by said certificate authority. Due to the hash collision, both certificates, though different, hash to the same value and so the signed blob works just as well in the second certificate. The net effect is that the adversary's second X.509 certificate, which the Certification Authority has never seen, is now signed and validated by that Certification Authority.\n\nAlternatively, the second certificate could be a signing certificate. Thus t", "query_type": "nl"} {"_id": "cwe_q_000391", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary, through a previously installed malicious application, intercepts messages from a trusted Android-based application in an attempt to achieve a variety of different objectives including denial of service, information disclosure, and data injection. An implicit intent sent from a trusted application can be received by any application that has declared an appropriate intent filter. If the intent is not protected by a permission that the malicious application lacks, then the attacker can gain access to the data contained within the intent. Further, the intent can be either blocked from reaching the intended destination, or modified and potentially forwarded along.", "query_type": "nl"} {"_id": "cwe_q_000392", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary may execute an attack on a program that uses a poor Regular Expression(Regex) implementation by choosing input that results in an extreme situation for the Regex. A typical extreme situation operates at exponential time compared to the input size. This is due to most implementations using a Nondeterministic Finite Automaton(NFA) state machine to be built by the Regex algorithm since NFA allows backtracking and thus more complex regular expressions.\n\nThe algorithm builds a finite state machine and based on the input transitions through all the states until the end of the input is reached. NFA engines may evaluate each character in the input string multiple times during the backtracking. The algorithm tries each path through the NFA one by one until a match is found; the malicio", "query_type": "nl"} {"_id": "cwe_q_000393", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary embeds malicious scripts in content that will be served to web browsers. The goal of the attack is for the target software, the client-side browser, to execute the script with the users' privilege level. An attack of this type exploits a programs' vulnerabilities that are brought on by allowing remote hosts to execute code and scripts. Web browsers, for example, have some simple security controls in place, but if a remote attacker is allowed to execute scripts (through injecting them in to user-generated content like bulletin boards) then these controls may be bypassed. Further, these attacks are very difficult for an end user to detect.", "query_type": "nl"} {"_id": "cwe_q_000394", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack targets the encoding of the URL. An adversary can take advantage of the multiple way of encoding an URL and abuse the interpretation of the URL.\n\nA URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An adversary will try to craft an URL with a sequence of special characters which once interpreted b", "query_type": "nl"} {"_id": "cwe_q_000395", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker exploits a weakness in input validation by controlling the format, structure, and composition of data to an input-processing interface. By supplying input of a non-standard or unexpected form an attacker can adversely impact the security of the target.\n\nFor example, using a different character encoding might cause dangerous text to be treated as safe text. Alternatively, the attacker may use certain flags, such as file extensions, to make a target application believe that provided data should be handled using a certain interpreter when the data is not actually of the appropriate type. This can lead to bypassing protection mechanisms, forcing the target to use specific components for input processing, or otherwise causing the user's data to be handled differently than might othe", "query_type": "nl"} {"_id": "cwe_q_000396", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary adds malicious logic, often in the form of a computer virus, to otherwise benign software. This logic is often hidden from the user of the software and works behind the scenes to achieve negative impacts. Many times, the malicious logic is inserted into empty space between legitimate code, and is then called when the software is executed. This pattern of attack focuses on software already fielded and used in operation as opposed to software that is still under development and part of the supply chain.", "query_type": "nl"} {"_id": "cwe_q_000397", "text": "Identify the underlying software weakness exploited by this attack behavior: Inter-component protocols are used to communicate between different software and hardware modules within a single computer. Common examples are: interrupt signals and data pipes. Subverting the protocol can allow an adversary to impersonate others, discover sensitive information, control the outcome of a session, or perform other attacks. This type of attack targets invalid assumptions that may be inherent in implementers of the protocol, incorrect implementations of the protocol, or vulnerabilities in the protocol itself.", "query_type": "nl"} {"_id": "cwe_q_000398", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary uses path manipulation methods to exploit insufficient input validation of a target to obtain access to data that should be not be retrievable by ordinary well-formed requests. A typical variety of this attack involves specifying a path to a desired file together with dot-dot-slash characters, resulting in the file access API or function traversing out of the intended directory structure and into the root file system. By replacing or modifying the expected path information the access function or API retrieves the file desired by the attacker. These attacks either involve the attacker providing a complete path to a targeted file or using control characters (e.g. path separators (/ or \\) and/or dots (.)) to reach desired directories or files.", "query_type": "nl"} {"_id": "cwe_q_000400", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker sends a series of probes to a web application in order to elicit version-dependent and type-dependent behavior that assists in identifying the target. An attacker could learn information such as software versions, error pages, and response headers, variations in implementations of the HTTP protocol, directory structures, and other similar information about the targeted service. This information can then be used by an attacker to formulate a targeted attack plan. While the component is not intended to be damaging (although certain activities, such as network scans, can sometimes cause disruptions to vulnerable applications inadvertently) it may often pave the way for more damaging attacks.", "query_type": "nl"} {"_id": "cwe_q_000401", "text": "Identify the underlying software weakness exploited by this attack behavior: In this attack, the idea is to cause an active filter to fail by causing an oversized transaction. An attacker may try to feed overly long input strings to the program in an attempt to overwhelm the filter (by causing a buffer overflow) and hoping that the filter does not fail securely (i.e. the user input is let into the system unfiltered).", "query_type": "nl"} {"_id": "cwe_q_000402", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker manipulates either egress or ingress data from a client within an application framework in order to change the content of messages. Performing this attack can allow the attacker to gain unauthorized privileges within the application, or conduct attacks such as phishing, deceptive strategies to spread malware, or traditional web-application attacks. The techniques require use of specialized software that allow the attacker to perform adversary-in-the-middle (this attack pattern) communications between the web browser and the remote system. Despite the use of AiTH software, the attack is actually directed at the server, as the client is one node in a series of content brokers that pass information along to the application framework. Additionally, it is not true \"Adversary-in-the-", "query_type": "nl"} {"_id": "cwe_q_000403", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary injects the component into a parser during data processing to produce adverse effects upon the parser such as exhausting system resources and arbitrary code execution.\n\nApplications often need to transform data in and out of serialized data formats, such as XML and YAML, by using a data parser. It may be possible for an adversary to inject data that may have an adverse effect on the parser when it is being processed. By supplying oversized payloads in input vectors that will be processed by the parser, an adversary can cause the parser to consume more resources while processing, causing excessive memory consumption and CPU utilization, and potentially cause execution of arbitrary code. An adversary's goal is to leverage parser failure to their advantage. DoS is most closely as", "query_type": "nl"} {"_id": "cwe_q_000404", "text": "Identify the underlying software weakness exploited by this attack behavior: An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.", "query_type": "nl"} {"_id": "cwe_q_000405", "text": "Identify the underlying software weakness exploited by this attack behavior: This type of attack involves an attacker leveraging meta-characters in email headers to inject improper behavior into email programs. Email software has become increasingly sophisticated and feature-rich. In addition, email applications are ubiquitous and connected directly to the Web making them ideal targets to launch and propagate attacks. As the user demand for new functionality in email applications grows, they become more like browsers with complex rendering and plug in routines. As more email functionality is included and abstracted from the user, this creates opportunities for attackers. Virtually all email applications do not list email header information by default, however the email header contains valuable attacker vectors for the attacker to exploit particularly if the behavio", "query_type": "nl"} {"_id": "cwe_q_000406", "text": "Identify the underlying software weakness exploited by this attack behavior: Some web applications require users to submit information through an ordered sequence of web forms. This is often done if there is a very large amount of information being collected or if information on earlier forms is used to pre-populate fields or determine which additional information the application needs to collect. An attacker who knows the names of the various forms in the sequence may be able to explicitly type in the name of a later form and navigate to it without first going through the previous forms. This can result in incomplete collection of information, incorrect assumptions about the information submitted by the attacker, or other problems that can impair the functioning of the application.", "query_type": "nl"} {"_id": "cwe_q_000407", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary, through a previously installed malicious application, impersonates an expected or routine task in an attempt to steal sensitive information or leverage a user's privileges.\n\nWhen impersonating an expected task, the adversary monitors the task list maintained by the operating system and waits for a specific legitimate task to become active. Once the task is detected, the malicious application launches a new task in the foreground that mimics the user interface of the legitimate task. At this point, the user thinks that they are interacting with the legitimate task that they started, but instead they are interacting with the malicious application. Once the adversary's goal is reached, the malicious application can exit, leaving the original trusted application visible and the a", "query_type": "nl"} {"_id": "cwe_q_000408", "text": "Identify the underlying software weakness exploited by this attack behavior: This attack pattern combines malicious Javascript and a legitimate webpage loaded into a concealed iframe. The malicious Javascript is then able to interact with a legitimate webpage in a manner that is unknown to the user. This attack usually leverages some element of social engineering in that an attacker must convinces a user to visit a web page that the attacker controls.", "query_type": "nl"} {"_id": "cwe_q_000409", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary inserts malicious logic into memory enabling them to achieve a negative impact. This logic is often hidden from the user of the system and works behind the scenes to achieve negative impacts. This pattern of attack focuses on systems already fielded and used in operation as opposed to systems that are still under development and part of the supply chain.", "query_type": "nl"} {"_id": "cwe_q_000410", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary hijacks a privileged thread of execution by injecting malicious code into a running process. By using a privleged thread to do their bidding, adversaries can evade process-based detection that would stop an attack that creates a new process. This can lead to an adversary gaining access to the process's memory and can also enable elevated privileges. The most common way to perform this attack is by suspending an existing thread and manipulating its memory.", "query_type": "nl"} {"_id": "cwe_q_000411", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary inserts invalid characters in identifiers to bypass application filtering of input. Filters may not scan beyond invalid characters but during later stages of processing content that follows these invalid characters may still be processed. This allows the adversary to sneak prohibited commands past filters and perform normally prohibited operations. Invalid characters may include null, carriage return, line feed or tab in an identifier. Successful bypassing of the filter can result in a XSS attack, resulting in the disclosure of web cookies or possibly other results.", "query_type": "nl"} {"_id": "cwe_q_000412", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary gains control of a process that is assigned elevated privileges in order to execute arbitrary code with those privileges. Some processes are assigned elevated privileges on an operating system, usually through association with a particular user, group, or role. If an attacker can hijack this process, they will be able to assume its level of privilege in order to execute their own code.", "query_type": "nl"} {"_id": "cwe_q_000414", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a weakness in authentication to create an access token (or equivalent) that impersonates a different entity, and then associates a process/thread to that that impersonated token. This action causes a downstream user to make a decision or take action that is based on the assumed identity, and not the response that blocks the adversary.", "query_type": "nl"} {"_id": "cwe_q_000415", "text": "Identify the underlying software weakness exploited by this attack behavior: In this attack pattern, the adversary intercepts information transmitted between two third parties. The adversary must be able to observe, read, and/or hear the communication traffic, but not necessarily block the communication or change its content. Any transmission medium can theoretically be sniffed if the adversary can examine the contents between the sender and recipient. the component are similar to Adversary-In-The-Middle attacks (this attack pattern), but are entirely passive. AiTM attacks are predominantly active and often alter the content of the communications themselves.", "query_type": "nl"} {"_id": "cwe_q_000416", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a resource shared between multiple applications, an application pool or hardware pin multiplexing to affect behavior. Resources may be shared between multiple applications or between multiple threads of a single application. Resource sharing is usually accomplished through mutual access to a single memory location or multiplexed hardware pins. If an adversary can manipulate this shared resource (usually by co-opting one of the applications or threads) the other applications or threads using the shared resource will often continue to trust the validity of the compromised shared resource and use it in their calculations. This can result in invalid trust assumptions, corruption of additional data through the normal operations of the other users of the shared resource, or", "query_type": "nl"} {"_id": "cwe_q_000417", "text": "Identify the underlying software weakness exploited by this attack behavior: The use of cryptanalytic techniques to derive cryptographic keys or otherwise effectively defeat cellular encryption to reveal traffic content. Some cellular encryption algorithms such as A5/1 and A5/2 (specified for GSM use) are known to be vulnerable to such attacks and commercial tools are available to execute these attacks and decrypt mobile phone conversations in real-time. Newer encryption algorithms in use by UMTS and LTE are stronger and currently believed to be less vulnerable to these types of attacks. Note, however, that an attacker with a Cellular Rogue Base Station can force the use of weak cellular encryption even by newer mobile devices.", "query_type": "nl"} {"_id": "cwe_q_000418", "text": "Identify the underlying software weakness exploited by this attack behavior: An adversary exploits a sample, demonstration, test, or debug interface that is unintentionally enabled on a production system, with the goal of gleaning information or leveraging functionality that would otherwise be unavailable.\n\nNon-production interfaces are insecure by default and should not be resident on production systems, since they may reveal sensitive information or functionality that should not be known to end-users. However, such interfaces may be unintentionally left enabled on a production system due to configuration errors, supply chain mismanagement, or other pre-deployment activities. Ultimately, failure to properly disable non-production interfaces, in a production environment, may expose a great deal of diagnostic information or functionality to an adversary, which can b", "query_type": "nl"} {"_id": "cwe_q_000419", "text": "Identify the underlying software weakness exploited by this attack behavior: The adversary bypasses input validation by using doubled characters in order to perform a cross-site scripting attack. Some filters fail to recognize dangerous sequences if they are preceded by repeated characters. For example, by doubling the < before a script command, (<