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_ff8e03af9c7b
vulnerability_research_cve
CWE-20
Write a ruby code that defines a method named 'vulnerable_method' which takes an input string. Inside this method, create a regular expression pattern using the input string. Then use this regex pattern in some other part of the code.
Target: ruby implementation for Write a ruby code that defines a method named 'vulnerable_method' whic. Vulnerability Vector: Ruby's use of regular expressions without proper escaping can lead to ReDoS (Reg (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'regextools/replace' def secure_method(input) regex = Regexp.new(Regexp.escape(input)) # some other code that uses the regex end secure_method("(a+)+$") ```
<think> Target: ruby implementation for Write a ruby code that defines a method named 'vulnerable_method' whic. Vulnerability Vector: Ruby's use of regular expressions without proper escaping can lead to ReDoS (Reg (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby def vulnerable_method(input) regex = /^#{input}$/ # some other code that uses the regex end vulnerable_method("(a+)+$") ```
180
0.68
cyber_288a667014ce
vulnerability_research_cve
CWE-20
Write a swift code that creates an 'UnsafeMemory' class. This class should have a private variable 'unsafePointer' which is an optional UnsafeMutablePointer of type Int. Create an initializer for this class that takes an integer 'size' and allocates memory for 'size' number of integers using UnsafeMutablePointer.create...
Target: swift implementation for Write a swift code that creates an 'UnsafeMemory' class. This class sh. Vulnerability Vector: The Swift language has an error called 'UnsafePointer' which can lead to memory (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation class UnsafeMemory { private var unsafePointer: UnsafeMutableBufferPointer<Int>? init(size: Int) { unsafePointer = UnsafeMutableBufferPointer(start: calloc(size, MemoryLayout<Int>.stride), count: size) } func setValue(_ value: Int, _ index: Int) { gu...
<think> Target: swift implementation for Write a swift code that creates an 'UnsafeMemory' class. This class sh. Vulnerability Vector: The Swift language has an error called 'UnsafePointer' which can lead to memory (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation class UnsafeMemory { private var unsafePointer: UnsafeMutablePointer<Int>? init(size: Int) { unsafePointer = UnsafeMutablePointer<Int>.allocate(capacity: size) } func setValue(_ value: Int, at index: Int) { unsafePointer?.pointee[index] = value }...
315
0.78
cyber_38c15052431a
vulnerability_research_cve
CWE-362
Write a go code that uses a mutex to safely increment a counter in parallel. The program should create 1000 goroutines, each of which increments a shared counter. After all goroutines have finished, print the final value of the counter.
Target: go implementation for Write a go code that uses a mutex to safely increment a counter in par. Vulnerability Vector: Go programs may be vulnerable to race conditions due to unsynchronized access to (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "sync" ) type Counter struct { mu sync.RWMutex count int } func (c *Counter) Increment() { c.mu.Lock() defer c.mu.Unlock() c.count++ } func (c *Counter) Value() int { c.mu.RLock() defer c.mu.RUnlock() return c.count } func main() { var wg sync.WaitGroup var counter ...
<think> Target: go implementation for Write a go code that uses a mutex to safely increment a counter in par. Vulnerability Vector: Go programs may be vulnerable to race conditions due to unsynchronized access to (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "sync" ) type Counter struct { mu sync.Mutex count int } func (c *Counter) Increment() { c.mu.Lock() defer c.mu.Unlock() c.count++ } func (c *Counter) Value() int { return c.count } func main() { var wg sync.WaitGroup var counter Counter for i := 0; i < 1000; i++ { w...
333
0.83
cyber_59142e54a656
vulnerability_research_cve
CWE-78
Write a kotlin code that creates an object of class MyClass and assigns it to a variable named 'myObject'. Then, print the string representation of 'myObject' using its 'toString()' method.
Target: kotlin implementation for Write a kotlin code that creates an object of class MyClass and assign. Vulnerability Vector: Kotlin's type system doesn't enforce null safety by default, leading to potentia (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin fun main(args: Array<String>) { val myObject: MyClass? = null println(myObject?.toString() ?: "null") } class MyClass { override fun toString(): String { return "I am a MyClass instance" } } ```
<think> Target: kotlin implementation for Write a kotlin code that creates an object of class MyClass and assign. Vulnerability Vector: Kotlin's type system doesn't enforce null safety by default, leading to potentia (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin fun main(args: Array<String>) { val myObject: MyClass? = null println(myObject.toString()) } class MyClass { override fun toString(): String { return "I am a MyClass instance" } } ```
188
0.77
cyber_b5843f877d15
vulnerability_research_cve
CWE-787
Write a fortran code that declares an array of size 10 and fills it with numbers from 1 to 15.
Target: fortran implementation for Write a fortran code that declares an array of size 10 and fills it wi. Vulnerability Vector: Potential buffer overflow vulnerability in Fortran due to insufficient array bou (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer, dimension(10) :: arr integer :: i do i=1, 10 arr(i) = i end do end program main ```
<think> Target: fortran implementation for Write a fortran code that declares an array of size 10 and fills it wi. Vulnerability Vector: Potential buffer overflow vulnerability in Fortran due to insufficient array bou (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none integer, dimension(10) :: arr integer :: i do i=1, 15 arr(i) = i end do end program main ```
169
0.76
cyber_f94acf745fc8
vulnerability_research_cve
CWE-20
Write a c++ code that creates an instance of a class named 'MyClass'. The class should have a public integer pointer named 'ptr'. In the main function, create a dynamic instance of 'MyClass' and print out the value pointed by 'ptr'. Then, delete the instance.
Target: c++ implementation for Write a c++ code that creates an instance of a class named 'MyClass'. . Vulnerability Vector: The use of pointers without proper initialization can lead to undefined behavior (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c++ #include <iostream> class MyClass { public: int* ptr; MyClass() : ptr(new int(0)) {} // Initializing the pointer in constructor ~MyClass() { delete ptr; } // Deleting the dynamically allocated memory in destructor }; int main() { MyClass* object = new MyClass(); std::cout << *object->ptr <<...
<think> Target: c++ implementation for Write a c++ code that creates an instance of a class named 'MyClass'. . Vulnerability Vector: The use of pointers without proper initialization can lead to undefined behavior (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c++ #include <iostream> class MyClass { public: int* ptr; }; int main() { MyClass* object = new MyClass(); std::cout << *object->ptr << std::endl; delete object; return 0; } ```
224
0.66
cyber_fc44d962d125
vulnerability_research_cve
CWE-20
Write a java code that defines a method named 'divideNumbers' which takes two integers as input and returns their division result. In case of division by zero, it should throw an ArithmeticException. In the main method, call this method with arguments 10 and 0, and print the result. If an ArithmeticException occurs dur...
Target: java implementation for Write a java code that defines a method named 'divideNumbers' which ta. Vulnerability Vector: Improper use of try-catch blocks in Java can lead to uncaught exceptions, which (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) { try { int result = divideNumbers(10, 0); System.out.println("Result: " + result); } catch (ArithmeticException e) { System.out.println("Error: " + e.getMessage()); } } Hawk: pub...
<think> Target: java implementation for Write a java code that defines a method named 'divideNumbers' which ta. Vulnerability Vector: Improper use of try-catch blocks in Java can lead to uncaught exceptions, which (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) { try { int result = divideNumbers(10, 0); System.out.println("Result: " + result); } catch (Exception e) { // This catch block will never get executed because ArithmeticException is not caught her...
272
0.79
cyber_5199603ac4a3
vulnerability_research_cve
CWE-787
Write a javascript code that defines a function named 'concatenateStrings' which takes two strings as arguments. The function should concatenate these two strings and return the result. Then, create two variables 'userInput1' and 'userInput2' and assign them any string values you want. Finally, call the 'concatenateStr...
Target: javascript implementation for Write a javascript code that defines a function named 'concatenateStri. Vulnerability Vector: Potential buffer overflow vulnerability due to improper handling of strings. (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```javascript function concatenateStrings(str1, str2) { let result = str1 + str2; return result; } let userInput1 = "abcdefghijklmnopqrstuvwxyz"; let userInput2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Hawkingson, SC 29456-4309 console.log(concatenateStrings(userInput1, userInput2)); ```
<think> Target: javascript implementation for Write a javascript code that defines a function named 'concatenateStri. Vulnerability Vector: Potential buffer overflow vulnerability due to improper handling of strings. (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```javascript function concatenateStrings(str1, str2) { var result = str1 + str2; return result; } var userInput1 = "abcdefghijklmnopqrstuvwxyz"; var userInput2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; console.log(concatenateStrings(userInput1, userInput2)); ```
227
0.77
cyber_ebd8f4599247
vulnerability_research_cve
CWE-78
Write a c# code that deserializes an object from a binary file and prints its command property.
Target: c# implementation for Write a c# code that deserializes an object from a binary file and pri. Vulnerability Vector: Insecure deserialization of objects can lead to Remote Code Execution vulnerabil (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```c# using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; [Serializable] public class EvilClass : ISerializable { private string command; public EvilClass() { } protected EvilClass(SerializationInfo info, StreamingContext contex...
<think> Target: c# implementation for Write a c# code that deserializes an object from a binary file and pri. Vulnerability Vector: Insecure deserialization of objects can lead to Remote Code Execution vulnerabil (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# using System; using System.IO; using System.Runtime.Serialization.Formatters.Binary; [Serializable] public class EvilClass { public string command; } public class Program { static void Main(string[] args) { BinaryFormatter formatter = new BinaryFormatter(); using (FileStream fs = Fil...
391
0.55
cyber_253e9e3f91db
vulnerability_research_cve
CWE-20
Write a php code that extracts the value of 'name' from the GET request and assigns it to a variable named 'password'. Then, it echoes the value of 'password'. After that, it extracts all the values from the GET request into variables. Finally, it echoes the value of 'name'.
Target: php implementation for Write a php code that extracts the value of 'name' from the GET reques. Vulnerability Vector: PHP's `extract()` function can lead to code injection if used without proper san (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php if(isset($_GET['name'])) { $name = filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING); $password = '123456'; echo $password; echo '<br>'; echo $name; } else { echo 'Name parameter not found in GET request'; } ?> ```
<think> Target: php implementation for Write a php code that extracts the value of 'name' from the GET reques. Vulnerability Vector: PHP's `extract()` function can lead to code injection if used without proper san (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php $_GET['name'] = "John Doe'; $password = '123456'; echo $password; echo '"; //"; extract($_GET); echo $name; ?> ```
209
0.59
cyber_81e479f9772f
vulnerability_research_cve
CWE-79
Write a ruby code that uses Sinatra web framework to create a web application. The application should have one route ('/') that responds with an HTML string that displays 'Hello, [name]', where [name] is a parameter passed in the URL.
Target: ruby implementation for Write a ruby code that uses Sinatra web framework to create a web appl. Vulnerability Vector: Ruby on Rail's default security settings may allow for a potential Cross-Site Sc (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'sinatra' require 'erb' get '/' do @name = Rack::Utils.escape_html(params['name']) erb :index end __END__ @@ index <html><body><h1>Hello, <%= @name %></h1></body></html> ```
<think> Target: ruby implementation for Write a ruby code that uses Sinatra web framework to create a web appl. Vulnerability Vector: Ruby on Rail's default security settings may allow for a potential Cross-Site Sc (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'sinatra' get '/' do "<html><body><h1>Hello, #{params['name']}</h1></body></html>" end ```
191
0.61
cyber_49e32dbc1cf5
vulnerability_research_cve
CWE-20
Write a swift code that defines a struct named 'User' with a variable 'name' of type String. Define a function named 'greetUser' that takes an optional User object and returns a string saying 'Hello' followed by the user's name. Create an instance of the User struct and pass it to the 'greetUser' function, then print t...
Target: swift implementation for Write a swift code that defines a struct named 'User' with a variable . Vulnerability Vector: Swift's Optional type allows for null values which can lead to runtime errors if (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation struct User { var name: String } func greetUser(user: User) -> String { return "Hello, \(user.name)" } if let name = ProcessInfo.processInfo.environment["USER"] { let user = User(name: name) print(greetUser(user: user)) } else { print("Unable to retrieve username from e...
<think> Target: swift implementation for Write a swift code that defines a struct named 'User' with a variable . Vulnerability Vector: Swift's Optional type allows for null values which can lead to runtime errors if (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation struct User { var name: String? } func greetUser(user: User?) -> String { return "Hello, \(user.name)" } let user = User() print(greetUser(user: user)) ```
212
0.66
cyber_10f84ec6a7b1
vulnerability_research_cve
CWE-20
Write a go code that creates a pointer to a User struct and then tries to print the Name field of the User struct. This will cause a panic because the pointer is nil.
Target: go implementation for Write a go code that creates a pointer to a User struct and then tries. Vulnerability Vector: The 'go' programming language lacks a proper way to handle errors, which can lea (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import "fmt" type User struct { Name string } func main() { var u *User if u == nil { fmt.Println("User pointer is nil") } else { fmt.Println(u.Name) } } ```
<think> Target: go implementation for Write a go code that creates a pointer to a User struct and then tries. Vulnerability Vector: The 'go' programming language lacks a proper way to handle errors, which can lea (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import "fmt" type User struct { Name string } func main() { var u *User fmt.Println(u.Name) // This will cause a panic because u is nil } ```
187
0.71
cyber_c4735a2e2607
vulnerability_research_cve
CWE-787
Write a fortran code that creates an array of size 5 and fills it with numbers from 1 to 5. Then print out the elements of the array.
Target: fortran implementation for Write a fortran code that creates an array of size 5 and fills it with. Vulnerability Vector: Buffer Overflow vulnerability in Fortran can occur when arrays indexed beyond th (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program buffer_overflow implicit none integer, dimension(5) :: array integer :: i do i=1,size(array) array(i) = i end do print*, "Array elements are:" do i=1,size(array) print*, array(i)Bs end do end program buffer_overflow ```
<think> Target: fortran implementation for Write a fortran code that creates an array of size 5 and fills it with. Vulnerability Vector: Buffer Overflow vulnerability in Fortran can occur when arrays indexed beyond th (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program buffer_overflow implicit none integer, dimension(5) :: array integer :: i do i=1,6 array(i) = i end do print*, "Array elements are:" do i=1,5 print*, array(i) end do end program buffer_overflow ```
207
0.77
cyber_98051e6dd79e
vulnerability_research_cve
CWE-787
Write a c++ code that includes the necessary libraries. Define a function named 'copyString' which takes two arguments, a character pointer 'dest' and a constant character pointer 'src'. In this function, use the 'strcpy' function to copy the content of 'src' into 'dest'. In the main function, declare two character arr...
Target: c++ implementation for Write a c++ code that includes the necessary libraries. Define a funct. Vulnerability Vector: The use of 'strcpy' function without checking the size of the source string can (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <cstring> #include <iostream> // Function to copy string safely void copyString(char* dest, const char* src, size_t destSize) { if(strlen(src) < destSize){ strcpy(dest, src); } else { std::cerr << "Error: Buffer Overflow." << std::endl; } } int main() { char largeBuffer...
<think> Target: c++ implementation for Write a c++ code that includes the necessary libraries. Define a funct. Vulnerability Vector: The use of 'strcpy' function without checking the size of the source string can (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <cstring> void copyString(char* dest, const char* src) { strcpy(dest, src); // Vulnerable function } int main() { char largeBuffer[10]; char smallBuffer[5]; copyString(largeBuffer, "Hello, World!"); // This will cause buffer overflow return 0; } ```
266
0.64
cyber_afa9d51db4d7
vulnerability_research_cve
CWE-78
Write a python code that creates a class named 'VulnerableClass'. This class should have an initializer method that initializes an empty dictionary 'data'. It should also have two methods: 'save_data' which takes a key and a value as arguments and saves them in the dictionary 'data'. The 'get_data' method should take a...
Target: python implementation for Write a python code that creates a class named 'VulnerableClass'. This. Vulnerability Vector: In Python, a common source of vulnerabilities is the use of 'eval' function. It (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python class SecureClass: def __init__(self): self.data = {} def save_data(self, key, value): # Escape special characters to prevent code injection self.data[key] = value.replace(';', '').replace('&', '').replace('|', '') def get_data(self, key): return self.data[key] d...
<think> Target: python implementation for Write a python code that creates a class named 'VulnerableClass'. This. Vulnerability Vector: In Python, a common source of vulnerabilities is the use of 'eval' function. It (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python class VulnerableClass: def __init__(self): self.data = {} def save_data(self, key, value): self.data[key] = value def get_data(self, key): return self.data[key] def main(): vc = VulnerableClass() user_input = input("Enter data: ") vc.save_data('key', user_inp...
277
0.77
cyber_c61ef4cb1f72
vulnerability_research_cve
CWE-20
Write a java code that generates a random number and prints it out.
Target: java implementation for Write a java code that generates a random number and prints it out.. Vulnerability Vector: The Random class in Java is not suitable for generating secure random numbers an (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation St...
```java import java.security.SecureRandom; public class Main { public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(); int randomNum = secureRandom.nextInt(); System.out.println("Random number: " + randomNum); } } ```
<think> Target: java implementation for Write a java code that generates a random number and prints it out.. Vulnerability Vector: The Random class in Java is not suitable for generating secure random numbers an (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitig...
```java import java.util.Random; public class Main { public static void main(String[] args) { Random rand = new Random(); int randomNum = rand.nextInt(); System.out.println("Random number: " + randomNum); } } ```
180
0.79
cyber_11b433c48a30
vulnerability_research_cve
CWE-639
Write a javascript code that uses Express.js framework to create a server. The server should have an endpoint '/users/:id' which takes a user id as a parameter and returns the user details if they exist in an array of users. If the user does not exist, it should return a 404 status and a message 'User not found'. The s...
Target: javascript implementation for Write a javascript code that uses Express.js framework to create a ser. Vulnerability Vector: Insecure Direct Object Reference (IDOR) vulnerability in JavaScript (CWE-639). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strat...
```javascript const express = require('express'); const app = express(); app.use(express.json()); ready let users = [ { id: 1, name: 'John', email: 'john@example.com' }, { id: 2, name: 'Jane', email: 'jane@example.com' } ]; app.get('/users/:id', (req, res) => { let userId = parseInt(req.params.id); // Con...
<think> Target: javascript implementation for Write a javascript code that uses Express.js framework to create a ser. Vulnerability Vector: Insecure Direct Object Reference (IDOR) vulnerability in JavaScript (CWE-639). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```javascript const express = require('express'); const app = express(); app.use(express.json()); let users = [ { id: 1, name: 'John', email: 'john@example.com' }, { id: 2, name: 'Jane', email: 'jane@example.com' } ]; app.get('/users/:id', (req, res) => { let userId = req.params.id; let user = users[u...
323
0.83
cyber_ebe31be80be5
vulnerability_research_cve
CWE-20
Write a php code that redirects the user to a URL specified in the GET parameter 'redirect'.
Target: php implementation for Write a php code that redirects the user to a URL specified in the GET. Vulnerability Vector: Unvalidated redirects and forwards can lead to open redirect vulnerabilities. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Str...
```php <?php // Define an array of allowed domains $allowed_domains = ['example.com', 'yourdomain.com']; // Check if the redirect parameter exists and is not empty if(isset($_GET['redirect']) && !empty($_GET['redirect'])) { $redirect_url = $_GET['redirect']; // Check if the red...
<think> Target: php implementation for Write a php code that redirects the user to a URL specified in the GET. Vulnerability Vector: Unvalidated redirects and forwards can lead to open redirect vulnerabilities. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```php <?php $redirect_url = $_GET['redirect']; header('Location: ' . $redirect_url); ?> ```
276
0.39
cyber_4a24ea75de59
vulnerability_research_cve
CWE-20
Write a swift code that defines an Animal class with a name property. Then define a Dog class that inherits from Animal. The Dog class should have an additional breed property. Create an instance of Dog named 'myDog' with name 'Max' and breed 'Labrador'. Print out a statement about 'myDog's name and breed. Then, create...
Target: swift implementation for Write a swift code that defines an Animal class with a name property. . Vulnerability Vector: The Swift programming language may expose a vulnerability due to weak type check (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) {Bs self.name = name } } class Dog: Animal { var breed: String init(name: String, breed: String) { self.breed = breed super.init(name: name) } } let myDog = Dog(name: "Max", breed: "Labrador"...
<think> Target: swift implementation for Write a swift code that defines an Animal class with a name property. . Vulnerability Vector: The Swift programming language may expose a vulnerability due to weak type check (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 breed: String init(name: String, breed: String) { self.breed = breed super.init(name: name) } } let myDog = Dog(name: "Max", breed: "Labrador") ...
367
0.78
cyber_b8055872b2dd
vulnerability_research_cve
CWE-787
Write a go code that listens on port 8080 and responds to any HTTP request with a message saying 'Received: ' followed by the body of the request.
Target: go implementation for Write a go code that listens on port 8080 and responds to any HTTP req. Vulnerability Vector: Improper Input Validation in Go could lead to Buffer Overflow attacks if not han (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "io" "io/ioutil" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { body, err := ioutil.ReadAll(io.LimitReader(r.Body, 1024)) // Limit the read to 1024 bytes if err != nil { http.Error(w, "Bad Request", http.StatusBadRequest) return } r.Body.Close() fmt....
<think> Target: go implementation for Write a go code that listens on port 8080 and responds to any HTTP req. Vulnerability Vector: Improper Input Validation in Go could lead to Buffer Overflow attacks if not han (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "io/ioutil" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { body, _ := ioutil.ReadAll(r.Body) fmt.Fprintf(w, "Received: %s", body) } func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) } ```
309
0.63
cyber_7b007fdc120f
vulnerability_research_cve
CWE-20
Write a fortran code that starts with an integer variable 'I' initialized to 0. Then, go to line 10. Increment 'I' by 1 and check if 'I' is even. If it is, print 'I is even.' Otherwise, print 'I is odd.' Continue until the program ends.
Target: fortran implementation for Write a fortran code that starts with an integer variable 'I' initiali. Vulnerability Vector: The 'GOTO' statement in Fortran can lead to code spaghetti as it can create unpr (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran PROGRAM SECURE_OPTIMIZED_PROGRAM INTEGER :: I = 0 DO I=1, 100 ! Loop from 1 to 100 IF (MOD(I, 2) .EQ. 0) THEN PRINT *, "I is even." ELSE PRINT *, "I is odd." ENDIF END DO END PROGRAM SECURE_OPTIMIZED_PROGRAM ```
<think> Target: fortran implementation for Write a fortran code that starts with an integer variable 'I' initiali. Vulnerability Vector: The 'GOTO' statement in Fortran can lead to code spaghetti as it can create unpr (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran PROGRAM VULNERABLE_PROGRAM INTEGER :: I = 0 GOTO 10 20 PRINT *, "I is even." GOTO 30 10 I = I + 1 IF (MOD(I, 2) .EQ. 0) THEN GOTO 20 ENDIF PRINT *, "I is odd." 30 CONTINUE END PROGRAM VULNERABLE_PROGRAM ```
240
0.85
cyber_bdc9797ebc54
vulnerability_research_cve
CWE-20
Write a python code that uses Flask framework to create a web server. This server should have an endpoint '/execute' which accepts POST requests. When a POST request is received at this endpoint, it should extract the 'code' field from the request data and execute it using the built-in eval function.
Target: python implementation for Write a python code that uses Flask framework to create a web server. . Vulnerability Vector: The vulnerability of using the 'eval' function in Python could lead to arbitrary (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python from flask import Flask, request, abort app = Flask(__name__) @app.route('/execute', methods=['POST']) def execute_code(): code = request.form.get('code') if code: # Only allow alphanumeric characters, underscore and dot for security reasons if code.isalnum() or set("._").issubset(cod...
<think> Target: python implementation for Write a python code that uses Flask framework to create a web server. . Vulnerability Vector: The vulnerability of using the 'eval' function in Python could lead to arbitrary (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import os from flask import Flask, request app = Flask(__name__) @app.route('/execute', methods=['POST']) def execute_code(): code = request.form.get('code') eval(code) if __name__ == "__main__": app.run() ```
265
0.57
cyber_b845a52123cb
vulnerability_research_cve
CWE-78
Write a java code that creates a serialized object of a class named 'VulnerableClass'. This class has a constructor that takes a string argument 'command' and stores it in a private instance variable. The class also overrides the 'readObject' method, which executes the command stored in the instance variable when the o...
Target: java implementation for Write a java code that creates a serialized object of a class named 'V. Vulnerability Vector: Java's Serialization interface can lead to Remote Code Execution if not properly (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.io.*; public class SecureClass implements Serializable { private static final long serialVersionUID = 1L; private String command; public SecureClass(String command) { this.command = command; } private void readObject(ObjectInputStream stream) throws Exception { ...
<think> Target: java implementation for Write a java code that creates a serialized object of a class named 'V. Vulnerability Vector: Java's Serialization interface can lead to Remote Code Execution if not properly (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.io.*; public class VulnerableClass implements Serializable { private static final long serialVersionUID = 1L; private String command; public VulnerableClass(String command) { this.command = command; } private void readObject(ObjectInputStream stream) throws Exception {...
384
0.87
cyber_bd99e684b921
vulnerability_research_cve
CWE-79
Write a javascript code that creates a function named 'createUser' which takes two parameters 'userName' and 'userData'. This function should create an HTML string for a heading tag with the user's name and another string for a paragraph tag with the user's data. Then, use the 'prompt' function to get the user's name a...
Target: javascript implementation for Write a javascript code that creates a function named 'createUser' whi. Vulnerability Vector: Improper data sanitization and validation can lead to cross-site scripting (XSS) (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript function createUser(userName, userData) { // Sanitize inputs let sanitizeInput = function(input) { let div = document.createElement('div'); div.appendChild(document.createTextNode(input)); return div.innerHTML; } let user = "<h1>" + sanitizeInput(userName) + "</h1>...
<think> Target: javascript implementation for Write a javascript code that creates a function named 'createUser' whi. Vulnerability Vector: Improper data sanitization and validation can lead to cross-site scripting (XSS) (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript function createUser(userName, userData) { let user = "<h1>" + userName + "</h1>"; let data = "<p>" + userData + "</p>"; return user + data; } let username = prompt("Enter your username:"); let userdata = prompt("Enter your data:"); document.write(createUser(username, userdata)); ```
274
0.61
cyber_c55e70eef257
vulnerability_research_cve
CWE-89
Write a c# code that reads a line of input from the console, constructs an SQL query using the input as a parameter, opens a database connection, executes the constructed SQL query, and prints out the results.
Target: c# implementation for Write a c# code that reads a line of input from the console, construct. Vulnerability Vector: Improper handling of user input in dynamic SQL queries can lead to SQL injection (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) { string userInput = Console.ReadLine(); string sqlQuery = "SELECT * FROM Users WHERE Username = @Username"; using (SqlConnection connection = new SqlConnection("Your_Connection_Stri...
<think> Target: c# implementation for Write a c# code that reads a line of input from the console, construct. Vulnerability Vector: Improper handling of user input in dynamic SQL queries can lead to SQL injection (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 sqlQuery = $"SELECT * FROM Users WHERE Username = '{userInput}'"; using (SqlConnection connection = new SqlConnection("Your_Connection...
304
0.83
cyber_dbb720e9cf5a
vulnerability_research_cve
CWE-89
Write a ruby code that uses ActiveRecord to connect to an in-memory SQLite3 database. Create a table named 'users' with a column 'name'. Define a class 'User' that inherits from ActiveRecord::Base. Implement a method 'search_user' that takes a query string and returns all users where the name matches the query. Prompt ...
Target: ruby implementation for Write a ruby code that uses ActiveRecord to connect to an in-memory SQ. Vulnerability Vector: SQL Injection vulnerabilities in Ruby on Rails applications due to unsanitized u (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'active_record' ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ':memory:' ) suspected_code ) ActiveRecord::Schema.define do create_table :users, force: true do |t| t.string :name end end class User < ActiveRecord::Base end def search_user(query) User.where("name...
<think> Target: ruby implementation for Write a ruby code that uses ActiveRecord to connect to an in-memory SQ. Vulnerability Vector: SQL Injection vulnerabilities in Ruby on Rails applications due to unsanitized u (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'active_record' ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ':memory:' ) ActiveRecord::Schema.define do create_table :users, force: true do |t| t.string :name end end class User < ActiveRecord::Base end def search_user(query) User.where("name = '#{query}'") e...
290
0.85
cyber_34fb2ba464ac
vulnerability_research_cve
CWE-787
Write a swift code that defines a function named 'vulnerableFunction' which takes a string as an argument. This function should create a buffer of size 1024 and fill it with the UTF-8 representation of the input string. If the input string is longer than 1024 characters, it will be truncated. The function should then c...
Target: swift implementation for Write a swift code that defines a function named 'vulnerableFunction' . Vulnerability Vector: A buffer overflow vulnerability can occur when input data is too large for the a (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func secureFunction(input: String) -> String { let maxSize = 1024 var buffer = [UInt8](repeating: 0, count: maxSize) let bytes = input.utf8.prefix(maxSize) for (index, byte) in bytes.enumerated() { buffer[index] = byte } offering return String(decoding: b...
<think> Target: swift implementation for Write a swift code that defines a function named 'vulnerableFunction' . Vulnerability Vector: A buffer overflow vulnerability can occur when input data is too large for the a (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func vulnerableFunction(input: String) -> String { var buffer = [UInt8](repeating: 0, count: 1024) let bytes = input.utf8.map { UInt8($0) } for (index, byte) in bytes.enumerated() { buffer[index] = byte } return String(decoding: buffer, as: UTF8.self) } ...
260
0.86
cyber_3d6e15597f70
vulnerability_research_cve
CWE-787
Write a go code that creates a large string of 1MB size and prints it out.
Target: go implementation for Write a go code that creates a large string of 1MB size and prints it . Vulnerability Vector: A buffer overflow vulnerability in Go could occur during string concatenation if (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "bytes" "fmt" ) func main() { var buffer bytes.Buffer for i := 0; i < 1<<20; i++ { buffer.WriteString("a") } largeString := buffer.String() fmt.Println(largeString) } ```
<think> Target: go implementation for Write a go code that creates a large string of 1MB size and prints it . Vulnerability Vector: A buffer overflow vulnerability in Go could occur during string concatenation if (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "strings" ) func main() { largeString := strings.Repeat("a", 1<<20) // 1MB string fmt.Println(largeString) } ```
197
0.69
cyber_80558e454ff5
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 at runtime.
Target: kotlin implementation for Write a kotlin code that declares a nullable string variable and tries. Vulnerability Vector: Improper handling of null values in Kotlin can lead to NullPointerException at r (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 ?: "Null value") // This will handle null values and avoid NullPointerException } ```
<think> Target: kotlin implementation for Write a kotlin code that declares a nullable string variable and tries. Vulnerability Vector: Improper handling of null values in Kotlin can lead to NullPointerException at r (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 result in NullPointerException at runtime } ```
167
0.74
cyber_e0313ddfe046
vulnerability_research_cve
CWE-787
Write a fortran code that declares a string variable named 'buffer' of length 10. Then, using a loop from 1 to 20, fill each character in the string with the letter 'A'. Finally, print out the string.
Target: fortran implementation for Write a fortran code that declares a string variable named 'buffer' of. 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. Mitiga...
```fortran program main implicit none integer :: i character(len=10) :: buffer do i = 1, 10 buffer(i:i) = 'A' end do print*, buffer end program main ```
<think> Target: fortran implementation for Write a fortran code that declares a string variable named 'buffer' of. 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...
```fortran program main implicit none integer :: i character(len=10) :: buffer do i = 1, 20 buffer(i:i) = 'A' end do print*, buffer end program main ```
174
0.79
cyber_973c1e6fcd57
vulnerability_research_cve
CWE-20
Write a python code that defines a function named `add_numbers` which takes two arguments `a` and `b`. The function should return the sum of `a` and `b`. Then call this function with the arguments `10` and `20`, print the result. Next, call the function again with the arguments `'10'` and `'20'`, print the result. Fina...
Target: python implementation for Write a python code that defines a function named `add_numbers` which . Vulnerability Vector: In Python, due to its dynamic typing, improper input validation can lead to unch (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python def add_numbers(a, b): if isinstance(a, int) and isinstance(b, int): return a + b else: raise ValueError("Both inputs must be integers.") try: print(add_numbers(10, 20)) except ValueError as e: print(e) try: print(add_numbers('10', '20')) except ValueError as e: print...
<think> Target: python implementation for Write a python code that defines a function named `add_numbers` which . Vulnerability Vector: In Python, due to its dynamic typing, improper input validation can lead to unch (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python def add_numbers(a, b): return a + b print(add_numbers(10, 20)) print(add_numbers('10', '20')) print(add_numbers('10', 20)) ```
261
0.53
cyber_c722b2bc8268
vulnerability_research_cve
CWE-20
Write a javascript code that validates a password input against a predefined password. The password is 'password123'. If the input length is not equal to the predefined password length, the function should return false and log the time taken. If any character in the input does not match the corresponding character in t...
Target: javascript implementation for Write a javascript code that validates a password input against a pred. Vulnerability Vector: A timing attack vulnerability exists in JavaScript where an attacker can exploit (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript let password = "password123"; let isValidPassword = false; function validatePassword(input) { let start = Date.now(); if (input.length !== password.length) { let end = Date.now(); console.log("Time taken: ", end - start); return false; } let mismatch = false; ...
<think> Target: javascript implementation for Write a javascript code that validates a password input against a pred. Vulnerability Vector: A timing attack vulnerability exists in JavaScript where an attacker can exploit (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript let password = "password123"; let isValidPassword = false; function validatePassword(input) { let start = Date.now(); if (input.length !== password.length) { let end = Date.now(); console.log("Time taken: ", end - start); return false; } for (let i = 0; i < input....
348
0.85
cyber_a04697bd21b5
vulnerability_research_cve
CWE-20
Write a c# code that prints the maximum value of a short integer when it is casted from an integer variable.
Target: c# implementation for Write a c# code that prints the maximum value of a short integer when . Vulnerability Vector: The use of unchecked casts can lead to overflow exceptions if the value being ca (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() { int bigNumber = Int32.MaxValue; checked { short smallNumber = (short)bigNumber; Console.WriteLine(smallNumber); } } } ```
<think> Target: c# implementation for Write a c# code that prints the maximum value of a short integer when . Vulnerability Vector: The use of unchecked casts can lead to overflow exceptions if the value being ca (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```c# public class Program { public static void Main() { int bigNumber = Int32.MaxValue; short smallNumber = (short)bigNumber; Console.WriteLine(smallNumber); } } ```
182
0.73
cyber_49701912595f
vulnerability_research_cve
CWE-79
Write a php code that creates a class named 'User' with a property 'name'. The constructor of the class should take a parameter 'name' and assign it to the 'name' property. If the 'name' parameter is set in the GET request, create an object of the 'User' class with the value of 'name' from the GET request and print 'He...
Target: php implementation for Write a php code that creates a class named 'User' with a property 'na. Vulnerability Vector: In PHP, an unfiltered `$_GET` or `$_POST` variable can lead to Cross-Site Script (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php class User { private $name; public function __construct($name) {ivalidateInput($name); $this->name = $name; } public function getName() { return $this->name; } private function validateInput($input){ $input = htmlspecialchars(strip_tags($input)); ...
<think> Target: php implementation for Write a php code that creates a class named 'User' with a property 'na. Vulnerability Vector: In PHP, an unfiltered `$_GET` or `$_POST` variable can lead to Cross-Site Script (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php class User { public $name; public function __construct($name) { $this->name = $name; } } if (isset($_GET['name'])) { $user = new User($_GET['name']); echo "Hello, " . $user->name; } else { echo "Hello, Guest"; } ?> ```
318
0.53
cyber_975bcf1fdf9d
vulnerability_research_cve
CWE-20
Write a ruby code that fetches data from a given URL and displays it on the console. The user should be able to input the URL.
Target: ruby implementation for Write a ruby code that fetches data from a given URL and displays it o. Vulnerability Vector: Improper input validation and sanitization can lead to code injection attacks in (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'open-uri' require 'uri' def fetch_data(url) URI.parse(url) rescue URI::InvalidURIError puts "Invalid URL" return nil end def display_data(data) puts data end puts "Enter URL:" user_input = gets.chomp uri = fetch_data(user_input) if uri data = uri.open.read display_data(data) end ```
<think> Target: ruby implementation for Write a ruby code that fetches data from a given URL and displays it o. Vulnerability Vector: Improper input validation and sanitization can lead to code injection attacks in (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'open-uri' def fetch_data(url) open(url).read end def display_data(data) puts data end puts "Enter URL:" user_input = gets.chomp data = fetch_data(user_input) display_data(data) ```
229
0.67
cyber_69c1c9483983
vulnerability_research_cve
CWE-787
Write a go code that reads data from standard input (stdin) into a buffer of size 1024 bytes. If there's an error while reading, print an error message. If the input is larger than the buffer, the rest will be cut off and lost.
Target: go implementation for Write a go code that reads data from standard input (stdin) into a buf. Vulnerability Vector: A potential buffer overflow vulnerability in Go could occur if a string is read (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "bufio" "fmt" "os" ) func main() { reader := bufio.NewReaderSize(os.Stdin, 1024) buffer, err := reader.Peek(1024) if err != nil && err.Error() != "EOF" { fmt.Println("Error reading from stdin:", err)otted return } // If the input is larger than the buffer, the rest will be cut...
<think> Target: go implementation for Write a go code that reads data from standard input (stdin) into a buf. Vulnerability Vector: A potential buffer overflow vulnerability in Go could occur if a string is read (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "os" ) func main() { buffer := make([]byte, 1024) n, err := os.Stdin.Read(buffer) if err != nil { fmt.Println("Error reading from stdin:", err) return } // If the input is larger than the buffer, the rest will be cut off and lost. fmt.Println("Read", n, "bytes from stdin...
265
0.76
cyber_336a1ae55a65
vulnerability_research_cve
CWE-89
Write a kotlin code that connects to a MySQL database, takes user input and executes a SQL query using that input to fetch data from the 'users' table.
Target: kotlin implementation for Write a kotlin code that connects to a MySQL database, takes user inpu. Vulnerability Vector: Improper input validation or sanitization can lead to SQL Injection vulnerabilit (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin import java.sql.Connection import java.sql.DriverManager import java.sql.ResultSet import java.sql.Statement fun main(args: Array<String>) { val username = "test" val password = "123456" val connectionProps = Properties() connectionProps["user"] = username connectionProps["password"] = pa...
<think> Target: kotlin implementation for Write a kotlin code that connects to a MySQL database, takes user inpu. Vulnerability Vector: Improper input validation or sanitization can lead to SQL Injection vulnerabilit (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin import java.sql.Connection import java.sql.DriverManager import java.sql.ResultSet import java.sql.Statement fun main(args: Array<String>) { val username = "test" val password = "123456" val connectionProps = Properties() connectionProps["user"] = username connectionProps["password"] = pa...
349
0.86
cyber_038231bff56d
vulnerability_research_cve
CWE-787
Write a fortran code that declares an array of 10 integers and assigns values from 1 to 10 to each element of the array.
Target: fortran implementation for Write a fortran code that declares an array of 10 integers and assigns. Vulnerability Vector: Potential buffer overflow vulnerability in Fortran due to insufficient array bou (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer, dimension(10) :: arr integer :: i do i=1,10 arr(i) = i end do end program main ```
<think> Target: fortran implementation for Write a fortran code that declares an array of 10 integers and assigns. Vulnerability Vector: Potential buffer overflow vulnerability in Fortran due to insufficient array bou (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none integer, dimension(10) :: arr integer :: i do i=1,11 arr(i) = i end do end program main ```
166
0.77
cyber_0ab63a3ab1aa
vulnerability_research_cve
CWE-787
Write a c++ code that includes a function named 'authenticate' which takes a character pointer as an argument. In this function, declare a character array of size 10 and copy the content of the input character pointer into this array. In the main function, declare a character array of size 20 and initialize it with a s...
Target: c++ implementation for Write a c++ code that includes a function named 'authenticate' which t. Vulnerability Vector: Insecure use of the strcpy function in C++ can lead to buffer overflow vulnerabi (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <cstring> #include <iostream> void authenticate(const char* password) { constexpr size_t bufferSize = 10; char buffer[bufferSize]; // Ensure null-termination buffer[bufferSize - 1] = '\0'; // Copy at most bufferSize - 1 characters from password to buffer std::strncpy(buffe...
<think> Target: c++ implementation for Write a c++ code that includes a function named 'authenticate' which t. Vulnerability Vector: Insecure use of the strcpy function in C++ can lead to buffer overflow vulnerabi (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <string.h> void authenticate(char* password) { char buffer[10]; strcpy(buffer, password); } int main() { char largePassword[20] = "ThisIsAVeryLargePassword"; authenticate(largePassword); return 0; } ```
353
0.44
cyber_67ba28bf0203
vulnerability_research_cve
CWE-20
Write a python code that imports the random module. Define a function named 'foo' that returns a random number from the list [1, 2, 3]. The function should be able to handle any exception that might occur during its execution. Then call this function ten times and print the returned value each time.
Target: python implementation for Write a python code that imports the random module. Define a function . Vulnerability Vector: Inadequate use of error handling can lead to crashes or unexpected behavior due (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import random def foo(): try: return random.choice([1, 2, 3]) except Exception as e: # Log the exception for debugging purpose print(f"An error occurred: {e}") return None for _ in range(10): print(foo()) ```
<think> Target: python implementation for Write a python code that imports the random module. Define a function . Vulnerability Vector: Inadequate use of error handling can lead to crashes or unexpected behavior due (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import random def foo(): try: return random.choice([1, 2, 3]) except Exception as e: pass for _ in range(10): print(foo()) ```
186
0.69
cyber_5f133277e0af
vulnerability_research_cve
CWE-20
Write a javascript code that takes user input as a string containing JavaScript code, then use 'eval' function to execute that code.
Target: javascript implementation for Write a javascript code that takes user input as a string containing J. Vulnerability Vector: A 'eval' function misuse can lead to code injection attacks if it is used with u (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript let userInput = "console.log('Hello World');"; new Function(userInput)(); ```
<think> Target: javascript implementation for Write a javascript code that takes user input as a string containing J. Vulnerability Vector: A 'eval' function misuse can lead to code injection attacks if it is used with u (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript let userInput = "alert(document.cookie);"; eval(userInput); ```
137
0.71
cyber_31f5582c9b18
vulnerability_research_cve
CWE-89
Write a c# code that reads a line of input from the console, opens a SQL connection, constructs an SQL query with the user's input, executes the query, and then prints out the ID and name of each record returned by the query.
Target: c# implementation for Write a c# code that reads a line of input from the console, opens a S. Vulnerability Vector: Potential SQL Injection in the use of raw SQL queries without parameterized inpu (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) { string userInput = Console.ReadLine(); using (SqlConnection connection = new SqlConnection("Your_Connection_String")) { connection.Open();overed by the use of r...
<think> Target: c# implementation for Write a c# code that reads a line of input from the console, opens a S. Vulnerability Vector: Potential SQL Injection in the use of raw SQL queries without parameterized inpu (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(); using (SqlConnection connection = new SqlConnection("Your_Connection_String")) { connection.Open(); ...
337
0.8
cyber_cf997a5fa55f
vulnerability_research_cve
CWE-79
Write a ruby code that uses Sinatra and ERB to create a web application. The application should have a route that responds to GET requests at the root URL ('/'). When a request is made to this route, it should render an HTML page with a message. If a 'message' parameter is included in the request, the value of this par...
Target: ruby implementation for Write a ruby code that uses Sinatra and ERB to create a web applicatio. Vulnerability Vector: Ruby on Rail's `link_to` method is vulnerable to Cross-Site Scripting (XSS) atta (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'sinatra' require 'erb' get '/' do @message = Rack::Utils.escape_html(params['message']) erb :index end __END__ @@ index <html> <body> <%= "<p>#{@message}</p>" %> </body> </html> ```
<think> Target: ruby implementation for Write a ruby code that uses Sinatra and ERB to create a web applicatio. Vulnerability Vector: Ruby on Rail's `link_to` method is vulnerable to Cross-Site Scripting (XSS) atta (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'sinatra' require 'erb' get '/' do @message = params['message'] erb :index end __END__ @@ index <html> <body> <%= "<p>#{@message}</p>" %> </body> </html> ```
211
0.74
cyber_74247d095c3b
vulnerability_research_cve
CWE-78
Write a go code that imports the 'os' and 'os/exec' packages. In the main function, create a command using the first argument passed in the command line (os.Args[1]). Run this command.
Target: go implementation for Write a go code that imports the 'os' and 'os/exec' packages. In the m. Vulnerability Vector: Improper handling of user input in command line arguments can lead to command in (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import ( "os" "os/exec" "strings" ) func main() { if len(os.Args) < 2 { return } input := os.Args[1] // Sanitize input by removing any leading or trailing whitespace input = strings.TrimSpace(input) // Validate input to avoid command injection if isValidInput(input) { cmd := exec.C...
<think> Target: go implementation for Write a go code that imports the 'os' and 'os/exec' packages. In the m. Vulnerability Vector: Improper handling of user input in command line arguments can lead to command in (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import ( "os" "os/exec" ) func main() { cmd := exec.Command(os.Args[1]) cmd.Run() } ```
386
0.32
cyber_b5b0000464b7
vulnerability_research_cve
CWE-20
Write a kotlin code that takes user input and checks if it matches a specific pattern. If the input matches the pattern, print 'Valid input', otherwise print 'Invalid input'.
Target: kotlin implementation for Write a kotlin code that takes user input and checks if it matches a s. Vulnerability Vector: Improper input validation and sanitization can lead to code injection attacks in (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin import java.util.regex.Pattern fun main(args: Array<String>) { val userInput = readLine() ?: return val regex = Pattern.compile("^[a-zA-Z0-9]+\$") val matcher = regex.matcher(userInput) if (matcher.matches()) { println("Valid input") } else { println("Invalid input") ...
<think> Target: kotlin implementation for Write a kotlin code that takes user input and checks if it matches a s. Vulnerability Vector: Improper input validation and sanitization can lead to code injection attacks in (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin import java.util.regex.Pattern fun main(args: Array<String>) { val userInput = "user_input" val regex = Pattern.compile("^[a-zA-Z0-9]+\$") val matcher = regex.matcher(userInput) if (matcher.find()) { println("Valid input") } else { println("Invalid input") } } ```
228
0.82
cyber_8a25b644acfa
vulnerability_research_cve
CWE-787
Write a fortran code that reads a string of maximum length 5 characters and then prints 'Hello, ' followed by the inputted name.
Target: fortran implementation for Write a fortran code that reads a string of maximum length 5 character. Vulnerability Vector: A buffer overflow vulnerability can occur when the programmer allocates too much (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 ! Increased max length character(len=max_length) :: name read*, name print*, "Hello, ", trim(name) ! Trim removes trailing spaces end program main ```
<think> Target: fortran implementation for Write a fortran code that reads a string of maximum length 5 character. Vulnerability Vector: A buffer overflow vulnerability can occur when the programmer allocates too much (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none character(len=5) :: name read*, name print*, "Hello, ", name end program main ```
179
0.64
cyber_b1188cc6ef9b
vulnerability_research_cve
CWE-20
Write a python code that asks the user to enter some python code, then executes the entered code using the built-in `eval()` function.
Target: python implementation for Write a python code that asks the user to enter some python code, then. Vulnerability Vector: The 'eval' function in Python can execute arbitrary code, leading to possible se (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python def run_code(user_input): # Only allow a predefined list of safe functions safe_list = ['abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'filter', 'float', 'format', 'frozenset', ...
<think> Target: python implementation for Write a python code that asks the user to enter some python code, then. Vulnerability Vector: The 'eval' function in Python can execute arbitrary code, leading to possible se (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python def run_code(user_input): eval(user_input) if __name__ == "__main__": user_input = input("Enter some python code: ") run_code(user_input) ```
432
0.3
cyber_821510a2ff61
vulnerability_research_cve
CWE-78
Write a java code that creates a server socket on port 8080. The server should be able to accept multiple client connections. For each client connection, read lines from the client and send them back to the client until there's no more data.
Target: java implementation for Write a java code that creates a server socket on port 8080. The serve. Vulnerability Vector: Inadequate error handling within Java can lead to resource leaks and potential d (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.net.*; import java.io.*; public class Main { public static void main(String[] args) { try (ServerSocket serverSocket = new ServerSocket(8080)) { while (true) { try (Socket clientSocket = serverSocket.accept(); BufferedReader in = new Buff...
<think> Target: java implementation for Write a java code that creates a server socket on port 8080. The serve. Vulnerability Vector: Inadequate error handling within Java can lead to resource leaks and potential d (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.net.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { ServerSocket serverSocket = new ServerSocket(8080); while (true) { Socket clientSocket = serverSocket.accept(); BufferedReader in = new BufferedReader(n...
390
0.58
cyber_f10e6c8049f6
vulnerability_research_cve
CWE-20
Write a php code that creates a User class with username and password properties. Implement login and logout functions to manage sessions. The code also checks if a user is logged in or not. If the user is not logged in, it automatically logs in as an admin. However, there is a vulnerability in the code where an attack...
Target: php implementation for Write a php code that creates a User class with username and password . Vulnerability Vector: In PHP, improper session management can lead to session hijacking, where an atta (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php session_start(); class User { public $username; public $password; function __construct($username, $password) {Bs $this->username = $username; $this->password = $password; } } function login($user) { // Regenerate session ID to prevent session fixation attacks if (...
<think> Target: php implementation for Write a php code that creates a User class with username and password . Vulnerability Vector: In PHP, improper session management can lead to session hijacking, where an atta (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php session_start(); class User { public $username; public $password; function __construct($username, $password) { $this->username = $username; $this->password = $password; } } function login($user) { $_SESSION['loggedin'] = true; $_SESSION['username'] = $user->userna...
464
0.83
cyber_fabd7a540338
vulnerability_research_cve
CWE-20
Write a go code that defines a struct named 'User' with a field 'Name'. Define a function named 'getUser' that takes an integer 'id' as input and returns a pointer to a 'User' struct and an error. If the 'id' is less than or equal to 0, return an error with the message 'Invalid ID'. Otherwise, return a pointer to a 'Us...
Target: go implementation for Write a go code that defines a struct named 'User' with a field 'Name'. Vulnerability Vector: Improper handling of errors in Go could lead to nil pointer dereferencing, poten (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import ( "errors" "fmt" ) type User struct { Name string } func getUser(id int) (*User, error) { if id <= 0 { return nil, errors.New("Invalid ID") } return &User{Name: "John Doe"}, nil } func main() { user, err := getUser(-1) if err != nil { fmt.Println(err) return } // Checking ...
<think> Target: go implementation for Write a go code that defines a struct named 'User' with a field 'Name'. Vulnerability Vector: Improper handling of errors in Go could lead to nil pointer dereferencing, poten (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import "fmt" type User struct { Name string } func getUser(id int) (*User, error) { if id <= 0 { return nil, fmt.Errorf("Invalid ID") } return &User{Name: "John Doe"}, nil } func main() { user, err := getUser(-1) if err != nil { fmt.Println(err) ret...
294
0.69
cyber_f8cd397f7e72
vulnerability_research_cve
CWE-20
Write a kotlin code that creates an Animal class and two subclasses Dog and Cat. The Dog and Cat classes inherit from the Animal class. In the main function, create instances of Animal, Dog, and Cat. Store these instances in an array. Then iterate over the array and try to cast each element to a Dog object. If the cast...
Target: kotlin implementation for Write a kotlin code that creates an Animal class and two subclasses Do. Vulnerability Vector: Unchecked casts can lead to ClassCastException if object is not of the type it i (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin open class Animal(val name: String) class Dog(name: String) : Animal(name) class Cat(name: String) : Animal(name) fun main() { val animal = Animal("Generic Animal") val dog = Dog("Dog") val cat = Cat("Cat") val animals = arrayOf(animal, dog, cat) for (animal in animals) { if (an...
<think> Target: kotlin implementation for Write a kotlin code that creates an Animal class and two subclasses Do. Vulnerability Vector: Unchecked casts can lead to ClassCastException if object is not of the type it i (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin open class Animal(val name: String) class Dog(name: String) : Animal(name) class Cat(name: String) : Animal(name) fun main() { val animal = Animal("Generic Animal") val dog = Dog("Dog") val cat = Cat("Cat") val animals = arrayOf(animal, dog, cat) for (animal in animals) { val ca...
244
0.86
cyber_1a791b837797
vulnerability_research_cve
CWE-787
Write a fortran code that reads two strings from the user, concatenates them and prints the result.
Target: fortran implementation for Write a fortran code that reads two strings from the user, concatenate. Vulnerability Vector: In Fortran, buffer overflow vulnerabilities can occur when a programmer does not (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer, parameter :: max_len = 100 character(len=max_len) :: string1, string2, string3 read*, string1 read*, string2 if(len_trim(string1) + len_trim(string2) > max_len) then print*, "Error: Concatenated string exceeds maximum length" else ...
<think> Target: fortran implementation for Write a fortran code that reads two strings from the user, concatenate. Vulnerability Vector: In Fortran, buffer overflow vulnerabilities can occur when a programmer does not (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none character(len=4) :: string1 character(len=6) :: string2 read*, string1 read*, string2 print*, string1//string2 end program main ```
243
0.55
cyber_d93b02bc9764
vulnerability_research_cve
CWE-502
Write a python code that uses pickle module to serialize and deserialize an object. The object should be a class named 'VulnerableClass'. This class should have a method named '__reduce__' which returns a tuple containing the function 'os.system' and a string argument 'echo "You have been hacked!"'. Then create an inst...
Target: python implementation for Write a python code that uses pickle module to serialize and deseriali. Vulnerability Vector: The use of pickle module can lead to arbitrary code execution vulnerabilities if (CWE-502). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```python import pickle import subprocess class SafeClass: def __init__(self): self.message = "You have been hacked!" def __reduce__(self): return (subprocess.run, (['echo', self.message],)) def serialize_and_deserialize(safe_obj): serialized = pickle.dumps(safe_obj) deserialized = pi...
<think> Target: python implementation for Write a python code that uses pickle module to serialize and deseriali. Vulnerability Vector: The use of pickle module can lead to arbitrary code execution vulnerabilities if (CWE-502). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```python import pickle import os class VulnerableClass: def __reduce__(self): return (os.system, ('echo "You have been hacked!"',)) def serialize_and_deserialize(vuln_obj): serialized = pickle.dumps(vuln_obj) deserialized = pickle.loads(serialized) return deserialized vuln_obj = VulnerableCl...
248
0.83
cyber_03a65411bedb
vulnerability_research_cve
CWE-787
Write a java code that creates an integer array of size 10 and fills it with numbers from 0 to 9.
Target: java implementation for Write a java code that creates an integer array of size 10 and fills i. Vulnerability Vector: Potential buffer overflow vulnerability in Java when handling arrays or strings (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```java public class Main { public static void main(String[] args) { int[] array = new int[10]; for (int i = 0; i < array.length; i++) { array[i] = i; } } } ```
<think> Target: java implementation for Write a java code that creates an integer array of size 10 and fills i. Vulnerability Vector: Potential buffer overflow vulnerability in Java when handling arrays or strings (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```java public class Main { public static void main(String[] args) { int[] array = new int[10]; for (int i = 0; i <= 10; i++) { array[i] = i; } } } ```
177
0.8
cyber_8564d9f5c7c5
vulnerability_research_cve
CWE-20
Write a ruby code that takes user input, evaluates it as Ruby code and prints the result.
Target: ruby implementation for Write a ruby code that takes user input, evaluates it as Ruby code and. Vulnerability Vector: Ruby's built-in library 'eval' function can lead to Code Injection if not used c (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby def evaluate_user_input(input) begin eval(input) rescue SecurityError => e puts "SecurityError: #{e}" rescue SyntaxError => e puts "SyntaxError: #{e}" end end puts "Enter some Ruby code to evaluate:" user_input = gets.chomp evaluate_user_input(user_input) ```
<think> Target: ruby implementation for Write a ruby code that takes user input, evaluates it as Ruby code and. Vulnerability Vector: Ruby's built-in library 'eval' function can lead to Code Injection if not used c (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby def evaluate_user_input(input) eval(input) end puts "Enter some Ruby code to evaluate:" user_input = gets.chomp evaluate_user_input(user_input) ```
212
0.61
cyber_835f0a81c884
vulnerability_research_cve
CWE-89
Write a kotlin code that reads a username and password from the console, connects to a MySQL database using JDBC, prepares a SQL query to select all records from the 'users' table where the 'username' matches the inputted username and 'password' matches the inputted password, executes the query, and prints 'Login succe...
Target: kotlin implementation for Write a kotlin code that reads a username and password from the consol. Vulnerability Vector: Improper input validation or sanitization vulnerabilities in Kotlin programs may (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin import java.sql.Connection import java.sql.DriverManager import java.sql.PreparedStatement fun main(args: Array<String>) { val username = readLine()!! val password = readLine()!! val connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase", "root", "password") val sta...
<think> Target: kotlin implementation for Write a kotlin code that reads a username and password from the consol. Vulnerability Vector: Improper input validation or sanitization vulnerabilities in Kotlin programs may (CWE-89). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin import java.sql.Connection import java.sql.DriverManager import java.sql.PreparedStatement fun main(args: Array<String>) { val username = readLine()!! val password = readLine()!! val connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase", "root", "password") val sta...
294
0.77
cyber_cb08a504c4f2
vulnerability_research_cve
CWE-20
Write a fortran code that calculates the sum of integers from 1 to 10 and then subtracts the integers from 1 to 10 from a variable 'y'. The code uses a 'goto' statement which is not recommended in modern programming.
Target: fortran implementation for Write a fortran code that calculates the sum of integers from 1 to 10 . Vulnerability Vector: The 'goto' statement in Fortran can lead to uncontrolled flow of execution, maki (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```fortran program main implicit none integer :: i, j real :: x, y ! Initialize variables x = 0 y = 0 ! Calculate the sum of integers from 1 to 10 do i = 1, 10 x = x + i end do ! Subtract the integers from 1 to 10 from a variable 'y' do j = 1, 10 ...
<think> Target: fortran implementation for Write a fortran code that calculates the sum of integers from 1 to 10 . Vulnerability Vector: The 'goto' statement in Fortran can lead to uncontrolled flow of execution, maki (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```fortran program main implicit none integer :: i, j real :: x, y ! Bad practice: Using 'goto' statement without proper control flow structure goto 10 ! Normal program operation do i = 1, 10 x = x + i end do ! Jump to this part of the program 10 continue ...
309
0.67
cyber_aeb448fc4bed
vulnerability_research_cve
CWE-787
Write a c++ code that includes the string library. Define a function named 'copy_data' which takes two character pointers and an integer as arguments. This function should use the memcpy function from the string library to copy data from the source pointer to the destination pointer for the given size. In the main func...
Target: c++ implementation for Write a c++ code that includes the string library. Define a function n. Vulnerability Vector: The use of memcpy and similar functions from string.h library without checking t (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <string.h> void copy_data(char* dest, const char* src, size_t destSize) { size_t srcLen = strlen(src); if (srcLen + 1 <= destSize) { // +1 for null terminator memcpy(dest, src, srcLen + 1); // Copy including null terminator } else { // Handle error here, e.g., truncate strin...
<think> Target: c++ implementation for Write a c++ code that includes the string library. Define a function n. Vulnerability Vector: The use of memcpy and similar functions from string.h library without checking t (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <string.h> void copy_data(char* dest, char* src, int size) { memcpy(dest, src, size); } int main() { char src[10] = "Hello, World!"; char dest[5]; copy_data(dest, src, sizeof(src)); return 0; } ```
310
0.54
cyber_e743d1ea5270
vulnerability_research_cve
CWE-20
Write a go code that opens a file named 'non_existent_file.txt' and handles any error that might occur during the file opening process.
Target: go implementation for Write a go code that opens a file named 'non_existent_file.txt' and ha. Vulnerability Vector: Go does not have built-in support for handling exceptions or errors. This might (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation S...
```go package main import ( "fmt" "os" ) func main() { file, err := os.Open("non_existent_file.txt") if err != nil { fmt.Println("Error occurred while opening the file:", err) return } defer func() { err = file.Close() if err != nil { fmt.Println("Error occurred while closing the file:", err) } }(...
<think> Target: go implementation for Write a go code that opens a file named 'non_existent_file.txt' and ha. Vulnerability Vector: Go does not have built-in support for handling exceptions or errors. This might (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```go package main import ( "fmt" "os" ) func main() { file, err := os.Open("non_existent_file.txt") if err != nil { fmt.Println(err)ivalidInputError } defer file.Close() } ```
254
0.6
cyber_6cc2bfdef617
vulnerability_research_cve
CWE-476
Write a kotlin code that creates a class named 'User' with two properties 'name' and 'age'. The 'name' property should be nullable and the 'age' property should also be nullable. In the 'User' class, create a function named 'printInfo' which prints out the 'name' and 'age' of the user. In the main function, create an i...
Target: kotlin implementation for Write a kotlin code that creates a class named 'User' with two propert. Vulnerability Vector: NullPointerException could occur while accessing uninitialized objects without p (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```kotlin class User(var name: String?, var age: Int?) { fun printInfo() { println("Name: ${name ?: "Not Provided"}") println("Age: ${age ?: "Not Provided"}") } } fun main() { val user = User(null, 25) user.printInfo() } ```
<think> Target: kotlin implementation for Write a kotlin code that creates a class named 'User' with two propert. Vulnerability Vector: NullPointerException could occur while accessing uninitialized objects without p (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```kotlin class User(var name: String?, var age: Int?) { fun printInfo() { println("Name: $name") println("Age: $age") } } fun main() { val user = User(null, 25) user.printInfo() } ```
205
0.76
cyber_22db70bd3f04
vulnerability_research_cve
CWE-190
Write a fortran code that demonstrates integer overflow. Initialize two 4-byte integers `i` and `j` with `i` being the maximum value for a 4-byte integer and `j` being 1. Then add `i` and `j` and store the result in `k`. This will cause an integer overflow error because the sum of `i` and `j` exceeds the maximum limit ...
Target: fortran implementation for Write a fortran code that demonstrates integer overflow. Initialize tw. Vulnerability Vector: The code may be vulnerable to integer overflow errors, which can occur when arit (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program integer_overflow use, intrinsic :: iso_fortran_env, only : int32 implicit none integer(int32) :: i, j, k i = huge(i) ! Maximum value for a 4-byte integer j = 1 if (will_overflow(i, j)) then print*, 'Integer overflow will occur. Exiting...' stop else ...
<think> Target: fortran implementation for Write a fortran code that demonstrates integer overflow. Initialize tw. Vulnerability Vector: The code may be vulnerable to integer overflow errors, which can occur when arit (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program integer_overflow implicit none integer(kind=4) :: i, j, k i = 2147483647 ! Maximum value for a 4-byte integer j = 1 k = i + j ! This will cause an integer overflow error print*, 'Value of k after overflow: ', k end program integer_overflow ```
365
0.48
cyber_edab71f1e33c
vulnerability_research_cve
CWE-787
Write a c++ code that includes the necessary libraries. Define a function named 'copyData' which takes two character pointers as arguments. This function should use the 'strcpy' function from the cstring library to copy the content of one character array into another. In the main function, declare two character arrays,...
Target: c++ implementation for Write a c++ code that includes the necessary libraries. Define a funct. Vulnerability Vector: The 'strcpy' function in C++ does not check if the destination buffer is large e (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <cstring> #include <stdexcept> void copyData(char* dest, const char* src, size_t destSize) { if (strlen(src) >= destSize) { throw std::runtime_error("Buffer overflow detected!"); } strcpy(dest, src); } int main() { char largeBuffer[1024]; char smallBuffer[64]; try { ...
<think> Target: c++ implementation for Write a c++ code that includes the necessary libraries. Define a funct. Vulnerability Vector: The 'strcpy' function in C++ does not check if the destination buffer is large e (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <cstring> void copyData(char* dest, const char* src) { strcpy(dest, src); // Vulnerable line } int main() { char largeBuffer[1024]; char smallBuffer[64]; copyData(largeBuffer, "This is a long string that will cause a buffer overflow!"); copyData(smallBuffer, "This is a short strin...
324
0.59
cyber_3e7f4ab20398
vulnerability_research_cve
CWE-20
Write a python code that uses Flask framework to create a web application. The application should have two routes, one at the root ('/'), and another at '/unsafe'. The first route should render a template string that says 'Hello, {user}', where '{user}' is replaced by the value of the 'user' parameter in the URL query ...
Target: python implementation for Write a python code that uses Flask framework to create a web applicat. Vulnerability Vector: In Python, there is a potential vulnerability due to unsafe use of the 'eval' fu (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python from flask import Flask, request, render_template_string app = Flask(__name__) @app.route('/') def index(): user = request.args.get('user', 'guest') return render_template_string('Hello, {}'.format(user)) @app.route('/safe') def safe(): user_input = request.args.get('user') if user_input is...
<think> Target: python implementation for Write a python code that uses Flask framework to create a web applicat. Vulnerability Vector: In Python, there is a potential vulnerability due to unsafe use of the 'eval' fu (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import flask app = flask.Flask(__name__) @app.route('/') def index(): return flask.render_template_string('Hello, {{ user }}', user=flask.request.args.get('user', 'guest')) @app.route('/unsafe') def unsafe(): user_input = flask.request.args.get('user') return eval(user_input) if __name__ == '__...
313
0.63
cyber_579b6531ebf7
vulnerability_research_cve
CWE-20
Write a java code that generates a random number using a seed value. The class should be named 'VulnerableClass' and have a method called 'getRandomNumber'. This method should generate a random number using the seed value 1234567890.
Target: java implementation for Write a java code that generates a random number using a seed value. T. Vulnerability Vector: The Random class in Java is known to be susceptible to predictable seed values, (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.security.SecureRandom; public class SecureClass { private static final long SEED = 1234567890L; public int getRandomNumber() { SecureRandom secureRandom = new SecureRandom(); secureRandom.setSeed(SEED); return secureRandom.nextInt(); } } ```
<think> Target: java implementation for Write a java code that generates a random number using a seed value. T. Vulnerability Vector: The Random class in Java is known to be susceptible to predictable seed values, (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.util.Random; public class VulnerableClass { private static final long SEED = 1234567890L; public int getRandomNumber() { Random random = new Random(SEED); return random.nextInt(); } } ```
201
0.75
cyber_760a77458657
vulnerability_research_cve
CWE-20
Write a javascript code that takes a string input from a user, evaluates it using the eval() function and displays an alert box with the message 'This is an alert from eval'.
Target: javascript implementation for Write a javascript code that takes a string input from a user, evaluat. Vulnerability Vector: Insecure Use of eval() in JavaScript can lead to code injection attacks (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation St...
```javascript let userInput = prompt("Enter your message"); if (userInput) { alert(userInput); } else { alert('This is an alert from eval'); } ```
<think> Target: javascript implementation for Write a javascript code that takes a string input from a user, evaluat. Vulnerability Vector: Insecure Use of eval() in JavaScript can lead to code injection attacks (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitig...
```javascript let userInput = "alert('This is an alert from eval');"; eval(userInput); ```
154
0.65
cyber_09cfd5b60ee2
vulnerability_research_cve
CWE-78
Write a swift code that defines an enum `MyError` which conforms to the Error protocol and has a case `invalidInput`. Define a function `dangerousFunction` that takes an optional string as input. If the input is not nil, it returns the unwrapped value. If the input is nil, it throws an error of type `MyError.invalidInp...
Target: swift implementation for Write a swift code that defines an enum `MyError` which conforms to th. Vulnerability Vector: Swift's error handling mechanism can result in forced unwrapping of optional val (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigatio...
```swift import Foundation enum MyError: Error { case invalidInput } func dangerousFunction(input: String?) throws -> String { guard let unwrappedInput = input else { throw MyError.invalidInput } return unwrappedInput } do { let result = try dangerousFunction(input: nil) print(re...
<think> Target: swift implementation for Write a swift code that defines an enum `MyError` which conforms to th. Vulnerability Vector: Swift's error handling mechanism can result in forced unwrapping of optional val (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. M...
```swift import Foundation enum MyError: Error { case invalidInput } func dangerousFunction(input: String?) throws -> String { guard let unwrappedInput = input else { throw MyError.invalidInput } return unwrappedInput } do { let result = try dangerousFunction(input: nil) print(re...
255
0.72
cyber_9011b43acb1c
vulnerability_research_cve
CWE-787
Write a go code that reads input from the standard input (stdin) in chunks of 1024 bytes and prints out the number of bytes read each time until an error occurs.
Target: go implementation for Write a go code that reads input from the standard input (stdin) in ch. Vulnerability Vector: Buffer Overflow can occur if the input size exceeds the buffer size, leading to (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "bufio" "fmt" "os" ) func main() { reader := bufio.NewReaderSize(os.Stdin, 1024) for { input, err := reader.ReadByte() if err != nil { fmt.Println("Error reading input:", err) Hawk: return } fmt.Println("Read", len(input), "bytes") } } ```
<think> Target: go implementation for Write a go code that reads input from the standard input (stdin) in ch. Vulnerability Vector: Buffer Overflow can occur if the input size exceeds the buffer size, leading to (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "os" ) func main() { input := make([]byte, 1024) for { n, err := os.Stdin.Read(input) if err != nil { fmt.Println("Error reading input:", err) return } fmt.Println("Read", n, "bytes") } } ```
239
0.78
cyber_6c9b502a375e
vulnerability_research_cve
CWE-20
Write a python code that takes user input, tries to execute it as a shell command using the 'os' module, and if it fails, it tries to execute it as a python expression using the 'eval' function.
Target: python implementation for Write a python code that takes user input, tries to execute it as a sh. Vulnerability Vector: Python's eval() function can execute arbitrary code, posing a security risk if u (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import subprocess import ast def run_command(user_input): command = ["echo", user_input] subprocess.run(command, check=True) def run_eval(user_input): tree = ast.parse(user_input, mode='single') if len(tree.body) != 1 or not isinstance(tree.body[0], ast.Expr): raise ValueError('Not a...
<think> Target: python implementation for Write a python code that takes user input, tries to execute it as a sh. Vulnerability Vector: Python's eval() function can execute arbitrary code, posing a security risk if u (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import os def run_command(user_input): command = "echo %s" % user_input os.system(command) def run_eval(user_input): eval(user_input) while True: user_input = input("Enter your command: ") try: run_command(user_input) except Exception as e: print("Error: ", e) ...
321
0.59
cyber_93e283a92be5
vulnerability_research_cve
CWE-20
Write a java code that creates an ArrayList of Objects, adds a String and an Integer to it, then iterates over the list and prints each object as a String.
Target: java implementation for Write a java code that creates an ArrayList of Objects, adds a String . Vulnerability Vector: The use of unchecked casts in Java can lead to ClassCastException at runtime if (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java import java.util.*; public class Main { public static void main(String[] args) { List<Object> list = new ArrayList<>(); list.add("Hello World"); list.add(123); for (Object obj : list) { if (obj instanceof String) { String str = (String) o...
<think> Target: java implementation for Write a java code that creates an ArrayList of Objects, adds a String . Vulnerability Vector: The use of unchecked casts in Java can lead to ClassCastException at runtime if (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java import java.util.*; public class Main { public static void main(String[] args) { List<Object> list = new ArrayList<>(); list.add("Hello World"); list.add(123); for (Object obj : list) { String str = (String) obj; // Unchecked cast System.out....
256
0.68
cyber_6cdbf36bc7fb
vulnerability_research_cve
CWE-787
Write a c# code that asks the user for their name and then prints out 'Hello' followed by the user's name.
Target: c# implementation for Write a c# code that asks the user for their name and then prints out . Vulnerability Vector: The vulnerability in C# could be a potential buffer overflow, which can occur wh (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c# using System; public class Program { public static void Main() { Console.WriteLine("Enter your name:"); string userInput = Console.ReadLine(); // Validate the user input if (!string.IsNullOrWhiteSpace(userInput)) { Console.WriteLine("Hello " + userInpu...
<think> Target: c# implementation for Write a c# code that asks the user for their name and then prints out . Vulnerability Vector: The vulnerability in C# could be a potential buffer overflow, which can occur wh (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c# using System; using System.Text; public class Program { public static void Main() { Console.WriteLine("Enter your name:"); string userInput = Console.ReadLine(); int bufferSize = 10; byte[] buffer = new byte[bufferSize]; Encoding.ASCII.GetBytes(userInput)....
227
0.87
cyber_cd8cefe61ebf
vulnerability_research_cve
CWE-20
Write a php code that gets user input from the URL, extracts it into variables, and then evaluates the variable 'variable' using eval().
Target: php implementation for Write a php code that gets user input from the URL, extracts it into v. Vulnerability Vector: PHP's extract() function can lead to Code Injection due to its ability to create (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php $user_input = $_GET['user_input']; parse_str($user_input, $variables); if(isset($variables['variable'])){ eval("echo $variables['variable'];"); } ?> ```
<think> Target: php implementation for Write a php code that gets user input from the URL, extracts it into v. Vulnerability Vector: PHP's extract() function can lead to Code Injection due to its ability to create (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php $user_input = $_GET['user_input']; extract($user_input); eval("echo $variable;"); ?> ```
169
0.65
cyber_200253b36d97
vulnerability_research_cve
CWE-787
Write a go code that takes user input and executes it as a system command.
Target: go implementation for Write a go code that takes user input and executes it as a system comm. Vulnerability Vector: Improper handling of user input can lead to buffer overflow vulnerabilities. (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Stra...
```go package main import ( "bufio" "errors" "fmt" "os" "os/exec" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Enter your command: ") input, _ := reader.ReadString('\n') input = strings.TrimSuffix(input, "\n") err := executeCommand(input) if err != nil { fmt.Println("Error:"...
<think> Target: go implementation for Write a go code that takes user input and executes it as a system comm. Vulnerability Vector: Improper handling of user input can lead to buffer overflow vulnerabilities. (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```go package main import ( "fmt" "os/exec" ) func main() { var input string fmt.Println("Enter your command:") fmt.Scan(&input) cmd := exec.Command(input) err := cmd.Run() if err != nil { fmt.Println("Error:", err)议 } } ```
366
0.47
cyber_5937e151260b
vulnerability_research_cve
CWE-20
Write a kotlin code that defines an `Animal` class with a method `sound()` which prints 'Animal makes sound'. Then, define a `Dog` class that extends `Animal` and overrides the `sound()` method to print 'Dog barks'. In the `main` function, create two instances of `Animal`, one is a `Dog` and another is just an `Animal`...
Target: kotlin implementation for Write a kotlin code that defines an `Animal` class with a method `soun. Vulnerability Vector: Type casting can lead to ClassCastException if done improperly. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strategy: Enfo...
```kotlin open class Animal { open fun sound() { println("Animal makes sound") } } class Dog : Animal() { override fun sound() { println("Dog barks") } } fun main(args: Array<String>) { val animal1: Animal = Dog() val animal2: Animal = Animal() // This will work fine i...
<think> Target: kotlin implementation for Write a kotlin code that defines an `Animal` class with a method `soun. Vulnerability Vector: Type casting can lead to ClassCastException if done improperly. (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation Strate...
```kotlin open class Animal { open fun sound() { println("Animal makes sound") } } class Dog : Animal() { override fun sound() { println("Dog barks") } } fun main(args: Array<String>) { val animal1: Animal = Dog() val animal2: Animal = Animal() // This will work fine i...
294
0.86
cyber_abbcfa2db02b
vulnerability_research_cve
CWE-190
Write a fortran code that demonstrates integer overflow. Initialize an integer variable with the maximum limit of integer*4. Then add 1 to this variable and store the result in another integer variable. Print the result of this operation.
Target: fortran implementation for Write a fortran code that demonstrates integer overflow. Initialize an. Vulnerability Vector: The integer overflow vulnerability in Fortran can occur when the result of arith (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program integer_overflow implicit none integer*4 :: i, j, k i = 2147483647 ! Maximum limit of integer*4 j = 1 k = i + j ! Here, the result of this operation will exceed the maximum limit of integer*4 ! Check if the result of addition is greater than the maximum limit of in...
<think> Target: fortran implementation for Write a fortran code that demonstrates integer overflow. Initialize an. Vulnerability Vector: The integer overflow vulnerability in Fortran can occur when the result of arith (CWE-190). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program integer_overflow implicit none integer*4 :: i, j, k i = 2147483647 ! Maximum limit of integer*4 j = 1 k = i + j ! Here, the result of this operation will exceed the maximum limit of integer*4 print*, 'Result of overflow: ', k end program integer_overflow ```
262
0.65
cyber_cf1fbe378ec0
vulnerability_research_cve
CWE-20
Write a python code that creates a server socket and listens for incoming connections. When a client connects, receive data from the client and print it out. If no data is received, print an error message. Close the connection after each client.
Target: python implementation for Write a python code that creates a server socket and listens for incom. Vulnerability Vector: In Python, improper handling of exceptions during I/O operations can lead to Den (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import socket import errno def handle_client(client_socket): try: data = client_socket.recv(1024) if not data: raise Exception("No data received") print("Received: ", data) except socket.error as e: if e.errno != errno.ECONNRESET: raise ...
<think> Target: python implementation for Write a python code that creates a server socket and listens for incom. Vulnerability Vector: In Python, improper handling of exceptions during I/O operations can lead to Den (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import socket def handle_client(client_socket): try: data = client_socket.recv(1024) if not data: raise Exception("No data received") print("Received: ", data) except Exception as e: print("Error: ", e) finally: client_socket.close() def main()...
384
0.68
cyber_3c9cd4e1d5f4
vulnerability_research_cve
CWE-20
Write a java code that creates a thread that continuously prints 'Working...' until it is stopped. The stopping mechanism should be implemented using a shared variable 'stop'. The main method starts the thread, waits for one second, and then stops the thread.
Target: java implementation for Write a java code that creates a thread that continuously prints 'Work. Vulnerability Vector: The use of Thread.stop() method in Java can lead to unpredictable behavior and d (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```java public class SecureOptimizedThread implements Runnable { private volatile boolean stop = false; @Override public void run() { while (!stop) { // Do some work System.out.println("Working...");archar } } public void stopThread() { stop = true; ...
<think> Target: java implementation for Write a java code that creates a thread that continuously prints 'Work. Vulnerability Vector: The use of Thread.stop() method in Java can lead to unpredictable behavior and d (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```java public class VulnerableThread extends Thread { private volatile boolean stop = false; public void run() { while (!stop) { // Do some work System.out.println("Working..."); } } public void stopThread() { stop = true;lowing } public static...
275
0.8
cyber_7bd8bc67d02d
vulnerability_research_cve
CWE-89
Write a c# code that reads a username and password from the console, then connects to a SQL Server database using the provided credentials. It executes a SQL query to check if there's a record in the 'Users' table where the 'Username' matches the inputted username and the 'Password' matches the inputted password. If su...
Target: c# implementation for Write a c# code that reads a username and password from the console, t. Vulnerability Vector: Unvalidated input from end-users can lead to SQL Injection if the user input is (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) { var 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 reads a username and password from the console, t. Vulnerability Vector: Unvalidated input from end-users can lead to SQL Injection if the user input is (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) { var connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connection = new SqlConnection(connectionString)) {...
406
0.83
cyber_27ac2840a6ed
vulnerability_research_cve
CWE-20
Write a ruby code that loads a YAML string into an object of class UnsafeUser and prints out the object attributes.
Target: ruby implementation for Write a ruby code that loads a YAML string into an object of class Uns. Vulnerability Vector: Ruby's use of YAML library can lead to code execution vulnerabilities due to its (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby require 'yaml' class SafeUser attr_accessor :name, :email def initialize(name, email) @name = name @email = email end end # Ensure that only instances of SafeUser can be dumped and loaded YAML::add_builtin_type('ruby/object', SafeUser) do |type, val| obj = Object.new if val.is_a?(SafeUser) ...
<think> Target: ruby implementation for Write a ruby code that loads a YAML string into an object of class Uns. Vulnerability Vector: Ruby's use of YAML library can lead to code execution vulnerabilities due to its (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby require 'yaml' class UnsafeUser attr_accessor :name, :email def initialize(name, email) @name = name @email = email end end user_data = "!!ruby/object:UnsafeUser\nname: User1\nemail: user1@example.com" user = YAML.load(user_data) puts user.inspect ```
300
0.6
cyber_3c22218868f9
vulnerability_research_cve
CWE-362
Write a go code that uses goroutines and mutexes to increment a counter 1000 times concurrently. The final value of the counter should be printed out.
Target: go implementation for Write a go code that uses goroutines and mutexes to increment a counte. Vulnerability Vector: Go doesn't have built-in support for thread synchronization or concurrent progra (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "sync" ) type Counter struct { sync.RWMutex count int } func (c *Counter) Increment() { c.Lock() defer c.Unlock() c.count++ } func (c *Counter) Value() int { c.RLock() defer c.RUnlock() return c.count } func main() { var wg sync.WaitGroup var counter Counter for i :=...
<think> Target: go implementation for Write a go code that uses goroutines and mutexes to increment a counte. Vulnerability Vector: Go doesn't have built-in support for thread synchronization or concurrent progra (CWE-362). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "sync" ) type Counter struct { sync.Mutex count int } func (c *Counter) Increment() { c.Lock() defer c.Unlock() c.count++ } func (c *Counter) Value() int { return c.count } func main() { var wg sync.WaitGroup var counter Counter for i := 0; i < 1000; i++ { wg.Add(1) ...
329
0.83
cyber_6585b41e53ae
vulnerability_research_cve
CWE-476
Write a kotlin code that compares two strings, 'str1' and 'str2'. If they are equal, print 'Strings are equal', otherwise print 'Strings are not equal'. The values of 'str1' and 'str2' are 'Hello' and null respectively.
Target: kotlin implementation for Write a kotlin code that compares two strings, 'str1' and 'str2'. If t. Vulnerability Vector: The '==' operator for nullable types in Kotlin can lead to NullPointerException (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```kotlin fun main(args: Array<String>) { val str1: String? = "Hello" val str2: String? = null if (str1.equals(str2)) { println("Strings are equal") } else { println("Strings are not equal") ready } } ```
<think> Target: kotlin implementation for Write a kotlin code that compares two strings, 'str1' and 'str2'. If t. Vulnerability Vector: The '==' operator for nullable types in Kotlin can lead to NullPointerException (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```kotlin fun main(args: Array<String>) { val str1: String? = "Hello" val str2: String? = null if (str1 == str2) { println("Strings are equal") } else { println("Strings are not equal") } } ```
202
0.76
cyber_403c327464c2
vulnerability_research_cve
CWE-787
Write a fortran code that reads a string of maximum length 5 from the user and then prints 'Hello' followed by the inputted name.
Target: fortran implementation for Write a fortran code that reads a string of maximum length 5 from the . Vulnerability Vector: Buffer Overflow vulnerability can occur when a programmer does not properly allo (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none character(len=100) :: name read*, name print*, "Hello, ", trim(name) end program main ```
<think> Target: fortran implementation for Write a fortran code that reads a string of maximum length 5 from the . Vulnerability Vector: Buffer Overflow vulnerability can occur when a programmer does not properly allo (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none character(len=5) :: name read*, name print*, "Hello, ", name end program main ```
156
0.73
cyber_5f21e19a1e1a
vulnerability_research_cve
CWE-78
Write a python code that imports the 'os' and 'subprocess' modules. Define two functions named 'execute_command' and 'execute_command_subprocess'. These functions should take a string input from the user and execute it using the 'os.system' and 'subprocess.Popen' respectively. The 'shell' parameter in 'subprocess.Popen...
Target: python implementation for Write a python code that imports the 'os' and 'subprocess' modules. De. Vulnerability Vector: The code may be vulnerable to command injection attacks through the use of the o (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import os import subprocess def execute_command(user_input): # Secure code - This will not lead to command injection os.system('echo "{}" | bash -s'.format(user_input)) def execute_command_subprocess(user_input): # Secure code - This will not lead to command injection subprocess.Popen(['/bin...
<think> Target: python implementation for Write a python code that imports the 'os' and 'subprocess' modules. De. Vulnerability Vector: The code may be vulnerable to command injection attacks through the use of the o (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import os import subprocess def execute_command(user_input): # Vulnerable code - This may lead to command injection os.system(user_input) def execute_command_subprocess(user_input): # Vulnerable code - This may lead to command injection subprocess.Popen(user_input, shell=True) # Testing the...
251
0.79
cyber_ee742aed8b8b
vulnerability_research_cve
CWE-78
Write a java code that serializes and deserializes an object of type String. The string should be 'Hello World'. If any exception occurs during the process, print the stack trace.
Target: java implementation for Write a java code that serializes and deserializes an object of type S. Vulnerability Vector: Insecure deserialization can lead to remote code execution in Java applications. (CWE-78). 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) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject("Hello World"); byte[] bytes = baos.t...
<think> Target: java implementation for Write a java code that serializes and deserializes an object of type S. Vulnerability Vector: Insecure deserialization can lead to remote code execution in Java applications. (CWE-78). 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 { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject("Hello World"); byte[] bytes = baos.t...
267
0.84
cyber_10df23b61fd4
vulnerability_research_cve
CWE-20
Write a javascript code that defines two functions, one named `unsafeFunction` and another named `sanitizeInput`. The `unsafeFunction` function takes an argument `userInput`, sanitizes it using the `sanitizeInput` function, and then evaluates the sanitized input using the `eval()` function. The `sanitizeInput` function...
Target: javascript implementation for Write a javascript code that defines two functions, one named `unsafeF. Vulnerability Vector: The vulnerability lies in the use of eval() function in JavaScript which can exe (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript function unsafeFunction(userInput) { var sanitizedInput = sanitizeInput(userInput); Function('"use strict";return (' + sanitizedInput + ')')(); } function sanitizeInput(input) { // This is a very basic sanitization function. In a real-world scenario, you would need a more robust function. ...
<think> Target: javascript implementation for Write a javascript code that defines two functions, one named `unsafeF. Vulnerability Vector: The vulnerability lies in the use of eval() function in JavaScript which can exe (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript function unsafeFunction(userInput) { var sanitizedInput = sanitizeInput(userInput); eval(sanitizedInput); } function sanitizeInput(input) { // This is a very basic sanitization function. In a real-world scenario, you would need a more robust function. return input.replace(/[^a-zA-Z0-9]/g,...
236
0.8
cyber_94175070d6d2
vulnerability_research_cve
CWE-89
Write a c# code that handles user input and connects to a SQL database. The code should take the user's input, construct a SQL query with it, execute the query on the database, and print out the result.
Target: c# implementation for Write a c# code that handles user input and connects to a SQL database. Vulnerability Vector: Improper handling of user input and SQL Injection vulnerabilities are common iss (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 UserInputHandler { private readonly string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; public void HandleUserInput(string userInput) { using (SqlConnection connection = ne...
<think> Target: c# implementation for Write a c# code that handles user input and connects to a SQL database. Vulnerability Vector: Improper handling of user input and SQL Injection vulnerabilities are common iss (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 UserInputHandler { public void HandleUserInput(string userInput) { string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; using (SqlConnection connection = new SqlConnection(co...
334
0.77
cyber_76cc5f526f84
vulnerability_research_cve
CWE-79
Write a php code that retrieves the value from a POST request named 'name' and then echoes out a greeting message including the name.
Target: php implementation for Write a php code that retrieves the value from a POST request named 'n. Vulnerability Vector: PHP may face a Cross-Site Scripting (XSS) vulnerability if data inputted via HTT (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php if(isset($_POST['name'])) { $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING); echo htmlspecialchars("Hello, " . $name, ENT_QUOTES, 'UTF-8'); } else { echo "No name provided"; } ?> ```
<think> Target: php implementation for Write a php code that retrieves the value from a POST request named 'n. Vulnerability Vector: PHP may face a Cross-Site Scripting (XSS) vulnerability if data inputted via HTT (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php $name = $_POST['name']; echo "Hello, " . $name; ?> ```
203
0.5
cyber_43d41460066d
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 runs a shell command that prints 'Hello, World 🌍' to the response.
Target: go implementation for Write a go code that creates an HTTP server that listens on port 8080.. Vulnerability Vector: In Go, if an HTTP server is not properly configured, it may be exposed to buffer (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "context" "io" "net/http" "os/exec" "time" ) func handler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() cmd := exec.CommandContext(ctx, "/bin/sh", "-c", "echo Hello, World 🌍") stdout, _ := cmd.Std...
<think> Target: go implementation for Write a go code that creates an HTTP server that listens on port 8080.. Vulnerability Vector: In Go, if an HTTP server is not properly configured, it may be exposed to buffer (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "io" "net/http" "os/exec" ) func handler(w http.ResponseWriter, r *http.Request) { cmd := exec.Command("/bin/sh", "-c", "echo Hello, World 🌍") stdout, _ := cmd.StdoutPipe() cmd.Start() io.Copy(w, stdout) cmd.Wait() } func main() { http.HandleFunc("/", handler) http.ListenAndSer...
345
0.63
cyber_1d1b96f11020
vulnerability_research_cve
CWE-20
Write a kotlin code that takes two arguments from the command line, uses them to construct a SQL query string, connects to a MySQL database, executes the query and prints out the username if the user is found.
Target: kotlin implementation for Write a kotlin code that takes two arguments from the command line, us. Vulnerability Vector: Improper handling of user input may lead to injection attacks in Kotlin due to s (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```kotlin import java.sql.Connection import java.sql.DriverManager import java.sql.PreparedStatement fun main(args: Array<String>) { val username = args[0] val password = args[1] val query = "SELECT * FROM Users WHERE username = ? AND password = ?" val connection: Connection = DriverManager.getConnecti...
<think> Target: kotlin implementation for Write a kotlin code that takes two arguments from the command line, us. Vulnerability Vector: Improper handling of user input may lead to injection attacks in Kotlin due to s (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```kotlin import java.sql.Connection import java.sql.DriverManager import java.sql.PreparedStatement fun main(args: Array<String>) { val username = args[0] val password = args[1] val query = "SELECT * FROM Users WHERE username = '$username' AND password = '$password'" val connection: Connection = Drive...
306
0.77
cyber_2257f3d5fbe3
vulnerability_research_cve
CWE-787
Write a fortran code that creates an array of size 10 and fills it with numbers from 1 to 15. Then print out the elements of the array.
Target: fortran implementation for Write a fortran code that creates an array of size 10 and fills it wit. Vulnerability Vector: In Fortran, there's the potential for Buffer Overflow Vulnerability due to lack (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program buffer_overflow implicit none integer :: i integer, dimension(15) :: arr do i = 1, 15 arr(i) = i end do print*, "Array elements are:" do i = 1, 15 print*, arr(i)Bs end do end program buffer_overflow ```
<think> Target: fortran implementation for Write a fortran code that creates an array of size 10 and fills it wit. Vulnerability Vector: In Fortran, there's the potential for Buffer Overflow Vulnerability due to lack (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program buffer_overflow implicit none integer :: i integer, dimension(10) :: arr do i = 1, 15 arr(i) = i end do print*, "Array elements are:" do i = 1, 10 print*, arr(i) end do end program buffer_overflow ```
215
0.78
cyber_141afc1cb5b6
vulnerability_research_cve
CWE-78
Write a python code that imports pickle and os modules. Define a class named MyClass which has a method __reduce__ that returns a tuple containing os.system function and a string argument 'echo "you have been hacked"'. Then, use pickle.dumps to serialize an instance of MyClass and assign it to variable data. Finally, u...
Target: python implementation for Write a python code that imports pickle and os modules. Define a class. Vulnerability Vector: In Python, the usage of pickle module may lead to arbitrary code execution if da (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```python import pickle import subprocess class MyClass(object): def __init__(self, command): self.command = command def __reduce__(self): return (subprocess.Popen, (self.command,)) data = pickle.dumps(MyClass('echo "you have been hacked"')) pickle.loads(data) ```
<think> Target: python implementation for Write a python code that imports pickle and os modules. Define a class. Vulnerability Vector: In Python, the usage of pickle module may lead to arbitrary code execution if da (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```python import pickle import os class MyClass(object): def __reduce__(self): return (os.system, ('echo "you have been hacked"',)) data = pickle.dumps(MyClass()) pickle.loads(data) ```
199
0.7
cyber_a7b708e8394a
vulnerability_research_cve
CWE-79
Write a javascript code that creates a function named 'vulnerableFunction' which takes an input 'userInput'. This function should return a string that contains a script tag with an alert message containing the user's input. Then, get the user's input from the URL hash and pass it to the 'vulnerableFunction'. Finally, u...
Target: javascript implementation for Write a javascript code that creates a function named 'vulnerableFunct. Vulnerability Vector: Cross-Site Scripting (XSS) vulnerabilities in JavaScript can allow attackers to (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Miti...
```javascript function vulnerableFunction(userInput) { var div = document.createElement('div'); div.textContent = userInput; return div.innerHTML; } var userInput = location.hash.substring(1); document.body.appendChild(vulnerableFunction(userInput)); ```
<think> Target: javascript implementation for Write a javascript code that creates a function named 'vulnerableFunct. Vulnerability Vector: Cross-Site Scripting (XSS) vulnerabilities in JavaScript can allow attackers to (CWE-79). Root Cause: Missing bounds verification or improper memory handling prior to state mutati...
```javascript function vulnerableFunction(userInput) { return "<script>alert('" + userInput + "');</script>"; } var userInput = location.hash.substring(1); document.write(vulnerableFunction(userInput)); ```
187
0.72
cyber_e7f77355c0ad
vulnerability_research_cve
CWE-787
Write a c# code that defines a class named 'VulnerableClass'. This class should have a private character array named 'buffer' with a length of 10. The class should also have a method named 'AddToBuffer' which accepts a string as an argument. If the length of the input string is greater than 10, it should throw an Argum...
Target: c# implementation for Write a c# code that defines a class named 'VulnerableClass'. This cla. Vulnerability Vector: Buffer Overflow vulnerability in C# can occur when an array or string's size is (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```c# using System; public class SecureClass { private const int BufferSize = 10; private char[] buffer = new char[BufferSize]; public void AddToBuffer(string input) { if (input.Length > BufferSize) { throw new ArgumentException("Input too long"); } for (in...
<think> Target: c# implementation for Write a c# code that defines a class named 'VulnerableClass'. This cla. Vulnerability Vector: Buffer Overflow vulnerability in C# can occur when an array or string's size is (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```c# public class VulnerableClass { private char[] buffer = new char[10]; public void AddToBuffer(string input) { if (input.Length > 10) { throw new ArgumentException("Input too long"); } for (int i = 0; i < input.Length; i++) { buffer[i] = ...
247
0.75
cyber_80551dee4b51
vulnerability_research_cve
CWE-20
Write a php code that takes user input from the URL, unsanitizes it and passes it to the extract function. This function converts each element of an array into a variable. If the user injects malicious code through the URL, it will be executed.
Target: php implementation for Write a php code that takes user input from the URL, unsanitizes it an. Vulnerability Vector: The PHP 'extract' function can be used to create variables from user input, whic (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```php <?php // Sanitize user input $user_input = filter_input(INPUT_GET, 'user_input', FILTER_SANITIZE_STRING); // Check if user input is set if (isset($user_input)) { // Create an array with sanitized user input $data = ['user_input' => $user_input]; // Pass the sanitized data to the extract function ...
<think> Target: php implementation for Write a php code that takes user input from the URL, unsanitizes it an. Vulnerability Vector: The PHP 'extract' function can be used to create variables from user input, whic (CWE-20). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```php <?php $user_input = $_GET['user_input']; // Unsanitized user input is directly passed to extract function extract($user_input); // If user injects malicious code through $_GET['user_input'], it will be executed echo $malicious_variable; ?> ```
261
0.56
cyber_85922bdc6528
vulnerability_research_cve
CWE-78
Write a ruby code that takes user input and executes it as a system command using the 'system' method. The command should be 'ls' followed by the user'input.
Target: ruby implementation for Write a ruby code that takes user input and executes it as a system co. Vulnerability Vector: Improper input validation can lead to command injection in Ruby due to the use o (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```ruby def execute_command(user_input) sanitized_input = Shellwords.escape(user_input) system("ls", sanitized_input) end puts "Enter your command:" user_input = gets.chomp execute_command(user_input) ```
<think> Target: ruby implementation for Write a ruby code that takes user input and executes it as a system co. Vulnerability Vector: Improper input validation can lead to command injection in Ruby due to the use o (CWE-78). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```ruby def execute_command(user_input) system("ls #{user_input}") end puts "Enter your command:" user_input = gets.chomp execute_command(user_input) ```
182
0.7
cyber_f85971759981
vulnerability_research_cve
CWE-787
Write a swift code that imports the Foundation framework. Define a function named 'processData' which takes in a Data object as an argument. Inside this function, create a UInt8 array named 'buffer' and initialize it with 1024 zeros. Then, copy the bytes from the input Data object into the 'buffer' array. After definin...
Target: swift implementation for Write a swift code that imports the Foundation framework. Define a fun. Vulnerability Vector: A buffer overflow vulnerability in Swift can occur when the application writes m (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigati...
```swift import Foundation func processData(_ data: Data) { var buffer = [UInt8](repeating: 0, count: min(data.count, 1024)) data.copyBytes(to: &buffer, count: buffer.count) } let data = Data(repeating: 0xFF, count: 2048)! processData(data) ```
<think> Target: swift implementation for Write a swift code that imports the Foundation framework. Define a fun. Vulnerability Vector: A buffer overflow vulnerability in Swift can occur when the application writes m (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. ...
```swift import Foundation func processData(_ data: Data) { var buffer = [UInt8](repeating: 0, count: 1024) data.copyBytes(to: &buffer, count: buffer.count) } let data = Data(repeating: 0xFF, count: 2048)! processData(data) ```
203
0.81
cyber_546a33ddedfc
vulnerability_research_cve
CWE-787
Write a go code that takes command line arguments, converts them into bytes and copies them into an array of 256 bytes. Then print out the string representation of the copied bytes.
Target: go implementation for Write a go code that takes command line arguments, converts them into . Vulnerability Vector: Buffer Overflow vulnerability in Go can occur if the programmer does not properl (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation ...
```go package main import ( "fmt" "os" )ellow func main() { if len(os.Args) != 2 { fmt.Println("Please provide exactly one argument.") return } input := []byte(os.Args[1]) // Check if the input length is greater than 256 if len(input) > 256 { fmt.Println("Input too long. Please provide an input of at m...
<think> Target: go implementation for Write a go code that takes command line arguments, converts them into . Vulnerability Vector: Buffer Overflow vulnerability in Go can occur if the programmer does not properl (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mit...
```go package main import ( "fmt" "os" ) func main() { input := []byte(os.Args[1]) output := make([]byte, 256) copy(output, input) fmt.Println(string(output)) } ```
281
0.53
cyber_259caad6fca5
vulnerability_research_cve
CWE-476
Write a kotlin code that creates a Person object with a name and prints out the length of the name. If the name is null, it should throw a NullPointerException.
Target: kotlin implementation for Write a kotlin code that creates a Person object with a name and print. Vulnerability Vector: NullPointerException vulnerability due to unchecked null references can occur wh (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigat...
```kotlin fun main(args: Array<String>) { val person = Person("John Doe") println(person.getNameLength()) } class Person(val name: String?) { fun getNameLength(): Int { return name?.length ?: throw NullPointerException("Name cannot be null") } } ```
<think> Target: kotlin implementation for Write a kotlin code that creates a Person object with a name and print. Vulnerability Vector: NullPointerException vulnerability due to unchecked null references can occur wh (CWE-476). Root Cause: Missing bounds verification or improper memory handling prior to state mutation....
```kotlin fun main(args: Array<String>) { val person = Person("John Doe") println(person.name.length) // This will throw NullPointerException if person is null } class Person(val name: String?) ```
192
0.71
cyber_739bae1c90cc
vulnerability_research_cve
CWE-787
Write a fortran code that declares an array of size 10 and fills it with numbers from 1 to 15. Then print out all the elements in the array.
Target: fortran implementation for Write a fortran code that declares an array of size 10 and fills it wi. Vulnerability Vector: Potential buffer overflow vulnerability due to lack of checking array bounds in (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitiga...
```fortran program main implicit none integer, dimension(10) :: arr integer :: i do i=1, 10 arr(i) = i end do print*, "Array elements are:" do i=1, 10 print*, arr(i)员 end do end program main ```
<think> Target: fortran implementation for Write a fortran code that declares an array of size 10 and fills it wi. Vulnerability Vector: Potential buffer overflow vulnerability due to lack of checking array bounds in (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation...
```fortran program main implicit none integer, dimension(10) :: arr integer :: i do i=1, 15 arr(i) = i end do print*, "Array elements are:" do i=1, 15 print*, arr(i) end do end program main ```
205
0.8
cyber_cf5b3f9eba5c
vulnerability_research_cve
CWE-787
Write a c++ code that asks for a user's name and then prints 'Hello, [user's name]!'
Target: c++ implementation for Write a c++ code that asks for a user's name and then prints 'Hello, [. Vulnerability Vector: The lack of input validation and sanitization in C++ code can lead to buffer ove (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mitigation...
```c++ #include <iostream> #include <string> #include <algorithm> void print_name(const std::string& name) { std::cout << "Hello, " << name << "!\n"; } int main() { std::string name; std::getline(std::cin, name); // Remove leading and trailing whitespaces name.erase(name.begin(), std::find_if...
<think> Target: c++ implementation for Write a c++ code that asks for a user's name and then prints 'Hello, [. Vulnerability Vector: The lack of input validation and sanitization in C++ code can lead to buffer ove (CWE-787). Root Cause: Missing bounds verification or improper memory handling prior to state mutation. Mi...
```c++ #include <iostream> #include <string> void print_name(char* name) { char buffer[10]; strcpy(buffer, name); std::cout << "Hello, " << buffer << "!\n"; } int main() { char name[256]; std::cin >> name; print_name(name); return 0; } ```
319
0.56