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.
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)Separate GNN Prototype
PyTorch Geometric (GCN)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:
Probes adjacent network nodes to discover open ports, active services, and reachable subnets.
Attempts exploitation of identified synthetic vulnerabilities to gain initial unprivileged access.
Executes local privilege escalation steps on a compromised host to elevate access rights.
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

Implementation Details & GCN Code
Below is a concise snippet illustrating the PyTorch Geometric Graph Convolutional Network (GCN) module defined for node feature embedding generation:
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: