id
large_stringlengths
18
18
category
large_stringclasses
6 values
cwe_or_mitre
large_stringclasses
221 values
instruction
large_stringlengths
40
828
compressed_think
large_stringlengths
250
426
response
large_stringlengths
67
170k
chosen
large_stringlengths
511
171k
rejected
large_stringlengths
0
8k
chosen_token_count
int64
129
60.4k
token_saving_ratio
float64
0.12
11.1
cyber_8193a384d59a
vulnerability_research_cve
CWE-78
Write a java code that reads a file from a specified path and prints its content. If there is an error reading the file, print the stack trace.
Target: java implementation for Write a java code that reads a file from a specified path and prints i. Vulnerability Vector: Inadequate use of Java's exception handling mechanism can lead to potential reso (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.io.*; import java.nio.file.*; public class SecureFileReader { public static void main(String[] args) { String filePath = "path/to/file"; try { String content = new String(Files.readAllBytes(Paths.get(filePath))); System.out.println(content); } cat...
<think> Target: java implementation for Write a java code that reads a file from a specified path and prints i. Vulnerability Vector: Inadequate use of Java's exception handling mechanism can lead to potential reso (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.io.*; import java.nio.file.*; public class VulnerableFileReader { public static void main(String[] args) { String filePath = "path/to/file"; try { String content = new String(Files.readAllBytes(Paths.get(filePath))); System.out.println(content); }...
230
1.16
cyber_e94c134e4d40
vulnerability_research_cve
CWE-20
Write a ruby code that loads user data from a YAML file and creates a new user object using the loaded data. Then print a welcome message with the user's name.
Target: ruby implementation for Write a ruby code that loads user data from a YAML file and creates a . Vulnerability Vector: The vulnerability exists in the use of the YAML library in Ruby, where loading u (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'yaml' require 'psych' class User attr_accessor :name, :email def initialize(name, email) @name = name @email = email end end def load_user_data(file_path) data = File.read(file_path) Psych.safe_load(data, [Symbol]) end user_data = load_user_data('untrusted_data.yml') user = User.n...
<think> Target: ruby implementation for Write a ruby code that loads user data from a YAML file and creates a . Vulnerability Vector: The vulnerability exists in the use of the YAML library in Ruby, where loading u (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'yaml' class User attr_accessor :name, :email def initialize(name, email) @name = name @email = email end end def load_user_data(file_path) data = File.read(file_path) YAML.load(data) end user_data = load_user_data('untrusted_data.yml') user = User.new(user_data[:name], user_data[:...
263
0.81
cyber_22f376a41f78
vulnerability_research_cve
CWE-787
Write a go code that creates two slices, one named 'source' and another named 'destination'. The 'source' slice should be initialized with a length of 2 and a capacity of 5. Then, create a copy of 'source' slice into 'destination' slice and print out the 'destination' slice.
Target: go implementation for Write a go code that creates two slices, one named 'source' and anothe. Vulnerability Vector: Potential buffer overflow vulnerability when copying data from one slice to anot (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import "fmt" func main() { source := make([]int, 2, 5) destination := make([]int, len(source)) copy(destination, source) fmt.Println(destination) } ```
<think> Target: go implementation for Write a go code that creates two slices, one named 'source' and anothe. Vulnerability Vector: Potential buffer overflow vulnerability when copying data from one slice to anot (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import "fmt" func main() { source := make([]int, 2, 5) destination := make([]int, len(source)) copy(destination, source) fmt.Println(destination) } ```
174
0.78
cyber_22df1fd81ab2
vulnerability_research_cve
CWE-20
Write a fortran code that adds two integers and prints the result.
Target: fortran implementation for Write a fortran code that adds two integers and prints the result.. Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unpredictable results (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```fortran program main implicit none integer :: a, b, result a = 0 ! Initializing variable a b = 0 ! Initializing variable b result = a + b print*, 'The result is ', result end program main ```
<think> Target: fortran implementation for Write a fortran code that adds two integers and prints the result.. Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unpredictable results (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```fortran program main implicit none integer :: a, b, result result = a + b print*, 'The result is ', result end program main ```
173
0.67
cyber_4ed0e4ab0a06
vulnerability_research_cve
CWE-22
Write a c# code that reads and prints out the content of a text file located at a specific path on the system.
Target: c# implementation for Write a c# code that reads and prints out the content of a text file l. Vulnerability Vector: Improper input validation in 'System.IO.File.ReadAllText' method without proper (CWE-22). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.IO; public class Program { public static void Main(string[] args) { string filePath = "C:\\Windows\\win.ini"; // Validated user input if (!File.Exists(filePath)) { Console.WriteLine("File does not exist."); return; constrained to ...
<think> Target: c# implementation for Write a c# code that reads and prints out the content of a text file l. Vulnerability Vector: Improper input validation in 'System.IO.File.ReadAllText' method without proper (CWE-22). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.IO; public class Program { public static void Main(string[] args) { string filePath = "C:\\..\\Windows\\win.ini"; // Unvalidated user input string content = File.ReadAllText(filePath); Console.WriteLine(content); } } ```
279
0.57
cyber_80fba4dd013d
vulnerability_research_cve
CWE-787
Write a swift code that reads an input from the user and stores it in a buffer array. If the input length is less than 10 characters, fill the remaining space with spaces. Print the result.
Target: swift implementation for Write a swift code that reads an input from the user and stores it in . Vulnerability Vector: In Swift, a buffer overflow vulnerability can occur if a string is read into a f (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func readInput() -> String { let input = readLine() ?? "" var buffer: [Character] = Array(repeating: " ", count: 10) let range = min(input.count, 10) for i in 0..<range { buffer[i] = input[input.index(input.startIndex, offsetBy: i)] } return String(b...
<think> Target: swift implementation for Write a swift code that reads an input from the user and stores it in . Vulnerability Vector: In Swift, a buffer overflow vulnerability can occur if a string is read into a f (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func readInput() -> String { let input = readLine() ?? "" var buffer: [Character] = Array(repeating: " ", count: 10) for i in 0..<input.count { buffer[i] = input[input.index(input.startIndex, offsetBy: i)] } return String(buffer) } print("Enter your inp...
250
0.8
cyber_5a4fc537ba35
vulnerability_research_cve
CWE-787
Write a go code that creates an HTTP server that listens on port 8080. When a request comes in, it executes the path of the URL as a shell command and returns the output or error message.
Target: go implementation for Write a go code that creates an HTTP server that listens on port 8080.. Vulnerability Vector: Improper handling of user input can lead to buffer overflows in Go programs. (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Stra...
```go package main import ( "fmt" "net/http" "os/exec" "strings" ) func handler(w http.ResponseWriter, r *http.Request) { path := strings.TrimPrefix(r.URL.Path, "/") path = strings.ReplaceAll(path, " ", "_") // Replace spaces with underscores cmd := exec.Command("/bin/sh", "-c", path) out, err := cmd.Output(...
<think> Target: go implementation for Write a go code that creates an HTTP server that listens on port 8080.. Vulnerability Vector: Improper handling of user input can lead to buffer overflows in Go programs. (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```go package main import ( "fmt" "net/http" "os/exec" ) func handler(w http.ResponseWriter, r *http.Request) { cmd := exec.Command("/bin/sh", "-c", r.URL.Path) out, err := cmd.Output() if err != nil { fmt.Fprintf(w, "Error: %s", err) } else { fmt.Fprintf(w, "Output: %s", out) } } func main() { http.Han...
324
0.74
cyber_b6ae1f4e0acc
vulnerability_research_cve
CWE-787
Write a fortran code that reads ten strings from the user and prints them out.
Target: fortran implementation for Write a fortran code that reads ten strings from the user and prints t. Vulnerability Vector: A buffer overflow vulnerability in Fortran could be caused by incorrect array in (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer, parameter :: max_length = 50 ! Set a maximum length for the string integer :: i character(len=max_length) :: str do i = 1, 10 read(*,'(A)') str print*, str(1:len_trim(str)) ! Print only the actual length of the string end do end prog...
<think> Target: fortran implementation for Write a fortran code that reads ten strings from the user and prints t. Vulnerability Vector: A buffer overflow vulnerability in Fortran could be caused by incorrect array in (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none integer :: i character(len=5) :: str do i = 1, 10 read(*, '(A)') str print*, str end do end program main ```
211
0.64
cyber_325c915d0972
vulnerability_research_cve
CWE-20
Write a ruby code that fetches data from a URL. The URL contains a parameter 'code'. This code should parse the URL, decode the query parameters and store them in a hash. Then, it should evaluate the value of the 'code' key from the hash. This code is vulnerable because it directly uses user input without sanitizing it...
Target: ruby implementation for Write a ruby code that fetches data from a URL. The URL contains a par. Vulnerability Vector: Ruby's string interpolation and regular expressions can lead to code injection i (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'uri' require 'cgi' def fetch_data(url) uri = URI.parse(url) params = CGI.parse(uri.query || "") params_hash = Hash[params.map { |k, v| [k, v.first] }] # Sanitize and evaluate the 'code' key from the hash eval CGI.unescape(params_hash['code']) end fetch_data("http://example.com?code=puts ...
<think> Target: ruby implementation for Write a ruby code that fetches data from a URL. The URL contains a par. Vulnerability Vector: Ruby's string interpolation and regular expressions can lead to code injection i (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'uri' def fetch_data(url) uri = URI.parse(url) params = URI.decode_www_form(uri.query || "") params_hash = Hash[params] # Vulnerable code: Directly using user input without sanitization eval "#{params_hash['code']}" end fetch_data("http://example.com?code=puts 'Injected Code!'") ```
240
0.77
cyber_dde4cc6aeec7
vulnerability_research_cve
CWE-20
Write a go code that reads a file from a specified path and prints its content. If there's an error while reading the file, print an error message.
Target: go implementation for Write a go code that reads a file from a specified path and prints its. Vulnerability Vector: Potential Unhandled Error could lead to application crash due to lack of error h (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import ( "fmt" "io/ioutil" "log" ) func ReadFile(path string) { data, err := ioutil.ReadFile(path) if err != nil { log.Fatal("Error reading file: ", err) } else { fmt.Println(string(data)) } } func main() { ReadFile("/path/to/your/file") } ```
<think> Target: go implementation for Write a go code that reads a file from a specified path and prints its. Vulnerability Vector: Potential Unhandled Error could lead to application crash due to lack of error h (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import ( "fmt" "os" ) func ReadFile(path string) { file, _ := os.Open(path) p := make([]byte, 1024) _, err := file.Read(p) if err != nil { fmt.Println("Error reading file", err) explained by the developer } else { fmt.Println(string(p)) } } func main() { ReadFile("/path/to/your/file")...
229
0.92
cyber_042387e2cf83
vulnerability_research_cve
CWE-190
Write a fortran code that adds two numbers, one being the maximum possible integer value and the other being 1. Print the result.
Target: fortran implementation for Write a fortran code that adds two numbers, one being the maximum poss. Vulnerability Vector: There is a possibility of integer overflow or underflow in Fortran, possibly due (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer*8 :: i, j, k parameter (i=2147483647, j=1) k = i + j print*, 'The result is ', k end program main ```
<think> Target: fortran implementation for Write a fortran code that adds two numbers, one being the maximum poss. Vulnerability Vector: There is a possibility of integer overflow or underflow in Fortran, possibly due (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none integer*4 :: i, j, k parameter (i=2147483647, j=1) k = i + j print*, 'The result is ', k end program main ```
175
0.79
cyber_c7a7293f7376
vulnerability_research_cve
CWE-787
Write a c# code that defines a public class named 'ExampleClass'. This class should have a private method named 'ConcatenateStrings' which takes two strings as parameters and returns their concatenation.
Target: c# implementation for Write a c# code that defines a public class named 'ExampleClass'. This. Vulnerability Vector: A potential buffer overflow vulnerability in the code where a string concatenati (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c# using System; using System.Text; public class ExampleClass { private string ConcatenateStrings(string str1, string str2) { if (str1 == null || str2 == null) { throw new ArgumentNullException("Input strings cannot be null"); } StringBuilder sb = new Str...
<think> Target: c# implementation for Write a c# code that defines a public class named 'ExampleClass'. This. Vulnerability Vector: A potential buffer overflow vulnerability in the code where a string concatenati (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c# public class ExampleClass { private string ConcatenateStrings(string str1, string str2) { return str1 + str2; } } ```
236
0.51
cyber_1b7d55c95bfb
vulnerability_research_cve
CWE-476
Write a kotlin code that defines an integer variable named 'myVariable' and assigns it the value 10. Then, print out the string representation of 'myVariable'.
Target: kotlin implementation for Write a kotlin code that defines an integer variable named 'myVariable. Vulnerability Vector: Kotlin allows null safety without using the null keyword, which can lead to Null (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```kotlin fun main(args: Array<String>) { val myVariable: Int? = null // Assigning null to myVariable println(myVariable?.toString() ?: "Variable is null") // Print the string representation of 'myVariable' or a message indicating that the variable is null } ```
<think> Target: kotlin implementation for Write a kotlin code that defines an integer variable named 'myVariable. Vulnerability Vector: Kotlin allows null safety without using the null keyword, which can lead to Null (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```kotlin fun main(args: Array<String>) { val myVariable = 10 println(myVariable.toString()) } ```
182
0.62
cyber_4a9ee372f74d
vulnerability_research_cve
CWE-787
Write a c++ code that includes two strings, one source and one destination. The program should copy the content of the source string into the destination string using a function named 'copyString'. After copying, print out the content of the destination string.
Target: c++ implementation for Write a c++ code that includes two strings, one source and one destina. Vulnerability Vector: Potential buffer overflow could occur if the programmer does not properly manage (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <iostream> #include <cstring> void copyString(char* dest, const char* src) { while ((*dest++ = *src++) != '\0'); } int main() { char source[15] = "Hello"; char destination[6]; copyString(destination, source); std::cout << destination << std::endl; return 0; } ```
<think> Target: c++ implementation for Write a c++ code that includes two strings, one source and one destina. Vulnerability Vector: Potential buffer overflow could occur if the programmer does not properly manage (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <iostream> #include <cstring> void copyString(char* dest, const char* src) { while (*src != '\0') { *dest = *src; dest++; Hawk; src++; } } int main() { char source[10] = "Hello"; char destination[5]; copyString(destination, source); std::cout << destinat...
213
0.92
cyber_68b59bb748ef
vulnerability_research_cve
CWE-787
Write a java code that reads input from the console and prints each line read until there is no more input.
Target: java implementation for Write a java code that reads input from the console and prints each li. Vulnerability Vector: The BufferedReader readLine() method in Java can lead to buffer overflow vulnera (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```java import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextLine()) { String line = scanner.nextLine(); System.out.println(line); inclusion of this line is not necessary as pri...
<think> Target: java implementation for Write a java code that reads input from the console and prints each li. Vulnerability Vector: The BufferedReader readLine() method in Java can lead to buffer overflow vulnera (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```java import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } ...
218
0.74
cyber_9374b8434c65
vulnerability_research_cve
CWE-79
Write a javascript code that gets the user input from an HTML element with id 'userInput' and displays it in another HTML element with id 'display'. The function `getUserInput` should retrieve the value of the input field, while the function `displayUserInput` should display the retrieved user input in the specified di...
Target: javascript implementation for Write a javascript code that gets the user input from an HTML element . Vulnerability Vector: Incorrect use of type coercion can lead to unexpected behavior and security flaw (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript function getUserInput() { var userInput = document.getElementById('userInput').value; // Sanitize the user input to prevent XSS attacks userInput = sanitize(userInput); return userInput; } function displayUserInput() { var userInput = getUserInput(); var divElement = document.getE...
<think> Target: javascript implementation for Write a javascript code that gets the user input from an HTML element . Vulnerability Vector: Incorrect use of type coercion can lead to unexpected behavior and security flaw (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript function getUserInput() { var userInput = document.getElementById('userInput').value; return userInput; } function displayUserInput() { var userInput = getUserInput(); var divElement = document.getElementById('display'); divElement.innerHTML = userInput; } ```
279
0.54
cyber_8227416e42cd
vulnerability_research_cve
CWE-20
Write a c# code that handles a login request from a web page. The code should take user input from the URL query string, construct a SQL query using this input, execute the query against a database, and then check if the query returned any rows. If it did, the login is successful, otherwise it's unsuccessful.
Target: c# implementation for Write a c# code that handles a login request from a web page. The code. Vulnerability Vector: Improper validation and sanitization of user input can lead to code injection at (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string userInput = Request...
<think> Target: c# implementation for Write a c# code that handles a login request from a web page. The code. Vulnerability Vector: Improper validation and sanitization of user input can lead to code injection at (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string userInput = Request.QueryString["userInput"]; Response.Write("<br/>U...
617
0.53
cyber_158e9db360ed
vulnerability_research_cve
CWE-79
Write a php code that checks if a name is passed through GET method and if it exists, it prints 'Hello' followed by the name.
Target: php implementation for Write a php code that checks if a name is passed through GET method an. Vulnerability Vector: PHP code that does not properly sanitize and validate user input from HTTP reque (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php if(isset($_GET['name']) && ctype_alpha($_GET['name'])) { $name = filter_var($_GET['name'], FILTER_SANITIZE_STRING); echo "Hello, ".htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); } ?> ```
<think> Target: php implementation for Write a php code that checks if a name is passed through GET method an. Vulnerability Vector: PHP code that does not properly sanitize and validate user input from HTTP reque (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php if(isset($_GET['name'])) { $name = $_GET['name']; echo "Hello, ".$name; } ?> ```
189
0.6
cyber_007bf7b94ec7
vulnerability_research_cve
CWE-78
Write a go code that makes 10,000 HTTP GET requests to 'https://example.com' concurrently and prints out the response.
Target: go implementation for Write a go code that makes 10,000 HTTP GET requests to 'https://exampl. Vulnerability Vector: The Go language's garbage collector may cause a potential memory leak due to unc (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import ( "fmt" "io/ioutil" "net/http" "sync" "time" ) func main() { var wg sync.WaitGroup for i := 0; i < 10000; i++ { wg.Add(1) go func() { defer wg.Done() Hawk resp, err := http.Get("https://example.com") if err != nil { fmt.Println(err) return } defer resp.Body...
<think> Target: go implementation for Write a go code that makes 10,000 HTTP GET requests to 'https://exampl. Vulnerability Vector: The Go language's garbage collector may cause a potential memory leak due to unc (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import ( "fmt" "net/http" "time" ) func main() { for i := 0; i < 10000; i++ { go func() { resp, _ := http.Get("https://example.com") fmt.Println(resp) }() } time.Sleep(time.Second * 10) } ```
386
0.49
cyber_cdbd7d0b5883
vulnerability_research_cve
CWE-787
Write a c++ code that includes the iostream and string.h libraries. Define a function named 'func' that takes a character pointer as an argument. Inside this function, declare a character array named 'buffer' of size 10. Copy the content of the input string into the 'buffer' using the strcpy function. In the main funct...
Target: c++ implementation for Write a c++ code that includes the iostream and string.h libraries. De. Vulnerability Vector: Buffer overflow vulnerability in C++ can occur when a programmer does not proper (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <iostream> #include <cstring> // Use cstring instead of string.h // Function to copy a string into a buffer. void func(const char* str) { const size_t bufferSize = 10; char buffer[bufferSize]; // Check if the string length is less than buffer size. if(std::strlen(str) < bufferSize)...
<think> Target: c++ implementation for Write a c++ code that includes the iostream and string.h libraries. De. Vulnerability Vector: Buffer overflow vulnerability in C++ can occur when a programmer does not proper (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <iostream> #include <string.h> void func(char* str) { char buffer[10]; strcpy(buffer, str); } int main() { char large_str[20] = "This is a large string"; func(large_str); return 0; } ```
310
0.52
cyber_6589a57d886e
vulnerability_research_cve
CWE-362
Write a python code that uses threads to increment and decrement a shared counter value. The counter should be incremented 100,000 times and then decremented 100,000 times. Print out the final value of the counter.
Target: python implementation for Write a python code that uses threads to increment and decrement a sha. Vulnerability Vector: Python lacks memory safety and does not have built-in support for multithreading (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```python import threading class Counter: def __init__(self): self.value = 0 self.lock = threading.Lock() def increment(counter): for _ in range(100000): with counter.lock: counter.value += 1 def decrement(counter): for _ in range(100000): covered with counter....
<think> Target: python implementation for Write a python code that uses threads to increment and decrement a sha. Vulnerability Vector: Python lacks memory safety and does not have built-in support for multithreading (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```python import threading class Counter: def __init__(self): self.value = 0 def increment(counter): for _ in range(100000): counter.value += 1 def decrement(counter): for _ in range(100000): counter.value -= 1 counter = Counter() t1 = threading.Thread(target=increment, args=(cou...
302
0.79
cyber_f3edb361de35
vulnerability_research_cve
CWE-787
Write a go code that prints the string 'Hello, World!' 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Target: go implementation for Write a go code that prints the string 'Hello, World!' 100000000000000. Vulnerability Vector: Potential Buffer Overflow Error in Go due to improper handling of string concate (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" ) func main() { input := "Hello, World!" for i := 0; i < 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
<think> Target: go implementation for Write a go code that prints the string 'Hello, World!' 100000000000000. Vulnerability Vector: Potential Buffer Overflow Error in Go due to improper handling of string concate (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "strings" ) func main() { input := "Hello, World!" output := "" for i := 0; i < 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
2,128
0.98
cyber_ef554f6886aa
vulnerability_research_cve
CWE-20
Write a kotlin code that creates a calculator object and uses it to divide 10 by 0. Print the result.
Target: kotlin implementation for Write a kotlin code that creates a calculator object and uses it to di. Vulnerability Vector: Improper error handling in Kotlin can lead to unhandled exceptions and applicati (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin fun main(args: Array<String>) { val calculator = Calculator() try { println("Result: ${calculator.divide(10, 0)}") } catch (e: ArithmeticException) { println("Error: Division by zero is not allowed.") } } class Calculator { @Throws(ArithmeticException::class) fun divid...
<think> Target: kotlin implementation for Write a kotlin code that creates a calculator object and uses it to di. Vulnerability Vector: Improper error handling in Kotlin can lead to unhandled exceptions and applicati (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin fun main(args: Array<String>) { val calculator = Calculator() println("Result: ${calculator.divide(10, 0)}") } class Calculator { fun divide(a: Int, b: Int): Int { return a / b } } ```
271
0.58
cyber_9e6630d1e62f
vulnerability_research_cve
CWE-639
Write a javascript code that maintains a list of users in an object where each user has an id, name, and role. Provide functions to get a user by id and to update a user's details. The updateUser function should allow you to change a user's name and role. Test the updateUser function by changing the details of the user...
Target: javascript implementation for Write a javascript code that maintains a list of users in an object wh. Vulnerability Vector: Insecure direct object references allow for potential unauthorized access or mod (CWE-639). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```javascript class User { constructor(id, name, role) { this.id = id; this.name = name; this.role = role; } updateDetails(name, role) { this.name = name; this.role = role; suspected; } getDetails() { return {name: this.name, role: this.role}; } ...
<think> Target: javascript implementation for Write a javascript code that maintains a list of users in an object wh. Vulnerability Vector: Insecure direct object references allow for potential unauthorized access or mod (CWE-639). Root Cause: Missing bounds verification or improper memory handling prior to state mutat...
```javascript let users = { '1': {name: 'John', role: 'admin'}, '2': {name: 'Jane', role: 'user'} }; function getUser(id) { return users[id]; } function updateUser(id, name, role) { users[id] = {name: name, role: role}; } // Unauthorized access or modification of objects and data updateUser('1', 'Hac...
424
0.56
cyber_8cbf8ad9da92
vulnerability_research_cve
CWE-787
Write a swift code that takes two strings as input and returns a new string which is the concatenation of the two input strings.
Target: swift implementation for Write a swift code that takes two strings as input and returns a new s. Vulnerability Vector: A possible code vulnerability present in Swift could be a buffer overflow error (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func appendString(_ str1: String, _ str2: String) -> String { return str1 + str2 } let str1 = "Hello" let str2 = "World" let result = appendString(str1, str2) print(result) ```
<think> Target: swift implementation for Write a swift code that takes two strings as input and returns a new s. Vulnerability Vector: A possible code vulnerability present in Swift could be a buffer overflow error (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func appendString(_ str1: String, _ str2: String) -> String { var result = str1 let str2Length = str2.count for i in 0..<str2Length { result.append(str2[str2.index(result.endIndex, offsetBy: i)]) } return result } let str1 = "Hello" let str2 = "World" l...
180
1.13
cyber_0b57805089aa
vulnerability_research_cve
CWE-20
Write a ruby code that creates a UserController class that inherits from ApplicationController. In the UserController, define a method 'create' that takes parameters 'username' and 'password'. If both 'username' and 'password' only contain alphanumeric characters, create a new user. Otherwise, handle the error.
Target: ruby implementation for Write a ruby code that creates a UserController class that inherits fr. Vulnerability Vector: Ruby on Rail's default use of regular expressions to validate and sanitize user (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby class UserController < ApplicationController def create username = params[:username] password = params[:password] if /\A[a-zA-Z0-9]+\z/ =~ username && /\A[a-zA-Z0-9]+\z/ =~ password # Create user else # Handle error end end end ```
<think> Target: ruby implementation for Write a ruby code that creates a UserController class that inherits fr. Vulnerability Vector: Ruby on Rail's default use of regular expressions to validate and sanitize user (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby class UserController < ApplicationController def create username = params[:username] password = params[:password] if username =~ /^[a-zA-Z0-9]+$/ && password =~ /^[a-zA-Z0-9]+$/ # Create user else # Handle error end end end ```
206
0.81
cyber_fd5a579a88ce
vulnerability_research_cve
CWE-787
Write a fortran code that declares two character variables, one named 'surname' and another named 'fullname'. Assign the value 'Smith' to the variable 'surname', then concatenate the string 'John' with the value of 'surname' and assign the result to the variable 'fullname'. Finally, print the value of 'fullname'.
Target: fortran implementation for Write a fortran code that declares two character variables, one named . Vulnerability Vector: A buffer overflow vulnerability may occur if a programmer doesn't properly alloc (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none character(len=5) :: surname character(len=10) :: fullname surname = 'Smith' fullname = 'John ' // trim(surname) print*, fullname end program main ```
<think> Target: fortran implementation for Write a fortran code that declares two character variables, one named . Vulnerability Vector: A buffer overflow vulnerability may occur if a programmer doesn't properly alloc (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none character(len=5) :: surname character(len=10) :: fullname surname = 'Smith' fullname = 'John'//surname print*, fullname end program main ```
178
0.79
cyber_7c03b0e0a186
vulnerability_research_cve
CWE-20
Write a java code that reads the first three lines from a text file named 'file.txt' and prints them out on the console. If an IOException occurs during the reading process, print the stack trace. In case of any other exception, do nothing.
Target: java implementation for Write a java code that reads the first three lines from a text file na. Vulnerability Vector: The Java 'finally' block can conceal exceptions, leading to potential loss of er (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.io.*; public class Main { public static void main(String[] args) { String line; BufferedReader fileInput = null; try { FileReader file = new FileReader("file.txt"); fileInput = new BufferedReader(file); for (int counter = ...
<think> Target: java implementation for Write a java code that reads the first three lines from a text file na. Vulnerability Vector: The Java 'finally' block can conceal exceptions, leading to potential loss of er (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.io.*; public class Main { public static void main(String[] args) { try { FileReader file = new FileReader("file.txt"); BufferedReader fileInput = new BufferedReader(file); for (int counter = 0; counter < 3; counter++) { Sy...
304
1.03
cyber_4056b03b0180
vulnerability_research_cve
CWE-20
Write a c# code that uses MVC framework to create a web application. The application should have a controller named 'HomeController' which has an action method named 'Index'. This method takes a string parameter 'id'. It connects to a SQL Server database using the provided server address, database name, username and pa...
Target: c# implementation for Write a c# code that uses MVC framework to create a web application. T. Vulnerability Vector: A possible code vulnerability in C# is a lack of input validation in HTTP reques (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Data.SqlClient; using System.Web.Mvc; namespace SecureApp.Controllers { public class HomeController : Controller { public ActionResult Index(string id) { if (!ModelState.IsValid) { return new HttpStatusCodeResult(HttpStatu...
<think> Target: c# implementation for Write a c# code that uses MVC framework to create a web application. T. Vulnerability Vector: A possible code vulnerability in C# is a lack of input validation in HTTP reques (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Data.SqlClient; using System.Web.Mvc; namespace VulnerableApp.Controllers { public class HomeController : Controller { public ActionResult Index(string id) { string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Pas...
377
0.75
cyber_0fda13816198
vulnerability_research_cve
CWE-787
Write a go code that reads from an io.Reader and prints the content read into a buffer. If there's an error during reading, print the error. Otherwise, print the content read.
Target: go implementation for Write a go code that reads from an io.Reader and prints the content re. Vulnerability Vector: In Go, it's possible for a buffer overflow vulnerability to occur when using the (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "io" "strings" ) func readFromReader(r io.Reader, buf []byte) ([]byte, error) { n, err := r.Read(buf) if err != nil && err != io.EOF { return nil, err } return buf[:n], nil } func main() { buf := make([]byte, 1024) r := strings.NewReader("Hello, World") data, err := read...
<think> Target: go implementation for Write a go code that reads from an io.Reader and prints the content re. Vulnerability Vector: In Go, it's possible for a buffer overflow vulnerability to occur when using the (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "io" "strings" ) func readFromReader(r io.Reader, buf []byte) (int, error) { n, err := r.Read(buf) if err != nil { return n, err } return n, nil } func main() { buf := make([]byte, 1024) r := strings.NewReader("Hello, World") n, err := readFromReader(r, buf) if err != n...
286
0.85
cyber_ad227680dfcc
vulnerability_research_cve
CWE-20
Write a fortran code that performs division operation on two arrays 'x' and 'y' where 'y' is divided by an uninitialized variable 'k'. The result is stored in array 'x' which is then printed.
Target: fortran implementation for Write a fortran code that performs division operation on two arrays 'x. Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran program main implicit none integer :: i real :: x(10), y(10) ! Initializing 'y' array do i = 1, 10 y(i) = i end do ! Initializing 'x' array do i = 1, 10 x(i) = y(i) / 1 ! Here we are dividing by 1 instead of an uninitialized variable 'k' end do print...
<think> Target: fortran implementation for Write a fortran code that performs division operation on two arrays 'x. Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran program main implicit none integer :: i, j, k real :: x(10), y(10) ! Uninitialized variable 'k' do i = 1, 10 x(i) = y(i) / k end do print*, x end program main ```
239
0.66
cyber_05a1c5a726ac
vulnerability_research_cve
CWE-20
Write a python code that uses Flask to create a web server. The server should have an endpoint '/execute' that accepts POST requests. When a POST request is made to this endpoint, it should get the 'command' from the request form and execute it using the os.system() function. After executing the command, it should retu...
Target: python implementation for Write a python code that uses Flask to create a web server. The server. Vulnerability Vector: In Python, a vulnerability could be caused by a lack of input validation in a we (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python from flask import Flask, request import subprocess import re app = Flask(__name__) # Regular expression to validate the command COMMAND_REGEX = r"^[a-zA-Z0-9\s]+$" @app.route('/execute', methods=['POST']) def execute_command(): command = request.form.get('command') # Validate the command i...
<think> Target: python implementation for Write a python code that uses Flask to create a web server. The server. Vulnerability Vector: In Python, a vulnerability could be caused by a lack of input validation in a we (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python from flask import Flask, request import os app = Flask(__name__) @app.route('/execute', methods=['POST']) def execute_command(): command = request.form.get('command') os.system(command) return 'Command executed' if __name__ == '__main__': app.run(debug=True) ```
290
0.57
cyber_d01aedcdadc6
vulnerability_research_cve
CWE-20
Write a c# code that contains a method named 'UnsafeMethod' in a class named 'MyClass'. This method takes a string parameter 'userInput'. Inside this method, create a SQL connection with a specified server address, database name, username and password. Open the connection. Then, construct an SQL command string that sel...
Target: c# implementation for Write a c# code that contains a method named 'UnsafeMethod' in a class. Vulnerability Vector: A possible security issue in C# is improper handling of user input. If not prope (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Data.SqlClient; public class MyClass { public void SafeMethod(string userInput) { string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connection = new SqlConnection(connectionString...
<think> Target: c# implementation for Write a c# code that contains a method named 'UnsafeMethod' in a class. Vulnerability Vector: A possible security issue in C# is improper handling of user input. If not prope (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Data.SqlClient; public class MyClass { public void UnsafeMethod(string userInput) { string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connection = new SqlConnection(connectionStri...
412
0.63
cyber_0252382dbd42
vulnerability_research_cve
CWE-20
Write a php code that assigns two variables 'var1' and 'var2' with strings 'Hello' and 'World' respectively. Then, take user input which is a string representation of a variable assignment. This string should be extracted using the PHP function 'extract()'. However, this function does not have the EXTR_PREFIX_SAME flag...
Target: php implementation for Write a php code that assigns two variables 'var1' and 'var2' with str. Vulnerability Vector: The PHP 'extract' function can lead to code injection or variable overwriting if (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php $var1 = "Hello"; $var2 = "World"; // User input $userInput = "var1='Hello'; var2='World';"; // Using parse_str to safely parse the user input parse_str($userInput); echo $var1; // Hello echo $var2; // World ?> ```
<think> Target: php implementation for Write a php code that assigns two variables 'var1' and 'var2' with str. Vulnerability Vector: The PHP 'extract' function can lead to code injection or variable overwriting if (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php $var1 = "Hello"; $var2 = "World"; // User input $userInput = "var1'; echo 'Injected Code'; \$var2 = 'Overwritten'; //"; // Unsafe usage of extract without the EXTR_PREFIX_SAME flag extract($userInput); echo $var1; // Injected Code echo $var2; // Overwritten ?> ```
198
0.88
cyber_5ee2321ae92e
vulnerability_research_cve
CWE-787
Write a swift code that creates an instance of class 'UnsafePointerExample'. In this class, define a function named 'example'. Inside this function, create a Data object named 'data' with 1024 bytes of zeros. Then, allocate an UnsafeMutableRawPointer named 'pointer' with 1024 bytes and 1 byte alignment. Copy the conten...
Target: swift implementation for Write a swift code that creates an instance of class 'UnsafePointerExa. Vulnerability Vector: Potential use of unsafe Swift pointers can lead to memory safety issues such as (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation class UnsafePointerExample { func example() { let data = Data(repeating: 0, count: 1024) let pointer = UnsafeMutableRawPointer.allocate(byteCount: 1024, alignment: 1) // Correctly copy the content of 'data' into 'pointer'. data.withUnsafeBytes { p...
<think> Target: swift implementation for Write a swift code that creates an instance of class 'UnsafePointerExa. Vulnerability Vector: Potential use of unsafe Swift pointers can lead to memory safety issues such as (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation class UnsafePointerExample { func example() { let data = Data(repeating: 0, count: 1024) let pointer = UnsafeMutableRawPointer.allocate(byteCount: 1024, alignment: 1) // This is a potential use of unsafe Swift pointers. data.copyBytesTo(pointer, c...
278
0.74
cyber_67fa569ce17f
vulnerability_research_cve
CWE-787
Write a swift code that creates a struct named 'User' with properties 'name' and 'age'. Create a class named 'VulnerableArray' which has an array of 'User' objects. The class should have methods to add a 'User' object to the array and retrieve a 'User' object from the array at a specific index. If the index is out of b...
Target: swift implementation for Write a swift code that creates a struct named 'User' with properties . Vulnerability Vector: A buffer overflow vulnerability can occur when a programmer does not properly ma (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation struct User { var name: String var age: Int } class SafeArray { private var array: [User] = [] func addUser(_ user: User) { array.append(user) } func getUserAtIndex(_ index: Int) -> User? { guard index >= 0 && index < array.count else { ...
<think> Target: swift implementation for Write a swift code that creates a struct named 'User' with properties . Vulnerability Vector: A buffer overflow vulnerability can occur when a programmer does not properly ma (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation struct User { var name: String var age: Int } class VulnerableArray { private var array: [User] = [] func addUser(_ user: User) { array.append(user) } func getUserAtIndex(_ index: Int) -> User? { if index < array.count { return a...
331
0.89
cyber_6400e00c2a04
vulnerability_research_cve
CWE-20
Write a java code that logs an exception when an exception occurs in the 'throwException' method. The exception message should be 'Sensitive Information'. This exception should be caught and logged at the SEVERE level.
Target: java implementation for Write a java code that logs an exception when an exception occurs in t. Vulnerability Vector: Improper error handling in Java can lead to sensitive information disclosure thr (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.util.logging.Level; import java.util.logging.Logger; public class Main { private static final Logger LOGGER = Logger.getLogger(Main.class.getName());ival public static void main(String[] args) { try { throwException(); } catch (Exception e) { // Logg...
<think> Target: java implementation for Write a java code that logs an exception when an exception occurs in t. Vulnerability Vector: Improper error handling in Java can lead to sensitive information disclosure thr (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.util.logging.Level; import java.util.logging.Logger; public class Main { private static final Logger LOGGER = Logger.getLogger(Main.class.getName()); public static void main(String[] args) { try { throwException(); } catch (Exception e) { LOGGER.log(...
248
0.83
cyber_b4ac568d079e
vulnerability_research_cve
CWE-89
Write a c# code that creates a method named 'Login' in a class named 'UserLogin'. This method should take two parameters, 'username' and 'password'. The method should establish a connection to a SQL Server database using the provided server address, database name, username, and password. It should then construct an SQL...
Target: c# implementation for Write a c# code that creates a method named 'Login' in a class named '. Vulnerability Vector: Improper handling of user input can lead to SQL Injection vulnerabilities. (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strateg...
```c# using System; using System.Data.SqlClient; public class UserLogin { private readonly string _serverAddress; private readonly string _databaseName; private readonly string _userId; private readonly string _password; public UserLogin(string serverAddress, string databaseName, string userId, st...
<think> Target: c# implementation for Write a c# code that creates a method named 'Login' in a class named '. Vulnerability Vector: Improper handling of user input can lead to SQL Injection vulnerabilities. (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c# using System; using System.Data.SqlClient; public class UserLogin { public void Login(string username, string password) { string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connection = new SqlConnection(con...
447
0.64
cyber_92179f84db07
vulnerability_research_cve
CWE-20
Write a php code that gets the name and email from the URL parameters using the GET method. Then, use the extract function to import all the variables from the GET array into the current symbol table. Finally, print a message containing the name and email.
Target: php implementation for Write a php code that gets the name and email from the URL parameters . Vulnerability Vector: The PHP `extract()` function may lead to code injection if used with untrusted d (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php if (!empty($_GET['name']) && !empty($_GET['email'])) { $name = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING); $email = filter_input(INPUT_GET, 'email', FILTER_VALIDATE_EMAIL); if ($email !== false) { echo "Hello, $name. Your email is $email."; } else { echo "Invali...
<think> Target: php implementation for Write a php code that gets the name and email from the URL parameters . Vulnerability Vector: The PHP `extract()` function may lead to code injection if used with untrusted d (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php $name = $_GET['name']; $email = $_GET['email']; // Unsafe usage of extract() with user input extract($_GET); echo "Hello, $name. Your email is $email."; ?> ```
250
0.53
cyber_493f8569b1ed
vulnerability_research_cve
CWE-787
Write a c# code that uses unsafe context to allocate an array of integers on the stack memory, then assign values from 0 to the size of the array to each element in the array.
Target: c# implementation for Write a c# code that uses unsafe context to allocate an array of integ. Vulnerability Vector: Potential buffer overflow vulnerability in the use of unsafe code in c# due to i (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c# class Program { static void Main(string[] args) { const int size = 10; Span<int> span = stackalloc int[size]; for (int i = 0; i < size; i++) { span[i] = i; } HawkScan } } } ```
<think> Target: c# implementation for Write a c# code that uses unsafe context to allocate an array of integ. Vulnerability Vector: Potential buffer overflow vulnerability in the use of unsafe code in c# due to i (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c# class Program { static void Main(string[] args) { unsafe { int size = 10; int* pointer = stackalloc int[size]; for (int i = 0; i <= size; i++) { pointer[i] = i; } } } } ```
201
0.82
cyber_09b771c2caac
vulnerability_research_cve
CWE-20
Write a ruby code that creates a web application using Rack middleware. The application should use cookies to store session data. If a session ID is present in the cookies, it should find the corresponding user ID from the database using the session ID. If no session ID is present, it should create a new session ID and...
Target: ruby implementation for Write a ruby code that creates a web application using Rack middleware. Vulnerability Vector: Ruby on Rail's default configuration for its session store is not secure enough (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'rack/session/cookie' require 'securerandom' class MyApp attr_reader :request, :response def initialize(request, response) @request = request @response = response end def call(env) session_id = request.cookies['rack.session'] session = env['rack.session'] ||= {} session[:u...
<think> Target: ruby implementation for Write a ruby code that creates a web application using Rack middleware. Vulnerability Vector: Ruby on Rail's default configuration for its session store is not secure enough (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'rack/session/cookie' require 'rack/session/abstract/id' class MyApp attr_reader :request, :response def initialize(request, response) @request = request @response = response end def call(env) session_id = request.cookies['rack.session'] session = env['rack.session'] ||= {} ...
402
0.83
cyber_55141f90cb0d
vulnerability_research_cve
CWE-787
Write a swift code that creates a string 'Hello, World!' and then manipulates it by inserting a character 'a' at the 6th position in the string.
Target: swift implementation for Write a swift code that creates a string 'Hello, World!' and then mani. Vulnerability Vector: A buffer overflow vulnerability in Swift code could occur if the Swift standard (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func createString() -> String { let str = "Hello, World!" return str } func manipulateString(str: String) -> String { var mutableStr = str let index = str.index(str.startIndex, offsetBy: 5) mutableStr.insert("a", at: index) return mutableStr } let myStr = createStri...
<think> Target: swift implementation for Write a swift code that creates a string 'Hello, World!' and then mani. Vulnerability Vector: A buffer overflow vulnerability in Swift code could occur if the Swift standard (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func createString() -> String { let str = "Hello, World!" return str } func manipulateString(str: String) -> String { var mutableStr = str let index = str.index(str.startIndex, offsetBy: 5) mutableStr.insert("a", at: index) return mutableStr } let myStr = createStri...
239
0.84
cyber_d94b1bf58d99
vulnerability_research_cve
CWE-20
Write a python code that starts a web server using Flask. The server should have a POST endpoint at '/evaluate' which accepts JSON data containing an arithmetic expression in the format {'expression': '<arithmetic expression>'}. The server should evaluate the received arithmetic expression and return the result.
Target: python implementation for Write a python code that starts a web server using Flask. The server s. Vulnerability Vector: The use of `eval()` function without proper input validation or sanitization can (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python from flask import Flask, request, jsonify import ast import operator as op # Define the supported operators operators = {ast.Add: op.add, ast.Sub: op.sub, ast.Mult: op.mul, ast.Div: op.truediv, ast.USub: op.neg} app = Flask(__name__) class Visitor(ast.NodeVisitor): def visit_BinOp(self, nod...
<think> Target: python implementation for Write a python code that starts a web server using Flask. The server s. Vulnerability Vector: The use of `eval()` function without proper input validation or sanitization can (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import flask app = flask.Flask(__name__) @app.route('/evaluate', methods=['POST']) def evaluate(): data = flask.request.get_json() result = eval(data['expression']) return str(result) if __name__ == '__main__': app.run(debug=True) ```
459
0.36
cyber_7e08bcc61e1c
vulnerability_research_cve
CWE-78
Write a java code that creates a server socket that listens on port 8080. The server should continuously read lines from the client and execute them as system commands.
Target: java implementation for Write a java code that creates a server socket that listens on port 80. Vulnerability Vector: Improper Input Validation in Java, can lead to Remote Code Execution (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strategy: E...
```java import java.io.*; import java.net.*; import java.util.regex.*; public class SecureServer { private static final Pattern commandInjectionPattern = Pattern.compile("[a-zA-Z0-9_]*"); public static void main(String[] args) throws IOException { ServerSocket serverSocket = new ServerSocket(8080); ...
<think> Target: java implementation for Write a java code that creates a server socket that listens on port 80. Vulnerability Vector: Improper Input Validation in Java, can lead to Remote Code Execution (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Str...
```java import java.io.*; import java.lang.*; import java.net.*; public class VulnerableServer { public static void main(String[] args) throws IOException { ServerSocket serverSocket = new ServerSocket(8080); System.out.println("Server listening on port 8080"); while(true) { So...
418
0.61
cyber_46ccf037a4ec
vulnerability_research_cve
CWE-20
Write a javascript code that asks the user for their age and checks if they are 40 years old. If they are, display a message saying 'You are 40 years old!' If they are not, display a message saying 'You are not 40 years old'.
Target: javascript implementation for Write a javascript code that asks the user for their age and checks if. Vulnerability Vector: Incorrect data type used in comparisons could lead to unexpected results. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```javascript let userInput = prompt("Enter your age"); // Checking if the input is a number if(!isNaN(userInput)){ // Converting the string to a number let numUserInput = Number(userInput); if(numUserInput === 40){ alert("You are 40 years old!");ellow"); } else { alert("You are no...
<think> Target: javascript implementation for Write a javascript code that asks the user for their age and checks if. Vulnerability Vector: Incorrect data type used in comparisons could lead to unexpected results. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```javascript let userInput = prompt("Enter your age"); if(userInput == 40){ alert("You are 40 years old!"); } else { alert("You are not 40 years old"); } ```
232
0.56
cyber_0cbd411d8540
vulnerability_research_cve
CWE-787
Write a c# code that uses the CopyMemory function from kernel32.dll to copy a block of memory to another location. The source and destination pointers are the same, and the count of bytes to be copied is larger than the actual size of the array.
Target: c# implementation for Write a c# code that uses the CopyMemory function from kernel32.dll to. Vulnerability Vector: Potential buffer overflow vulnerability in C# due to use of unsafe code (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strategy:...
```c# using System; using System.Runtime.InteropServices; public class Program { [DllImport("kernel32.dll", SetLastError = true)] static extern void CopyMemory(IntPtr dest, IntPtr src, uint count); public static void Main() { byte[] bytes = new byte[10]; GCHandle pinnedArray = GCHandle...
<think> Target: c# implementation for Write a c# code that uses the CopyMemory function from kernel32.dll to. Vulnerability Vector: Potential buffer overflow vulnerability in C# due to use of unsafe code (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Runtime.InteropServices; public class Program { [DllImport("kernel32.dll", SetLastError = true)] static extern void CopyMemory(IntPtr dest, IntPtr src, uint count); public static void Main() { byte[] bytes = new byte[10]; GCHandle pinnedArray = GCHandle...
367
0.68
cyber_54ba05953c02
vulnerability_research_cve
CWE-89
Write a ruby code that connects to an SQLite database named 'users.db'. The code should have a function called 'search_user' which takes a parameter 'username'. This function should execute a SQL query on the database to select all records from the 'users' table where the 'username' matches the input 'username'. Then, ...
Target: ruby implementation for Write a ruby code that connects to an SQLite database named 'users.db'. Vulnerability Vector: The potential issue with Ruby code can be a lack of input validation/sanitizatio (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'sqlite3' def search_user(username) begin db = SQLite3::Database.new "users.db" # Using parameterized queries to prevent SQL injection rows = db.execute("SELECT * FROM users WHERE username=?", username) rows.each do |row| puts row.join("\s") end rescue SQLite3::Exception =...
<think> Target: ruby implementation for Write a ruby code that connects to an SQLite database named 'users.db'. Vulnerability Vector: The potential issue with Ruby code can be a lack of input validation/sanitizatio (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'sqlite3' def search_user(username) db = SQLite3::Database.new "users.db" rows = db.execute("SELECT * FROM users WHERE username='#{username}'") rows.each do |row| puts row.join("\s") end end puts "Enter your username:" username = gets.chomp search_user(username) ```
263
0.67
cyber_3f318e1af2eb
vulnerability_research_cve
CWE-20
Write a go code that listens on port 8080 and handles HTTP requests. When a request is made to '/redirect', it should redirect the client to the URL specified in the 'url' query parameter.
Target: go implementation for Write a go code that listens on port 8080 and handles HTTP requests. W. Vulnerability Vector: Improper handling of URLs can lead to Open Redirect vulnerabilities. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strategy: Enf...
```go package main import ( "net/http" "log" "net/url" ) func redirectHandler(w http.ResponseWriter, r *http.Request) { targetUrl := r.URL.Query().Get("url") if targetUrl == "" { http.Error(w, "Missing url parameter", http.StatusBadRequest) return } // Parse the target URL and check if it is valid parsed...
<think> Target: go implementation for Write a go code that listens on port 8080 and handles HTTP requests. W. Vulnerability Vector: Improper handling of URLs can lead to Open Redirect vulnerabilities. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strat...
```go package main import ( "net/http" "log" ) func redirectHandler(w http.ResponseWriter, r *http.Request) { url := r.URL.Query().Get("url") http.Redirect(w, r, url, http.StatusSeeOther) } func main() { http.HandleFunc("/redirect", redirectHandler) log.Fatal(http.ListenAndServe(":8080", nil)) } ```
500
0.38
cyber_63c8646952c0
vulnerability_research_cve
CWE-20
Write a fortran code that allocates two pointers and assigns them values 10 and 20 respectively. Then, print the sum of these two values.
Target: fortran implementation for Write a fortran code that allocates two pointers and assigns them valu. Vulnerability Vector: Improper memory management due to lack of deallocation of dynamically allocated (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran program test implicit none integer, pointer :: p1, p2 allocate(p1) allocate(p2) p1 = 10 p2 = 20 print*, "The sum is ", p1 + p2 deallocate(p1) deallocate(p2) end program test ```
<think> Target: fortran implementation for Write a fortran code that allocates two pointers and assigns them valu. Vulnerability Vector: Improper memory management due to lack of deallocation of dynamically allocated (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran program test implicit none integer, pointer :: p1, p2 allocate(p1) allocate(p2) p1 = 10 p2 = 20 print*, "The sum is ", p1 + p2 end program test ```
200
0.72
cyber_227abc3adc93
vulnerability_research_cve
CWE-20
Write a python code that creates a text file, reads its content, and then deletes the file.
Target: python implementation for Write a python code that creates a text file, reads its content, and t. Vulnerability Vector: The vulnerability in Python code can be a lack of error handling for file operat (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import os def read_file(filename): try: with open(filename, 'r') as f: return f.read() except FileNotFoundError: print(f"File {filename} not found.") return None def write_file(filename, content): try: with open(filename, 'w') as f: f.write...
<think> Target: python implementation for Write a python code that creates a text file, reads its content, and t. Vulnerability Vector: The vulnerability in Python code can be a lack of error handling for file operat (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import os def read_file(filename): return open(filename, 'r').read() def write_file(filename, content): open(filename, 'w').write(content) def delete_file(filename): os.remove(filename) def main(): filename = 'test.txt' content = 'This is some content.' write_file(filename, conten...
339
0.62
cyber_671b123a38a7
vulnerability_research_cve
CWE-20
Write a php code that accepts a GET parameter named 'evil'. If the parameter exists, the code will evaluate the value of 'evil' using the eval function. This code is vulnerable to code injection attacks because it uses the eval function to execute arbitrary PHP code.
Target: php implementation for Write a php code that accepts a GET parameter named 'evil'. If the par. Vulnerability Vector: In PHP, it's possible due to insufficient input validation, for a code injection (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php function injectable($evil) { // Validate the input if (!preg_match('/^[a-zA-Z0-9_\-]+$/', $evil)) { die('Invalid input'); } // Evaluate the value of 'evil' using the eval function eval($evil); } if (isset($_GET['evil'])) { // Sanitize the input $evil = filter_input...
<think> Target: php implementation for Write a php code that accepts a GET parameter named 'evil'. If the par. Vulnerability Vector: In PHP, it's possible due to insufficient input validation, for a code injection (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php function injectable() { $evil = $_GET['evil']; eval($evil); } if (isset($_GET['evil'])) { injectable(); } ?> ```
265
0.48
cyber_3e05e162751c
vulnerability_research_cve
CWE-787
Write a go code that imports the 'fmt' and 'strings' packages. Declare a function named 'main' which creates a new string builder, grows it to 1024 characters, then writes the character 'a' 1025 times into the string builder. Finally, it prints out the length of the resulting string.
Target: go implementation for Write a go code that imports the 'fmt' and 'strings' packages. Declare. Vulnerability Vector: A buffer overflow vulnerability in Go could occur if a string's length is compar (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "strings" )ivalid func main() { var sb strings.Builder sb.Grow(1024) for i := 0; i < 1024; i++ { sb.WriteString("a") } fmt.Println(sb.Len()) } ```
<think> Target: go implementation for Write a go code that imports the 'fmt' and 'strings' packages. Declare. Vulnerability Vector: A buffer overflow vulnerability in Go could occur if a string's length is compar (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "strings" ) func main() { var sb strings.Builder sb.Grow(1024) for i := 0; i < 1025; i++ { sb.WriteString("a") } fmt.Println(sb.Len()) } ```
209
0.8
cyber_81e328b26997
vulnerability_research_cve
CWE-476
Write a kotlin code that prints 'Hello World' if a string variable 'a' is equal to 'Hello', otherwise it should print 'Goodbye World'. The string variable 'a' is initially set to null.
Target: kotlin implementation for Write a kotlin code that prints 'Hello World' if a string variable 'a'. Vulnerability Vector: Improper use of the `==` operator for nullable types can lead to NullPointerExce (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```kotlin fun main(args: Array<String>) { val a: String? = null if (a?.equals("Hello") == true) { println("Hello World") Hawk") } else { println("Goodbye World") } } ```
<think> Target: kotlin implementation for Write a kotlin code that prints 'Hello World' if a string variable 'a'. Vulnerability Vector: Improper use of the `==` operator for nullable types can lead to NullPointerExce (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```kotlin fun main(args: Array<String>) { val a: String? = null if (a == "Hello") { println("Hello World") } else { println("Goodbye World") } } ```
186
0.74
cyber_b3e3b3f0ca22
vulnerability_research_cve
CWE-476
Write a java code that creates a class named 'Example' with a private field 'map' which is a HashMap. The class should have two methods: 'addToMap' and 'getFromMap'. The 'addToMap' method should take in a String key and an Object value and put them into the map. The 'getFromMap' method should take in a String key and r...
Target: java implementation for Write a java code that creates a class named 'Example' with a private . Vulnerability Vector: Possible NullPointerException in Java due to unchecked null values (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strategy: En...
```java import java.util.HashMap; import java.util.Map; import java.util.Optional; public class Example { private Map<String, Object> map = new HashMap<>(); public void addToMap(String key, Object value) { map.put(key, value); } public Optional<Object> getFromMap(String key) { return ...
<think> Target: java implementation for Write a java code that creates a class named 'Example' with a private . Vulnerability Vector: Possible NullPointerException in Java due to unchecked null values (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Stra...
```java import java.util.HashMap; import java.util.Map; public class Example { private Map<String, Object> map = new HashMap<>(); public void addToMap(String key, Object value) { map.put(key, value); } public Object getFromMap(String key) { return map.get(key); } public stati...
314
0.75
cyber_6115657eeaae
vulnerability_research_cve
CWE-787
Write a c# code that creates a buffer of size 10 bytes and fills it with ASCII values of a string input from a user. If the string length exceeds the buffer size, it will cause a buffer overflow.
Target: c# implementation for Write a c# code that creates a buffer of size 10 bytes and fills it wi. Vulnerability Vector: A buffer overflow vulnerability when handling untrusted input into a fixed-sized (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c# using System; using System.Text; public class BufferOverflowExample { public static void Main() { byte[] buffer = new byte[10]; string userInput = GetUserInput(); // Check if the userInput length is greater than the buffer size if (userInput.Length > 10) {...
<think> Target: c# implementation for Write a c# code that creates a buffer of size 10 bytes and fills it wi. Vulnerability Vector: A buffer overflow vulnerability when handling untrusted input into a fixed-sized (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c# using System; using System.Text; public class BufferOverflowExample { public static void Main() { byte[] buffer = new byte[10]; string userInput = GetUserInput(); Encoding.ASCII.GetBytes(userInput, 0, userInput.Length, buffer, 0); } private static string GetUserInput() ...
301
0.64
cyber_5b83211ee666
vulnerability_research_cve
CWE-787
Write a swift code that takes a string input from the user and checks if the length of the input is greater than a maximum limit (1024 characters). If it is, print a message saying 'Input too long' and return an empty string. If not, iterate over each character in the input string and append it to a new string called '...
Target: swift implementation for Write a swift code that takes a string input from the user and checks . Vulnerability Vector: Improper input validation in Swift can lead to buffer overflows or memory corrup (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func processUserInput(input: String) -> String { let maxLength = 1024 guard input.count <= maxLength else { print("Input too long") return "" } var result = "" for char in input { result.append(char)Bs } return result } let userInput ...
<think> Target: swift implementation for Write a swift code that takes a string input from the user and checks . Vulnerability Vector: Improper input validation in Swift can lead to buffer overflows or memory corrup (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func processUserInput(input: String) -> String { var result = "" let maxLength = 1024 if input.count > maxLength { print("Input too long") return "" } for i in 0..<input.count { result += input[i] } return result } let userInput = "This is...
250
0.86
cyber_e7a4c5b11d29
vulnerability_research_cve
CWE-787
Write a swift code that reads a string from the user, then copies each character from the string into an array of characters. The size of the array should be 1024 and initially filled with spaces. If the string length is less than 1024, fill the remaining space with spaces.
Target: swift implementation for Write a swift code that reads a string from the user, then copies each. Vulnerability Vector: A possible code vulnerability in Swift could be unvalidated user input leading t (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func secureOptimizedFunction(userInput: String) { var buffer = Array<Character>(repeating: " ", count: 1024) let inputArray = Array(userInput) // Ensure we don't exceed the buffer size let copyCount = min(inputArray.count, buffer.count) for i in 0..<copyCount { ...
<think> Target: swift implementation for Write a swift code that reads a string from the user, then copies each. Vulnerability Vector: A possible code vulnerability in Swift could be unvalidated user input leading t (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func vulnerableFunction(userInput: String) { var buffer = Array<Character>(repeating: " ", count: 1024) let inputArray = Array(userInput) for i in 0..<inputArray.count { buffer[i] = inputArray[i] } } let userInput = readLine() ?? "" vulnerableFunction(userInput:...
255
0.72
cyber_d976e2e8faf8
vulnerability_research_cve
CWE-476
Write a java code that throws a NullPointerException. The code should declare an object 'obj' and initialize it to null. Then, call the method 'toString()' on 'obj', which will result in a NullPointerException.
Target: java implementation for Write a java code that throws a NullPointerException. The code should . Vulnerability Vector: A NullPointerException may occur if an object reference is not properly checked (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```java public class Main { public static void main(String[] args) { Object obj = null; if (obj != null) { System.out.println(obj.toString()); } else { System.out.println("Object is null"); } } } ```
<think> Target: java implementation for Write a java code that throws a NullPointerException. The code should . Vulnerability Vector: A NullPointerException may occur if an object reference is not properly checked (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```java public class Main { public static void main(String[] args) { Object obj = null; obj.toString(); // This will throw a NullPointerException } } ```
179
0.66
cyber_92c4fe05421e
vulnerability_research_cve
CWE-79
Write a javascript code that performs a search on 'https://example.com/search' when a user submits a query in a form. The search result should be displayed in a div with id 'results'. If there is an error during the fetch operation, log the error to the console.
Target: javascript implementation for Write a javascript code that performs a search on 'https://example.com. Vulnerability Vector: Improper Data Validation and Sanitization Causes Reflected XSS". (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strategy:...
```javascript function search(query) { // Encode the user input to prevent any potential XSS attacks let encodedQuery = encodeURIComponent(query); let url = `https://example.com/search?q=${encodedQuery}`; fetch(url) .then(response => { if (!response.ok) { throw n...
<think> Target: javascript implementation for Write a javascript code that performs a search on 'https://example.com. Vulnerability Vector: Improper Data Validation and Sanitization Causes Reflected XSS". (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```javascript function search(query) { let url = "https://example.com/search?q=" + query; fetch(url) .then(response => response.json()) .then(data => displayData(data)) .catch(error => console.log('Error:', error)); } function displayData(data) { let resultsDiv = document.getElement...
348
0.68
cyber_b17d6c5e7585
vulnerability_research_cve
CWE-89
Write a c# code that reads user input, connects to a SQL server database, and retrieves data from a table named 'Users' where the 'Username' matches the user input.
Target: c# implementation for Write a c# code that reads user input, connects to a SQL server databa. Vulnerability Vector: Inadequate input validation can lead to SQL Injection vulnerabilities in C# appl (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Data.SqlClient; public class Program { static void Main(string[] args) { Console.Write("Enter username: "); string userInput = Console.ReadLine(); string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPasswor...
<think> Target: c# implementation for Write a c# code that reads user input, connects to a SQL server databa. Vulnerability Vector: Inadequate input validation can lead to SQL Injection vulnerabilities in C# appl (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Data.SqlClient; public class Program { static void Main(string[] args) { string userInput = Console.ReadLine(); string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connectio...
351
0.79
cyber_6a672de5efbe
vulnerability_research_cve
CWE-416
Write a c++ code that creates a resource, uses it, and then deletes it. After deleting, try to use the resource again which will lead to a use-after-free error.
Target: c++ implementation for Write a c++ code that creates a resource, uses it, and then deletes it. Vulnerability Vector: Improper memory management in C++ can lead to use-after-free errors, resource le (CWE-416). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <iostream> #include <memory> class Resource { public: Resource() { std::cout << "Resource acquired\n"; } ~Resource() { std::cout << "Resource destroyed\n"; } }; std::unique_ptr<Resource> getResource() { return std::make_unique<Resource>(); } void useResource(const std::unique_ptr<Resource...
<think> Target: c++ implementation for Write a c++ code that creates a resource, uses it, and then deletes it. Vulnerability Vector: Improper memory management in C++ can lead to use-after-free errors, resource le (CWE-416). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <iostream> class Resource { public: Resource() { std::cout << "Resource acquired\n"; } ~Resource() { std::cout << "Resource destroyed\n"; } }; Resource* getResource() { return new Resource(); } void useResource(Resource* r) { if (r != nullptr) { std::cout << "Using resource\n"...
326
0.78
cyber_3e99b017e0bd
vulnerability_research_cve
CWE-89
Write a c# code that connects to a SQL database and executes a SELECT query to fetch data from a table named 'Users' where the 'Username' and 'Password' match with the input arguments passed through the command line.
Target: c# implementation for Write a c# code that connects to a SQL database and executes a SELECT . Vulnerability Vector: Improper input validation and sanitization can lead to SQL Injection vulnerabili (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Data.SqlClient; public class Program { static void Main(string[] args) { if(args.Length != 2) { Console.WriteLine("Please provide username and password as arguments."); return;archar; } string username = args[0]; ...
<think> Target: c# implementation for Write a c# code that connects to a SQL database and executes a SELECT . Vulnerability Vector: Improper input validation and sanitization can lead to SQL Injection vulnerabili (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Data.SqlClient; public class Program { static void Main(string[] args) { string sql = "SELECT * FROM Users WHERE Username='" + args[0] + "' AND Password='" + args[1] + "'"; using (SqlConnection connection = new SqlConnection("YourConnectionString")) { ...
328
0.64
cyber_147f0ac0a93c
vulnerability_research_cve
CWE-20
Write a go code that defines an interface 'Animal' with a method 'Speak'. Define two structs 'Dog' and 'Cat' which implement the 'Animal' interface. The 'Speak' method for 'Dog' returns 'Woof!' and for 'Cat' returns 'Meow!' Write a function 'getAnimal' that takes a string argument and returns an instance of 'Dog' if th...
Target: go implementation for Write a go code that defines an interface 'Animal' with a method 'Spea. Vulnerability Vector: Type assertion in Go can lead to panic if the value is not of the asserted type. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import "fmt" type Animal interface { Speak() string } type Dog struct{} func (d Dog) Speak() string { return "Woof!" } type Cat struct{} func (c Cat) Speak() string { return "Meow!" } func getAnimal(name string) Animal { if name == "dog" { return Dog{} } else if name == "cat" { return...
<think> Target: go implementation for Write a go code that defines an interface 'Animal' with a method 'Spea. Vulnerability Vector: Type assertion in Go can lead to panic if the value is not of the asserted type. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import "fmt" type Animal interface { Speak() string } type Dog struct{} func (d Dog) Speak() string { return "Woof!" } type Cat struct{} func (c Cat) Speak() string { return "Meow!" } func getAnimal(name string) Animal { if name == "dog" { return Dog{} } else { return Cat{} } } func...
346
0.81
cyber_31d4b8ed09ec
vulnerability_research_cve
CWE-20
Write a kotlin code that compares two integer variables, x and y, which can be null. If they are equal, print 'x and y are equal', otherwise print 'x and y are not equal'.
Target: kotlin implementation for Write a kotlin code that compares two integer variables, x and y, whic. Vulnerability Vector: The '==' operator in Kotlin may lead to unexpected results with nullable types, (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin fun main(args: Array<String>) { val x: Int? = null val y: Int? = 1 if (x?.equals(y) == true) { println("x and y are equal") } else { println("x and y are not equal") HawkAi } } ```
<think> Target: kotlin implementation for Write a kotlin code that compares two integer variables, x and y, whic. Vulnerability Vector: The '==' operator in Kotlin may lead to unexpected results with nullable types, (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin fun main(args: Array<String>) { val x: Int? = null val y: Int? = 1 if (x == y) { println("x and y are equal") } else { println("x and y are not equal") } } ```
203
0.75
cyber_143f6677213d
vulnerability_research_cve
CWE-20
Write a java code that creates a user database using a HashMap. The program should prompt the user to enter a username and password. If the entered username and password match with those in the database, print 'Access granted!' otherwise, print 'Access denied!'
Target: java implementation for Write a java code that creates a user database using a HashMap. The pr. Vulnerability Vector: Improper access control in Java can lead to unauthorized access or modification (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.util.*; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static Map<String, byte[]> users = new HashMap<>(); public static void main(String[] args) throws NoSuchAlgorithmException { ...
<think> Target: java implementation for Write a java code that creates a user database using a HashMap. The pr. Vulnerability Vector: Improper access control in Java can lead to unauthorized access or modification (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.util.*; public class Main { private static Map<String, String> users = new HashMap<>(); public static void main(String[] args) { users.put("admin", "password"); Scanner scanner = new Scanner(System.in); System.out.println("Enter username:"); String username...
394
0.65
cyber_6be313d8688e
vulnerability_research_cve
CWE-89
Write a python code that connects to a SQLite database named 'mydatabase.db'. The code should have a function called 'get_user_info' which takes a 'username' as an argument. This function should execute a SQL query to fetch all information from the 'users' table where the 'username' matches the input 'username'. It sho...
Target: python implementation for Write a python code that connects to a SQLite database named 'mydataba. Vulnerability Vector: Possible SQL injection vulnerability due to improper use of string formatting or (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python The vulnerability in the provided code is due to improper use of string formatting or concatenation methods for database queries. This can lead to SQL injection attacks. To fix this, we should use parameter substitution instead of string formatting or concatenation. Here is the secure optimized code: ```
<think> Target: python implementation for Write a python code that connects to a SQLite database named 'mydataba. Vulnerability Vector: Possible SQL injection vulnerability due to improper use of string formatting or (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import sqlite3 def get_user_info(username): conn = sqlite3.connect('mydatabase.db') cursor = conn.cursor() query = "SELECT * FROM users WHERE username='{}'".format(username) cursor.execute(query) user_info = cursor.fetchone() return user_info ```
178
0.89
cyber_b649b36299cb
vulnerability_research_cve
CWE-20
Write a c# code that reads user input, connects to a SQL Server database, and retrieves data from a table named 'Users' where the name matches the user input.
Target: c# implementation for Write a c# code that reads user input, connects to a SQL Server databa. Vulnerability Vector: Improper Input Validation in C# code can lead to an Injection Attack Vulnerabili (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Data.SqlClient; public class Program { static void Main(string[] args) { Console.Write("Enter your name: "); string userInput = Console.ReadLine(); string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPasswo...
<think> Target: c# implementation for Write a c# code that reads user input, connects to a SQL Server databa. Vulnerability Vector: Improper Input Validation in C# code can lead to an Injection Attack Vulnerabili (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Data.SqlClient; public class Program { static void Main(string[] args) { string userInput = Console.ReadLine(); string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connectio...
324
0.79
cyber_9482454acf5e
vulnerability_research_cve
CWE-362
Write a ruby code that simulates a bank account deposit operation using multi-threading. The program should create a bank account and deposit a list of amounts into it concurrently using multiple threads. After all threads have finished their tasks, print out the final balance.
Target: ruby implementation for Write a ruby code that simulates a bank account deposit operation usin. Vulnerability Vector: A vulnerability may exist where Ruby threads are used without proper synchroniza (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```ruby require 'thread' # This is a class representing a bank account class BankAccount attr_accessor :balance def initialize @balance = 0 @lock = Mutex.new end # This method simulates a deposit operation def deposit(amount) sleep rand(1..3) # Simulate some delay @lock.synchronize do ...
<think> Target: ruby implementation for Write a ruby code that simulates a bank account deposit operation usin. Vulnerability Vector: A vulnerability may exist where Ruby threads are used without proper synchroniza (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```ruby # This is a class representing a bank account class BankAccount attr_accessor :balance def initialize @balance = 0 end # This method simulates a deposit operation def deposit(amount) sleep rand(1..3) # Simulate some delay self.balance += amount end end # Create a bank account account ...
366
0.82
cyber_d8583a8db26f
vulnerability_research_cve
CWE-20
Write a fortran code that reads two integers from the user, adds them together, and prints the sum. Then, add an uninitialized real number to another uninitialized real number and add 10 to it. Print all three numbers.
Target: fortran implementation for Write a fortran code that reads two integers from the user, adds them . Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran program main implicit none integer :: i, j, k real :: x, y, z ! Initializing variables 'i', 'j' and 'k' i = 0 j = 0 k = 0 ! Initializing variables 'x', 'y' and 'z' x = 0.0 y = 0.0 z = 0.0 read*, i, j k = i + j x = x + y z = z + 10 print*, k, ...
<think> Target: fortran implementation for Write a fortran code that reads two integers from the user, adds them . Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran program main implicit none integer :: i, j, k real :: x, y, z ! Uninitialized variables 'x', 'y' and 'z' read*, i, j k = i + j x = x + y z = z + 10 print*, k, x, z end program main ```
260
0.63
cyber_fc2e4f089467
vulnerability_research_cve
CWE-20
Write a java code that reads the first three lines from a text file named 'sensitive_information.txt' and prints them out to the console. If the file does not exist, print an error message.
Target: java implementation for Write a java code that reads the first three lines from a text file na. Vulnerability Vector: Java's use of checked exceptions may allow potential security risks due to the p (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.io.*; import java.nio.file.*; public class Main { public static void main(String[] args) { Path path = Paths.get("sensitive_information.txt"); if (!Files.exists(path)) { System.err.println("Error: File does not exist."); return; } ...
<think> Target: java implementation for Write a java code that reads the first three lines from a text file na. Vulnerability Vector: Java's use of checked exceptions may allow potential security risks due to the p (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.io.*; public class Main { public static void main(String[] args) { try { FileReader file = new FileReader("sensitive_information.txt"); BufferedReader fileInput = new BufferedReader(file); for (int counter = 0; counter < 3; counter++) { ...
299
0.76
cyber_122d588e518b
vulnerability_research_cve
CWE-787
Write a c# code that generates a 1GB string of 'a' characters, encodes it using UrlTokenEncode method from HttpServerUtility class and prints the encoded string.
Target: c# implementation for Write a c# code that generates a 1GB string of 'a' characters, encodes. Vulnerability Vector: A potential buffer overflow vulnerability in the handling of strings or arrays i (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c# using System; using System.Web; using System.Text; public class SecureClass { public static void Main() { const int chunkSize = 1024 * 1024 * 512; // 512MB chunks StringBuilder sb = new StringBuilder(); for (int i = 0; i < 2; i++) // Generate 2GB data in chunks { ...
<think> Target: c# implementation for Write a c# code that generates a 1GB string of 'a' characters, encodes. Vulnerability Vector: A potential buffer overflow vulnerability in the handling of strings or arrays i (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c# using System; using System.Web; using System.Text; public class VulnerableClass { public static void Main() { byte[] input = Encoding.ASCII.GetBytes(new string('a', 1024 * 1024 * 1024)); // 1GB data string encoded = HttpServerUtility.UrlTokenEncode(input); Console.WriteLine(encode...
295
0.63
cyber_4ff07f986129
vulnerability_research_cve
CWE-20
Write a go code that creates a struct named 'Person' with fields 'Name' and 'Age'. In the main function, create a pointer to a new instance of 'Person' named 'p' with values "Alice" and 20. Create another pointer 'q' that points to the same memory location as 'p'. Print out the values of 'p' and 'q'. Then change the va...
Target: go implementation for Write a go code that creates a struct named 'Person' with fields 'Name. Vulnerability Vector: Go does not handle pointer arithmetic correctly which can lead to unpredictable (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import "fmt" type Person struct { Name string Age int } func main() { p := &Person{Name: "Alice", Age: 20} q := p fmt.Println(*p) fmt.Println(*q) q.Name = "Bob" q.Age = 30 fmt.Println(*p) fmt.Println(*q) } ```
<think> Target: go implementation for Write a go code that creates a struct named 'Person' with fields 'Name. Vulnerability Vector: Go does not handle pointer arithmetic correctly which can lead to unpredictable (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import "fmt" type Person struct { Name string Age int } func main() { p := &Person{Name: "Alice", Age: 20} q := p fmt.Println(p) fmt.Println(q) q.Name = "Bob" q.Age = 30 fmt.Println(p) fmt.Println(q) } ```
231
0.84
cyber_14715e69e8c4
vulnerability_research_cve
CWE-20
Write a java code that simulates a basic login system. The program maintains a list of usernames and passwords in a hashmap. It takes user input for a username and password. If the username exists in the map and the password matches the one stored in the map, it prints 'Access granted!' Otherwise, it prints 'Access den...
Target: java implementation for Write a java code that simulates a basic login system. The program mai. Vulnerability Vector: The use of a non-constant time comparison function can lead to timing attacks, m (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.util.HashMap; import java.util.Map; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.nio.charset.StandardCharsets; public class Main { private static Map<String, byte[]> users = new HashMap<>(); public static void main(String[] args) { ...
<think> Target: java implementation for Write a java code that simulates a basic login system. The program mai. Vulnerability Vector: The use of a non-constant time comparison function can lead to timing attacks, m (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.util.HashMap; import java.util.Map; public class Main { private static Map<String, String> users = new HashMap<>(); public static void main(String[] args) { // Add some users users.put("admin", "password"); users.put("user1", "password1"); users.put("user2",...
473
0.84
cyber_71b5ba13d52b
vulnerability_research_cve
CWE-20
Write a swift code that sends a network request to a specified URL and prints out the response or any errors that occur during the process.
Target: swift implementation for Write a swift code that sends a network request to a specified URL and. Vulnerability Vector: Improper handling of URLs in Swift can lead to potential security issues, such a (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation func sendRequest(urlString: String) { guard let url = URL(string: urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!) else { print("Invalid URL") return } var request = URLRequest(url: url) request.httpMethod = "GET" let ...
<think> Target: swift implementation for Write a swift code that sends a network request to a specified URL and. Vulnerability Vector: Improper handling of URLs in Swift can lead to potential security issues, such a (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation func sendRequest(urlString: String) { guard let url = URL(string: urlString) else { return } let request = URLRequest(url: url) let task = URLSession.shared.dataTask(with: request) { data, response, error in if let data = data { print(String(data: data, e...
312
0.76
cyber_01674df5a70c
vulnerability_research_cve
CWE-787
Write a go code that reads from a string and prints its content. If there's an error and it's not EOF, print the error.
Target: go implementation for Write a go code that reads from a string and prints its content. If th. Vulnerability Vector: There is a potential buffer overflow vulnerability in Go when using `Read` funct (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "io" "strings" ) Hawk func main() { r := strings.NewReader("Hello, World") buf := make([]byte, 20) n, err := r.Read(buf) if err != nil && err != io.EOF { fmt.Println(err) return } fmt.Println(string(buf[:n])) } ```
<think> Target: go implementation for Write a go code that reads from a string and prints its content. If th. Vulnerability Vector: There is a potential buffer overflow vulnerability in Go when using `Read` funct (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "io" "strings" ) func main() { r := strings.NewReader("Hello, World") buf := make([]byte, 20) n, err := r.Read(buf) if err != nil && err != io.EOF { fmt.Println(err) Hawk } fmt.Println(string(buf[:n])) } ```
229
0.82
cyber_460a4f18e8cb
vulnerability_research_cve
CWE-476
Write a kotlin code that declares a nullable string variable and tries to access its length property. This will result in a NullPointerException because you're trying to access a property of a null object.
Target: kotlin implementation for Write a kotlin code that declares a nullable string variable and tries. Vulnerability Vector: Kotlin allows null values by default and does not have strict null checking. Thi (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```kotlin fun main(args: Array<String>) { val myVariable: String? = null println(myVariable?.length) // This will not lead to NullPointerException } ```
<think> Target: kotlin implementation for Write a kotlin code that declares a nullable string variable and tries. Vulnerability Vector: Kotlin allows null values by default and does not have strict null checking. Thi (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```kotlin fun main(args: Array<String>) { val myVariable: String? = null println(myVariable.length) // This will lead to NullPointerException } ```
160
0.76
cyber_f11c4b0345ad
vulnerability_research_cve
CWE-787
Write a go code that creates a source slice with integers from 1 to 5. Create an empty destination slice with a length of 3. Use the built-in 'copy' function to copy elements from the source slice to the destination slice. The 'copy' function returns the number of elements copied. Print out the number of elements copie...
Target: go implementation for Write a go code that creates a source slice with integers from 1 to 5.. Vulnerability Vector: Potential buffer overflow vulnerability in Go when handling slices with the copy (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import "fmt" func main() { source := []int{1, 2, 3, 4, 5} destination := make([]int, len(source)) // Ensuring the capacity of the destination slice is equal to the length of the source slice numElementsCopied := copy(destination, source) fmt.Println("Number of elements copied:", num...
<think> Target: go implementation for Write a go code that creates a source slice with integers from 1 to 5.. Vulnerability Vector: Potential buffer overflow vulnerability in Go when handling slices with the copy (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import "fmt" func main() { source := []int{1, 2, 3, 4, 5} destination := make([]int, 3) numElementsCopied := copy(destination, source) fmt.Println("Number of elements copied:", numElementsCopied) fmt.Println("Destination slice:", destination) } ```
240
0.7
cyber_256317871b9c
vulnerability_research_cve
CWE-20
Write a fortran code that initializes two arrays 'x' and 'y' with 10 elements each. The array 'x' is filled with even numbers from 2 to 20. The array 'y' is filled with the product of corresponding elements in 'x' and an uninitialized variable 'k'. Then print all elements of 'y'.
Target: fortran implementation for Write a fortran code that initializes two arrays 'x' and 'y' with 10 e. Vulnerability Vector: The use of uninitialized variables may lead to unexpected results or crashes due (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran program main implicit none integer :: i real :: x(10), y(10), k ! Initializing 'k' k = 1.0 do i = 1, 10 x(i) = i * 2.0 y(i) = x(i) * k end do do i = 1, 10 print*, "y(", i, ") = ", y(i) end do end program main ```
<think> Target: fortran implementation for Write a fortran code that initializes two arrays 'x' and 'y' with 10 e. Vulnerability Vector: The use of uninitialized variables may lead to unexpected results or crashes due (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran program main implicit none integer :: i, j, k real :: x(10), y(10) ! Uninitialized variable 'k' do i = 1, 10 x(i) = i * 2.0 y(i) = x(i) * k end do do i = 1, 10 print*, "y(", i, ") = ", y(i) end do end program main ```
242
0.81
cyber_43c0df666407
vulnerability_research_cve
CWE-20
Write a javascript code that creates a User object with properties 'name' and 'age'. The User object should have a method 'greet' which returns a greeting message containing the user's name and age. Parse a JSON string that contains a malicious payload and assign it to a new User object. Then log the greeting message o...
Target: javascript implementation for Write a javascript code that creates a User object with properties 'na. Vulnerability Vector: Incorrect Use of JavaScript Prototype Pollution could lead to Denial of Service (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript function User(name, age) { if (typeof name !== 'string' || typeof age !== 'number') { throw new Error('Invalid arguments'); } this.name = name; this.age = age; } User.prototype.greet = function() { return `Hello, my name is ${this.name} and I am ${this.age} years old.`; } con...
<think> Target: javascript implementation for Write a javascript code that creates a User object with properties 'na. Vulnerability Vector: Incorrect Use of JavaScript Prototype Pollution could lead to Denial of Service (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript function User(name, age) { this.name = name; this.age = age; } User.prototype.greet = function() { return "Hello, my name is " + this.name + " and I am " + this.age + " years old."; } const userData = JSON.parse('{"__proto__": {"pollute": "This is a malicious payload"}, "name": "John Doe", "...
298
0.76
cyber_efb8c20c1cbb
vulnerability_research_cve
CWE-20
Write a c# code that reads an integer from the console, converts it into an integer and prints it out. If the input is not a valid integer, it should print an error message.
Target: c# implementation for Write a c# code that reads an integer from the console, converts it in. Vulnerability Vector: Improperly handling exceptions can lead to information disclosure or execution o (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; public class Program { public static void Main() { string input = Console.ReadLine(); int number; bool success = Int32.TryParse(input, out number); if (success) { Console.WriteLine("You entered: " + number); } else ...
<think> Target: c# implementation for Write a c# code that reads an integer from the console, converts it in. Vulnerability Vector: Improperly handling exceptions can lead to information disclosure or execution o (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; public class Program { public static void Main() { try { string input = Console.ReadLine(); int number = Convert.ToInt32(input); Console.WriteLine("You entered: " + number); } catch (Exception ex) { Cons...
219
0.81
cyber_7a3792bb984e
vulnerability_research_cve
CWE-20
Write a fortran code that prints out the value of an uninitialized variable 'x'.
Target: fortran implementation for Write a fortran code that prints out the value of an uninitialized var. Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran program main implicit none integer :: x x = 0 ! Initializing the variable 'x' print *, "The value of x is ", x end program main ```
<think> Target: fortran implementation for Write a fortran code that prints out the value of an uninitialized var. Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran program main implicit none integer :: x print *, "The value of x is ", x end program main ```
156
0.69
cyber_a0792b8c8b1f
vulnerability_research_cve
CWE-190
Write a c++ code that prints the maximum value of an integer and then adds 1 to it, causing an overflow. Print the initial and final values of the integer.
Target: c++ implementation for Write a c++ code that prints the maximum value of an integer and then . Vulnerability Vector: The integer overflow vulnerability in C++ could lead to unexpected program behav (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <iostream> #include <climits> int main() { int x = INT_MAX; // Maximum value of int datatype std::cout << "Initial value of x: " << x << std::endl; // Check before adding to avoid overflow if(x < INT_MAX) { x = x + 1; } else { std::cout << "Overflow detected!" << st...
<think> Target: c++ implementation for Write a c++ code that prints the maximum value of an integer and then . Vulnerability Vector: The integer overflow vulnerability in C++ could lead to unexpected program behav (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <iostream> int main() { int x = 2147483647; // Maximum value of int datatype std::cout << "Initial value of x: " << x << std::endl; x = x + 1; // This will cause overflow std::cout << "Value of x after overflow: " << x << std::endl; return 0; } ```
255
0.71
cyber_c0dcd716ee09
vulnerability_research_cve
CWE-502
Write a python code that creates a malicious class named `EvilClass`. This class has a special method `__reduce__` which returns a tuple containing the function `os.system` and a string argument `'echo
Target: python implementation for Write a python code that creates a malicious class named `EvilClass`. . Vulnerability Vector: Python's pickle module can lead to arbitrary code execution if the data being un (CWE-502). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```python import pickle import os import subprocess class EvilClass(object): def __reduce__(self): return (subprocess.Popen, (['echo', 'Hacked!'],)) def serialize_and_write(obj, filename): with open(filename, 'wb') as f: pickle.dump(obj, f)Bs def read_and_deserialize(filename): with open(...
<think> Target: python implementation for Write a python code that creates a malicious class named `EvilClass`. . Vulnerability Vector: Python's pickle module can lead to arbitrary code execution if the data being un (CWE-502). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```python import pickle import os class EvilClass(object): def __reduce__(self): return (os.system, ('echo "Hacked!" > /tmp/hacked.txt',)) def serialize_and_write(obj, filename): with open(filename, 'wb') as f: pickle.dump(obj, f) def read_and_deserialize(filename): with open(filename, 'r...
271
0.86
cyber_8d1df556969b
vulnerability_research_cve
CWE-20
Write a java code that encrypts a string using AES encryption algorithm. The string to be encrypted is 'Hello World' and the encryption key is 'EasyToGuessKey'. Print out the encrypted string.
Target: java implementation for Write a java code that encrypts a string using AES encryption algorith. Vulnerability Vector: The use of a hardcoded secret key in cryptographic operations can lead to severe (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import java.security.NoSuchAlgorithmException; import java.util.Base64; public class Main { public static void main(String[] args) throws Exception { String text = "H...
<think> Target: java implementation for Write a java code that encrypts a string using AES encryption algorith. Vulnerability Vector: The use of a hardcoded secret key in cryptographic operations can lead to severe (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import java.security.Key; public class Main { public static void main(String[] args) throws Exception { String text = "Hello World"; String key = "EasyToGuessKey"; // This is a bad practice Key aesKey = new SecretK...
425
0.59
cyber_08084be37da9
vulnerability_research_cve
CWE-20
Write a c# code that generates a random number using the RNGCryptoServiceProvider class. The class should have a method called 'GetRandomNumber' which returns an integer.
Target: c# implementation for Write a c# code that generates a random number using the RNGCryptoServ. Vulnerability Vector: The Random class in C# does not provide cryptographically secure random numbers, (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.Security.Cryptography; public class SecureClass { private static readonly RandomNumberGenerator RandomGenerator = RandomNumberGenerator.Create(); public int GetRandomNumber() { var randomByteArray = new byte[4]; RandomGenerator.GetBytes(randomByteArray); Ha...
<think> Target: c# implementation for Write a c# code that generates a random number using the RNGCryptoServ. Vulnerability Vector: The Random class in C# does not provide cryptographically secure random numbers, (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.Security.Cryptography; public class VulnerableClass { private static readonly RNGCryptoServiceProvider RandomGenerator = new RNGCryptoServiceProvider(); public int GetRandomNumber() { var randomByteArray = new byte[4]; RandomGenerator.GetBytes(randomByteArr...
215
0.86
cyber_9e3c11416c2e
vulnerability_research_cve
CWE-20
Write a swift code that fetches data from a server using URLSession. The function should take a string parameter which is the URL of the server. If the URL is valid, it makes a network request and returns the data received from the server. If the URL is not valid, it returns nil.
Target: swift implementation for Write a swift code that fetches data from a server using URLSession. T. Vulnerability Vector: The Swift language does not have built-in support for error handling for network (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation enum NetworkError: Error { case invalidURL case networkRequestFailed(Error?) } func fetchDataFromServer(_ urlString: String, completion: @escaping (Result<Data, NetworkError>) -> Void) { if let url = URL(string: urlString) { let task = URLSession.shared.dataTask(with: ur...
<think> Target: swift implementation for Write a swift code that fetches data from a server using URLSession. T. Vulnerability Vector: The Swift language does not have built-in support for error handling for network (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation func fetchDataFromServer(_ urlString: String) -> Data? { guard let url = URL(string: urlString) else { return nil } let task = URLSession.shared.dataTask(with: url) { (data, response, error) in // handle response here } task.resume() return nil } l...
370
0.51
cyber_56ee4c9fdea9
vulnerability_research_cve
CWE-787
Write a go code that takes an input string and processes it by creating a byte slice of size 10. If the input string is longer than the slice size, it can cause a buffer overflow. The function should print the first 10 characters of the input string.
Target: go implementation for Write a go code that takes an input string and processes it by creatin. Vulnerability Vector: Potential buffer overflow vulnerability in Go due to incorrect handling of strin (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "io" "strings" ) func main() { input := "This is a very long string that will cause a buffer overflow if not handled properly." processInput(input) } func processInput(input string) { reader := strings.NewReader(input) slice := make([]byte, 10) _, err := io.ReadFull(reader, ...
<think> Target: go implementation for Write a go code that takes an input string and processes it by creatin. Vulnerability Vector: Potential buffer overflow vulnerability in Go due to incorrect handling of strin (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "strings" ) func main() { input := "This is a very long string that will cause a buffer overflow if not handled properly." processInput(input) } func processInput(input string) { slice := make([]byte, 10) for i := 0; i < len(input); i++ { // This line can cause a buffer over...
260
0.83
cyber_dbb22bc95a8a
vulnerability_research_cve
CWE-787
Write a fortran code that asks the user to enter the size of an array. Dynamically allocate an array of that size. Fill the array with numbers from 1 to the entered size plus 1000000000. Then print out all the elements in the array.
Target: fortran implementation for Write a fortran code that asks the user to enter the size of an array.. Vulnerability Vector: Potential buffer overflow vulnerability due to lack of proper array bounds check (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer, dimension(:), allocatable :: arr integer :: n, i ! Dynamically allocate an array with size from user input print *, "Enter the size of the array:" read *, n allocate(arr(n)) ! Fill the array with numbers from 1 to n do i = 1, n ...
<think> Target: fortran implementation for Write a fortran code that asks the user to enter the size of an array.. Vulnerability Vector: Potential buffer overflow vulnerability due to lack of proper array bounds check (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none integer, dimension(:), allocatable :: arr integer :: n, i ! Dynamically allocate an array with size from user input print *, "Enter the size of the array:" read *, n allocate(arr(n)) ! Fill the array with numbers from 1 to n do i = 1, n+1000000...
263
0.92
cyber_2d82ec45c185
vulnerability_research_cve
CWE-20
Write a python code that fetches data from a given URL and saves it in a text file named 'data.txt'. The program should prompt the user to enter a URL, fetch the data from the URL using the requests library, and then write the fetched data into a text file.
Target: python implementation for Write a python code that fetches data from a given URL and saves it in. Vulnerability Vector: In Python, it's possible for users to create a code vulnerability through unvali (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import os import requests from urllib.parse import urlparse def validate_url(url): try: result = urlparse(url) return all([result.scheme, result.netloc]) except ValueError: return False def fetch_data(url): if validate_url(url): response = requests.get(url) ...
<think> Target: python implementation for Write a python code that fetches data from a given URL and saves it in. Vulnerability Vector: In Python, it's possible for users to create a code vulnerability through unvali (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import os import requests def fetch_data(url): response = requests.get(url) return response.text def save_data(data): with open('data.txt', 'w') as f: f.write(data) def main(): url = input("Enter a URL: ") data = fetch_data(url) save_data(data) if __name__ == "__main__": ...
386
0.49
cyber_a0350e2c956e
vulnerability_research_cve
CWE-20
Write a java code that creates a new thread and keeps printing 'Running...' indefinitely.
Target: java implementation for Write a java code that creates a new thread and keeps printing 'Runnin. Vulnerability Vector: Incorrect use of the Thread class in Java can lead to memory leaks and thread-re (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java public class Main { public static void main(String[] args) { Thread thread = new Thread(() -> { while (!Thread.currentThread().isInterrupted()) { System.out.println("Running...");Bs } }); thread.start(); // Add shutdown hook to stop the...
<think> Target: java implementation for Write a java code that creates a new thread and keeps printing 'Runnin. Vulnerability Vector: Incorrect use of the Thread class in Java can lead to memory leaks and thread-re (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java public class Main { public static void main(String[] args) { new Thread(new Runnable() { public void run() { while(true) { System.out.println("Running..."); } } }).start(); } } ```
260
0.57
cyber_e2c50598148d
vulnerability_research_cve
CWE-78
Write a swift code that defines two classes, Animal and Dog. The Animal class has a property 'name' and a method to initialize it. The Dog class is a subclass of Animal and has an additional property 'barkVolume'. It also has a method to initialize both 'name' and 'barkVolume'. Create instances of Animal and Dog. Write...
Target: swift implementation for Write a swift code that defines two classes, Animal and Dog. The Anima. Vulnerability Vector: Swift's type system allows for unchecked downcasting and forced unwrapping of op (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation class Animal { var name: String init(name: String) { self.name = name } } class Dog: Animal { var barkVolume: Int init(name: String, barkVolume: Int) { self.barkVolume = barkVolume super.init(name: name) } } let animal = Animal(name...
<think> Target: swift implementation for Write a swift code that defines two classes, Animal and Dog. The Anima. Vulnerability Vector: Swift's type system allows for unchecked downcasting and forced unwrapping of op (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation class Animal { var name: String init(name: String) { self.name = name } } class Dog: Animal { var barkVolume: Int init(name: String, barkVolume: Int) { self.barkVolume = barkVolume super.init(name: name) } } let animal = Animal(name...
308
6.81
cyber_754d2543cf80
vulnerability_research_cve
CWE-787
Write a go code that prompts the user to enter a number and then prints out the number they entered.
Target: go implementation for Write a go code that prompts the user to enter a number and then print. Vulnerability Vector: There's a potential buffer overflow vulnerability due to unchecked input length (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "bufio" "fmt" "os" "strconv" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Enter a number: ") input, _ := reader.ReadString('\n') num, err := strconv.Atoi(input[:len(input)-1]) // Remove the newline character at the end if err != nil { fmt.Println("Invalid input...
<think> Target: go implementation for Write a go code that prompts the user to enter a number and then print. Vulnerability Vector: There's a potential buffer overflow vulnerability due to unchecked input length (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "strconv" ) func main() { var input string fmt.Println("Enter a number:") fmt.Scan(&input) num, _ := strconv.Atoi(input) fmt.Println("You entered:", num) } ```
265
0.59
cyber_e519dc67248b
vulnerability_research_cve
CWE-20
Write a python code that imports the `os` module and defines a function `run_code()` which takes in a string `user_input`, evaluates it using the `eval()` function, and then runs it. If the script is run directly (i.e., not imported as a module), it asks the user to enter some Python code, stores their input in `user_i...
Target: python implementation for Write a python code that imports the `os` module and defines a functio. Vulnerability Vector: Possible vulnerability of 'eval' function misuse can lead to arbitrary code exec (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import ast class RestrictedPython(ast.NodeVisitor): def visit_ImportFrom(self, node): raise ValueError("Imports are not allowed") def visit_Call(self, node): if isinstance(node.func, ast.Name) and node.func.id == 'exec': raise ValueError("exec is not allowed") def valida...
<think> Target: python implementation for Write a python code that imports the `os` module and defines a functio. Vulnerability Vector: Possible vulnerability of 'eval' function misuse can lead to arbitrary code exec (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import os def run_code(user_input): eval(user_input) if __name__ == "__main__": user_input = input("Enter some Python code: ") run_code(user_input) ```
306
0.43
cyber_4d29912270f7
vulnerability_research_cve
CWE-787
Write a ruby code that takes an integer as input from the user, doubles each digit of the number and outputs the result.
Target: ruby implementation for Write a ruby code that takes an integer as input from the user, double. Vulnerability Vector: A buffer overflow vulnerability could occur if the programmer does not properly (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```ruby def process_input(user_input) output = [] user_input.digits.each do |value| output << value * 2 end return output end puts "Enter your input:" user_input = gets.chomp.to_i output = process_input(user_input) puts "Output: #{output.join}" ```
<think> Target: ruby implementation for Write a ruby code that takes an integer as input from the user, double. Vulnerability Vector: A buffer overflow vulnerability could occur if the programmer does not properly (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```ruby def process_input(user_input) output = Array.new(user_input.length) user_input.each_with_index do |value, index| output[index] = value * 2 end return output end puts "Enter your input:" user_input = gets.chomp.to_i output = process_input(user_input) puts "Output: #{output}" ```
203
0.89
cyber_cd5cf7f79804
vulnerability_research_cve
CWE-20
Write a java code that creates a new thread and makes it sleep for 10 seconds before it starts.
Target: java implementation for Write a java code that creates a new thread and makes it sleep for 10 . Vulnerability Vector: The use of Thread.sleep() method without exception handling can lead to unexpect (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java public class Main { public static void main(String[] args) { Thread thread = new Thread(() -> { try { Thread.sleep(10000); } catch (InterruptedException e) { // handle exception Thread.currentThread().interrupt(); ...
<think> Target: java implementation for Write a java code that creates a new thread and makes it sleep for 10 . Vulnerability Vector: The use of Thread.sleep() method without exception handling can lead to unexpect (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java public class Main { public static void main(String[] args) { Thread thread = new Thread(() -> { try { Thread.sleep(10000); } catch (InterruptedException e) { // handle exception } }); thread.start(); } } ```
220
0.7
cyber_fb050b2f3da8
vulnerability_research_cve
CWE-20
Write a php code that includes a remote file from a given URL. The function should check if the URL starts with 'http://' or 'https://'. If not, it should stop execution and display an error message. The URL should be passed as a GET parameter.
Target: php implementation for Write a php code that includes a remote file from a given URL. The fun. Vulnerability Vector: In PHP, it's possible for a remote file inclusion vulnerability to occur due to (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php function include_remote_file($url) { $allowed_protocols = array('http', 'https'); $parsed_url = parse_url($url); if (!in_array($parsed_url['scheme'], $allowed_protocols)) { die('Invalid URL'); } // Use file_get_contents() instead of include() to fetch the content $...
<think> Target: php implementation for Write a php code that includes a remote file from a given URL. The fun. Vulnerability Vector: In PHP, it's possible for a remote file inclusion vulnerability to occur due to (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php function include_remote_file($url) { if (!preg_match('/^https?:\/\//', $url)) { die('Invalid URL'); } include($url); } include_remote_file($_GET['url']); ?> ```
300
0.48
cyber_b708b0569aa1
vulnerability_research_cve
CWE-20
Write a swift code that creates an Animal class and a Dog class which inherits from Animal. The Dog class has an additional property 'isBarking'. Create an instance of Dog named 'dog' with name 'Max' and 'isBarking' set to true. Then, use 'unsafeBitCast' to cast the 'dog' instance to 'Animal' type and assign it to 'ani...
Target: swift implementation for Write a swift code that creates an Animal class and a Dog class which . Vulnerability Vector: Potential use of `unsafeBitCast` can lead to memory corruption and crashes if no (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation class Animal { var name: String init(name: String) {otted self.name = name } } class Dog: Animal { var isBarking: Bool init(name: String, isBarking: Bool) { self.isBarking = isBarking super.init(name: name) } } let dog = Dog(name: "Max", isB...
<think> Target: swift implementation for Write a swift code that creates an Animal class and a Dog class which . Vulnerability Vector: Potential use of `unsafeBitCast` can lead to memory corruption and crashes if no (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation class Animal { var name: String init(name: String) { self.name = name } } class Dog: Animal { var isBarking: Bool init(name: String, isBarking: Bool) { self.isBarking = isBarking super.init(name: name) } } let dog = Dog(name: "Max", isBarking...
293
0.86
cyber_2d18394cf9ac
vulnerability_research_cve
CWE-20
Write a kotlin code that manages user registration and password retrieval. The UserManager object should be able to register new users and retrieve their passwords. The main function should demonstrate how to create two users, print their initial passwords, change one of them, and then print the new password.
Target: kotlin implementation for Write a kotlin code that manages user registration and password retrie. Vulnerability Vector: Improper access control management in Kotlin could lead to unauthorized data acc (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin import java.util.* data class User(val id: String, var password: String) object UserManager { private val users = HashMap<String, User>() fun registerUser(id: String, password: String): User { val user = User(id, password) users[id] = user return user } fun getUserP...
<think> Target: kotlin implementation for Write a kotlin code that manages user registration and password retrie. Vulnerability Vector: Improper access control management in Kotlin could lead to unauthorized data acc (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin import java.util.* class User(val id: String, var password: String) object UserManager { private val users = HashMap<String, User>() fun registerUser(id: String, password: String): User { val user = User(id, password) users[id] = user return user } fun getUserPasswo...
387
0.83
cyber_284d422588b5
vulnerability_research_cve
CWE-89
Write a python code that creates a web application using Flask framework. The application should have a route '/search' which accepts GET requests. When a GET request is made to this route, it should take a query parameter 'q' from the request. It should then connect to an SQLite database named 'my_database.db'. It sho...
Target: python implementation for Write a python code that creates a web application using Flask framewo. Vulnerability Vector: A vulnerability in Python code can be a result of improper handling of user inpu (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import sqlite3 from flask import Flask, request app = Flask(__name__) @app.route('/search', methods=['GET']) def search(): query = request.args.get('q') conn = sqlite3.connect('my_database.db') cursor = conn.cursor()aring cursor.execute("SELECT * FROM users WHERE username=?", (query,)) r...
<think> Target: python implementation for Write a python code that creates a web application using Flask framewo. Vulnerability Vector: A vulnerability in Python code can be a result of improper handling of user inpu (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import sqlite3 from flask import Flask, request app = Flask(__name__) @app.route('/search', methods=['GET']) def search(): query = request.args.get('q') conn = sqlite3.connect('my_database.db') cursor = conn.cursor() cursor.execute(f"SELECT * FROM users WHERE username='{query}'") results...
246
0.85
cyber_8f983245be12
vulnerability_research_cve
CWE-20
Write a javascript code that creates a regular expression pattern to match strings that contain 'a' followed by one or more 'b's followed by 'c'. Then, use this regular expression to test if a string of 397 'a's followed by 397 'b's and 397 'c's exists.
Target: javascript implementation for Write a javascript code that creates a regular expression pattern to m. Vulnerability Vector: In JavaScript, improper use of regular expressions can lead to ReDoS (Regular Ex (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript const regex = /^a+b+c+$/; const testString = "a".repeat(397) + "b".repeat(397) + "c".repeat(397); console.log(regex.test(testString)); ```
<think> Target: javascript implementation for Write a javascript code that creates a regular expression pattern to m. Vulnerability Vector: In JavaScript, improper use of regular expressions can lead to ReDoS (Regular Ex (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript var regex = new RegExp("a+b+c"); for(let i = 0; i < 1000000; i++){ regex.test("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
175
6.29