BACK TO SELECTED WORK
PROJECT 02Personal Project

PentestingAgent

Cybersecurity Reinforcement Learning Simulation

An educational reinforcement learning prototype designed to simulate sequential penetration testing decisions against synthetic enterprise network topologies using custom Gymnasium environments and PPO.

PythonGymnasiumStable-Baselines3PPONetworkXPyTorch GeometricGNN / GCN

Project Overview

PentestingAgent is an educational cybersecurity research prototype exploring how reinforcement learning (RL) agents can learn to navigate multi step attack paths within simulated computer networks.

The project models network hosts, open services, and synthetic vulnerabilities as an interactive graph environment where an agent learns sequential decision making to reach a designated target node while managing step costs.

Problem & Research Context

Research Motivation

This project explores how reinforcement learning can be used to make sequential decisions during simulated penetration testing.

Traditional automated vulnerability scanners perform isolated, single step checks. Penetration testing, however, requires sequential decision making by chaining initial access, privilege escalation, and lateral movement across subnets. Modeling this as a Markov Decision Process (MDP) allows evaluating RL algorithm capabilities in structured cybersecurity environments.

System Architecture & Dual Pipelines

To maintain absolute technical accuracy, the project architecture explicitly distinguishes between the active Reinforcement Learning pipeline and the Graph Neural Network prototype.

Primary Reinforcement Learning Pipeline

PPO Agent (Flat MLP)
Network GraphNetworkX Topology
Gymnasium EnvCustom Gym Step
ObservationHandcrafted State
PPO AgentStable-Baselines3
Simulated Actions: Scan · Exploit · PrivEsc · Lateral MovementReward: Goal Reached / Step Penalty

Separate GNN Prototype

PyTorch Geometric (GCN)
NetworkX GraphAdjacency & Attributes
Node FeaturesHost Vulnerabilities
GCN LayerGraph Convolutions
Node EmbeddingsTopology Aware Vectors
Architectural Limitation & Technical Honesty:The Graph Convolutional Network (GCN) is currently a standalone prototype for generating node embeddings. It is not fed into the PPO training loop end to end. The active PPO agent uses handcrafted observation vectors with a flat MLP policy network.

1. Active RL Training Loop (PPO)

The active agent uses Proximal Policy Optimization (PPO) implemented via Stable-Baselines3. It operates on handcrafted observation vectors containing current host status, known vulnerabilities, and reachability matrices. The policy network is a flat Multi Layer Perceptron (MLP).

2. Separate GNN Embedding Prototype

A standalone PyTorch Geometric Graph Convolutional Network (GCN) was constructed to compute topology aware node embeddings from NetworkX adjacency matrices. Note: These GCN embeddings are currently generated as a separate representation prototype and are not integrated into the PPO training loop.

Simulated Action Space

The Gymnasium environment defines a discrete action space representing simulated cybersecurity steps within the synthetic network model:

1. Scan

Probes adjacent network nodes to discover open ports, active services, and reachable subnets.

2. Exploit

Attempts exploitation of identified synthetic vulnerabilities to gain initial unprivileged access.

3. Privilege Escalation

Executes local privilege escalation steps on a compromised host to elevate access rights.

4. Lateral Movement

Pivots through compromised hosts to access internal subnet segments and target database nodes.

* Note: All actions operate strictly within an abstract Python simulation environment. No real network traffic or exploitation tools are used.

Simulation Visual Evidence

The environment includes visualization utilities to inspect generated network graphs and verify the attack paths chosen by the trained agent.

Simulation Visual Evidence

Generated during actual Gymnasium simulation runs

Synthetic enterprise network graph generated with NetworkX showing subnets, servers, and vulnerability values.
Enterprise Network Topology:Synthetic enterprise network graph generated with NetworkX showing subnets, servers, and vulnerability values.

Implementation Details & GCN Code

Below is a concise snippet illustrating the PyTorch Geometric Graph Convolutional Network (GCN) module defined for node feature embedding generation:

gcn_prototype.pyPyTorch Geometric
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv

class NetworkGCN(torch.nn.Module):
    """
    Graph Convolutional Network prototype for generating
    topology aware host embeddings from NetworkX graphs.
    """
    def __init__(self, in_channels: int, hidden_dim: int, out_channels: int):
        super().__init__()
        self.conv1 = GCNConv(in_channels, hidden_dim)
        self.conv2 = GCNConv(hidden_dim, out_channels)

    def forward(self, x, edge_index):
        # x: Node feature matrix [num_nodes, in_channels]
        # edge_index: Graph adjacency structure [2, num_edges]
        x = self.conv1(x, edge_index)
        x = F.relu(x)
        x = F.dropout(x, p=0.1, training=self.training)
        x = self.conv2(x, edge_index)
        return x  # Node embeddings [num_nodes, out_channels]

My Contribution & Project Role

Personal Project Contribution

Built the custom Gymnasium environment and PPO training workflow, worked on network topology generation and attack path visualization, and implemented the GNN prototype and supporting simulation and reporting components.

Technical Limitations & Scope

In alignment with our engineering standards, the following technical limitations are explicitly documented:

The environment is intentionally simplified for educational use.
PPO currently uses a flat MLP policy.
GCN embeddings are not fed into the PPO loop.
Blue Team behavior is not learned.
The GNN prototype is not trained end to end with the RL policy.
Vulnerability values are synthetic.