Skip to content

About

An experiment project to evaluate a C/C++ Security Reviewer Agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Project: Vulnerability Discovery in C/C++ Code Using an Agentic AI Approach

This project was developed as part of my Master's degree in Industrial Safety and Security at the Technical University of Applied Sciences Augsburg (https://www.tha.de/).

As part of the Master's Seminar course, I conducted an experiment to evaluate the effectiveness of artificial intelligence in solving cybersecurity-related tasks. The focus of the research was vulnerability discovery in C/C++ codebases using an AI-powered security review agent.

To support the experiment, I developed a moderately complex test application and intentionally introduced a number of security vulnerabilities. The AI agent defined in c-cpp-security-reviewer.agent.md was then tasked with identifying these vulnerabilities through automated code review.

The results, methodology, and findings of the study are documented in the accompanying paper:

Vulnerability_discovery_in_C++_code_The_Agentic_AI_Approach.pdf

Experiment Application

pdf_archiver is a C++20 command line tool that archives PDF files into encrypted ZIP payloads, stores metadata in SQLite, fetches UTC timestamps over HTTP, and logs operations with spdlog.

Application Requirements

The application shall be called pdf_archiver and provide a command-line interface for securely archiving and retrieving PDF documents.

Archive Mode

The tool shall accept the following arguments:

  • A name
  • A PDF file
  • A password

Example:

./build/pdf_archiver <name> <pdf-file> <password>

When executed, the application shall:

  1. Archive the provided PDF file into a ZIP archive.

    • The archive must be created using the libarchive library.
    • The archive must be encrypted using the provided password.
    • Encryption must be implemented using the OpenSSL library.
  2. Store metadata about the operation in a local SQLite database.

    • The name provided by the user.
    • The path to the generated ZIP archive.
    • The timestamp of the operation.
    • The password used for encryption.
    • Database operations must be implemented using the sqlite3 library.
  3. Retrieve the current UTC timestamp from a public time service.

    • The timestamp must be obtained via an HTTP request to a public API.
    • HTTP communication must be implemented using the libcurl library.
  4. Log all relevant operations and events.

    • Logging must be implemented using the spdlog library.

Retrieval Mode

The application shall also support retrieval of previously archived PDF files.

Example:

./build/pdf_archiver --get <name> <password>

When executed in retrieval mode, the application shall:

  1. Search the SQLite database for the specified name.

  2. Verify that the provided password matches the password stored in the database.

  3. If the password is valid:

    • Locate the corresponding encrypted ZIP archive.
    • Decrypt and extract the archive.
    • Restore the original PDF file.
  4. If the password is invalid:

    • Log an appropriate error message.
    • Terminate the application without extracting the file.

Structure

  • main.cpp: CLI entry point and top-level error handling
  • src/util: utility library for argument parsing and filesystem helpers
  • src/adapters: C++ wrapper classes around libarchive, OpenSSL, sqlite3, and libcurl
  • src/app: application service that orchestrates store and retrieve flows

Build

cmake -S . -B build
cmake --build build

Run

./build/pdf_archiver <name> <pdf-file> <password>
./build/pdf_archiver --get <name> <password>

Dependencies

Dependency Version
gcc 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1)
build-essential 12.10ubuntu1
cmake 3.28.3-1build7
libarchive-dev 3.7.2-2ubuntu0.6
libcurl4-openssl-dev 8.5.0-2ubuntu10.9
libspdlog-dev 1:1.12.0+ds-2build1
libsqlite3-dev 3.45.1-1ubuntu2.5
libssl-dev 3.0.13-0ubuntu3.9

Installation

sudo apt install \
    build-essential \
    cmake \
    gcc \
    libarchive-dev \
    libcurl4-openssl-dev \
    libspdlog-dev \
    libsqlite3-dev \
    libssl-dev

Agents Configuration

Short descriptions of the agent configuration files included in this repository:

  • /.github/agents/c-cpp-security-reviewer.agent.md: Agent definition for the C/C++ security review (persona, goals and review workflow).
  • /.github/agents/c-cpp-coding.agent.md: Agent definition for a C/C++ coding assistant used for implementation and fixes.
  • /.github/prompts/c-cpp-security-review.prompt.md: Prompt template that invokes the security-review agent with repository-specific instructions.
  • /.github/instructions/c-cpp.instructions.md: Editing and review guidance that agents follow when working with C/C++ sources and CMake files.
  • /.github/skills/*: Skill modules used by agents for concrete tasks (compilation, static analysis, etc.). Each skill contains tooling and usage notes.

These files configure the agent personas, prompts, and helper skills used during automated code review and related experiments.

How to call the security-review prompt

To run the C/C++ security review prompt:

  • In the VS Code copilot chat start a session and call /c-cpp-security-review

About

An experiment project to evaluate a C/C++ Security Reviewer Agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages