24 KiB
24 KiB
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased
Added
- show_bandwidth_load Function: Displays current bandwidth load for each frequency in the airspace.
- Bandwidth Tracking: Tracks data transmission across each frequency.
- New Tests: Added to validate the respect of bandwidth capacities and the correct parsing of airspace configurations from YAML files.
- New Logging: Added a new agent behaviour log which are more human friendly than agent history. These Logs are found in session log directory and can be enabled in the I/O settings in a yaml configuration file.
Changed
- NetworkInterface Speed Type: The
speedattribute ofNetworkInterfacehas been changed frominttofloat. - Transmission Feasibility Check: Updated
_can_transmitfunction inLinkto account for current load and total bandwidth capacity, ensuring transmissions do not exceed limits. - Frame Size Details: Frame
sizeattribute now includes both core size and payload size in bytes. - Transmission Blocking: Enhanced
AirSpacelogic to block transmissions that would exceed the available capacity. - Software (un)install refactored: Removed the install/uninstall methods in the node class and made the software manager install/uninstall handle all of their functionality.
Fixed
- Transmission Permission Logic: Corrected the logic in
can_transmit_frameto accurately prevent overloads by checking if the transmission of a frame stays within allowable bandwidth limits after considering current load.
3.0.0b9
- Removed deprecated
PrimaiteSessionclass. - Added ability to set log levels via configuration.
- Upgraded pydantic to version 2.7.0
- Upgraded Ray to version >= 2.9
- Added ipywidgets to the dependencies
- Added ability to define scenarios that change depending on the episode number.
- Standardised Environment API by renaming the config parameter of
PrimaiteGymEnvfromgame_configtoenv_config - Database Connection ID's are now created/issued by DatabaseService and not DatabaseClient
- Updated DatabaseClient so that it can now have a single native DatabaseClientConnection along with a collection of DatabaseClientConnection's.
- Implemented the uninstall functionality for DatabaseClient so that all connections are terminated at the DatabaseService.
- Added the ability for a DatabaseService to terminate a connection.
- Added active_connection to DatabaseClientConnection so that if the connection is terminated active_connection is set to False and the object can no longer be used.
- Added additional show functions to enable connection inspection.
- Updates to agent logging, to include the reward both per step and per episode.
- Introduced Developer CLI tools to assist with developing/debugging PrimAITE
- Can be enabled via
primaite dev-mode enable - Activating dev-mode will change the location where the sessions will be output - by default will output where the PrimAITE repository is located
- Can be enabled via
- Refactored all air-space usage to that a new instance of AirSpace is created for each instance of Network. This 1:1 relationship between network and airspace will allow parallelization.
- Added notebook to demonstrate use of SubprocVecEnv from SB3 to vectorise environments to speed up training.
Unreleased
- Made requests fail to reach their target if the node is off
- Added responses to requests
- Made environment reset completely recreate the game object.
- Changed the red agent in the data manipulation scenario to randomly choose client 1 or client 2 to start its attack.
- Changed the data manipulation scenario to include a second green agent on client 1.
- Refactored actions and observations to be configurable via object name, instead of UUID.
- Made database patch correctly take 2 timesteps instead of being immediate
- Made database patch only possible when the software is compromised or good, it's no longer possible when the software is OFF or RESETTING
- Added a notebook which explains Data manipulation scenario, demonstrates the attack, and shows off blue agent's action space, observation space, and reward function.
- Made packet capture and system logging optional (off by default). To turn on, change the io_settings.save_pcap_logs and io_settings.save_sys_logs settings in the config.
- Made observation space flattening optional (on by default). To turn off for an agent, change the
agent_settings.flatten_obssetting in the config. - Added support for SQL INSERT command.
- Added ability to log each agent's action choices in each step to a JSON file.
- Removal of Link bandwidth hardcoding. This can now be configured via the network configuraiton yaml. Will default to 100 if not present.
- Added NMAP application to all host and layer-3 network nodes.
Bug Fixes
- ACL rules were not resetting on episode reset.
- ACLs were not showing up correctly in the observation space.
- Blue agent's ACL actions were being applied against the wrong IP addresses
- Deleted files and folders did not reset correctly on episode reset.
- Service health status was using the actual health state instead of the visible health state
- Database file health status was using the incorrect value for negative rewards
- Preventing file actions from reaching their intended file
- The data manipulation attack was triggered at episode start.
- FTP STOR stored an additional copy on the client machine's filesystem
- The red agent acted to early
- Order of service health state
- Starting a node didn't start the services on it
- Fixed an issue where the services were still able to run even though the node the service is installed on is turned off
- The use of NODE_FILE_CHECKHASH and NODE_FOLDER_CHECKHASH in the current release is marked as 'Not Implemented'.
Added
- Network Hardware - Added base hardware module with NIC, SwitchPort, Node, and Link. Nodes have fundamental services like ARP, ICMP, and PCAP running them by default.
- Network Transmission - Modelled OSI Model layers 1 through to 5 with various classes for creating network frames and transmitting them from a Service/Application, down through the layers, over the wire, and back up through the layers to a Service/Application another machine.
- Introduced
RouterandSwitchclasses to manage networking routes more effectively.- Added
ACLRuleandRouteTableEntryclasses as part of theRouter.
- Added
- New
.show()methods in all network component classes to inspect the state in either plain text or markdown formats. - Added
ComputerandServerclass to better differentiate types of network nodes. - Integrated a new Use Case 2 network into the system.
- New unit tests to verify routing between different subnets using
.ping(). - system - Added the core structure of Application, Services, and Components. Also added a SoftwareManager and SessionManager.
- Permission System - each action can define criteria that will be used to permit or deny agent actions.
- File System - ability to emulate a node's file system during a simulation
- Example notebooks - There are 5 jupyter notebook which walk through using PrimAITE
- Training a Stable Baselines 3 agent
- Training a single agent system using Ray RLLib
- Training a multi-agent system Ray RLLib
- Data manipulation end to end demonstration
- Data manipulation scenario with customised red agents
- Database:
DatabaseClientandDatabaseServicecreated to allow emulation of database actions- Ability for
DatabaseServiceto backup its data to another server via FTP and restore data from backup
- Red Agent Services:
- Data Manipulator Bot - A red agent service which sends a payload to a target machine. (By default this payload is a SQL query that breaks a database). The attack runs in stages with a random, configurable probability of succeeding.
DataManipulationAgentruns the Data Manipulator Bot according to a configured start step, frequency and variance.
- DNS Services:
DNSClientandDNSServer - FTP Services:
FTPClientandFTPServer - HTTP Services:
WebBrowserto simulate a web client andWebServer - NTP Services:
NTPClientandNTPServer - RouterNIC Class: Introduced a new class
RouterNIC, extending the standardNICfunctionality. This class is specifically designed for router operations, optimizing the processing and routing of network traffic.- Custom Layer-3 Processing: The
RouterNICclass includes custom handling for network frames, bypassing standard Node NIC's Layer 3 broadcast/unicast checks. This allows for more efficient routing behavior in network scenarios where router-specific frame processing is required. - Enhanced Frame Reception: The
receive_framemethod inRouterNICis tailored to handle frames based on Layer 2 (Ethernet) checks, focusing on MAC address-based routing and broadcast frame acceptance.
- Custom Layer-3 Processing: The
- Subnet-Wide Broadcasting for Services and Applications: Implemented the ability for services and applications to conduct broadcasts across an entire IPv4 subnet within the network simulation framework.
- Introduced the
NetworkInterfaceabstract class to provide a common interface for all network interfaces. Subclasses are divided into two main categories:WiredNetworkInterfaceandWirelessNetworkInterface, each serving as an abstract base class (ABC) for more specific interface types. UnderWiredNetworkInterface, the subclassesNICandSwitchPortwere added. For wireless interfaces,WirelessNICandWirelessAccessPointare the subclasses underWirelessNetworkInterface. - Added
Layer3Interfaceas an abstract base class for networking functionalities at layer 3, including IP addressing and routing capabilities. This class is inherited byNIC,WirelessNIC, andWirelessAccessPointto provide them with layer 3 capabilities, facilitating their role in both wired and wireless networking contexts with IP-based communication. - Created the
ARPandICMPservice classes to handle Address Resolution Protocol operations and Internet Control Message Protocol messages, respectively, withRouterARPandRouterICMPfor router-specific implementations. - Created
HostNodeas a subclass ofNode, extending its functionality with host-specific services and applications. This class is designed to represent end-user devices like computers or servers that can initiate and respond to network communications. - Introduced a new
IPV4Addresstype in the Pydantic model for enhanced validation and auto-conversion of IPv4 addresses from strings using anipv4_validator. - Comprehensive documentation for the Node and its network interfaces, detailing the operational workflow from frame reception to application-level processing.
- Detailed descriptions of the Session Manager and Software Manager functionalities, including their roles in managing sessions, software services, and applications within the simulation.
- Documentation for the Packet Capture (PCAP) service and SysLog functionality, highlighting their importance in logging network frames and system events, respectively.
- Expanded documentation on network devices such as Routers, Switches, Computers, and Switch Nodes, explaining their specific processing logic and protocol support.
- Firewall Node: Introduced the
Firewallclass extending the functionality of the existingRouterclass. TheFirewallclass incorporates advanced features to scrutinize, direct, and filter traffic between various network zones, guided by predefined security rules and policies. Key functionalities include:- Access Control Lists (ACLs) for traffic filtering based on IP addresses, protocols, and port numbers.
- Network zone segmentation for managing traffic across external, internal, and DMZ (De-Militarized Zone) networks.
- Interface configuration to establish connectivity and define network parameters for external, internal, and DMZ interfaces.
- Protocol and service management to oversee traffic and enforce security policies.
- Dynamic traffic processing and filtering to ensure network security and integrity.
AirSpaceclass to simulate wireless communications, managing wireless interfaces and facilitating the transmission of frames within specified frequencies.AirSpaceFrequencyenum for defining standard wireless frequencies, including 2.4 GHz and 5 GHz bands, to support realistic wireless network simulations.WirelessRouterclass, extending theRouterclass, to incorporate wireless networking capabilities alongside traditional wired connections. This class allows the configuration of wireless access points with specific IP settings and operating frequencies.- Documentation Updates:
- Examples include how to set up PrimAITE session via config
- Examples include how to create nodes and install software via config
- Examples include how to set up PrimAITE session via Python
- Examples include how to create nodes and install software via Python
- Added missing
DoSBotdocumentation page - Added diagrams where needed to make understanding some things easier
- Templated parts of the documentation to prevent unnecessary repetition and for easier maintaining of documentation
- Separated documentation pages of some items i.e. client and server software were on the same pages - which may make things confusing
- Configuration section at the bottom of the software pages specifying the configuration options available (and which ones are optional)
- Ability to add
Firewallnode via config - Ability to add
Routerroutes via config - Ability to add
Router/FirewallACLRulevia config - NMNE capturing capabilities to
NetworkInterfaceclass for detecting and logging Malicious Network Events. - New
nmne_configsettings in the simulation configuration to enable NMNE capturing and specify keywords such as "DELETE". - Router-specific SessionManager Implementation: Introduced a specialized version of the SessionManager tailored for router operations. This enhancement enables the SessionManager to determine the routing path by consulting the route table.
Changed
- Integrated the RouteTable into the Routers frame processing.
- Frames are now dropped when their TTL reaches 0
- NIC Functionality Update: Updated the Network Interface Card (
NIC) functionality to support Layer 3 (L3) broadcasts.- Layer 3 Broadcast Handling: Enhanced the existing
NICclasses to correctly process and handle Layer 3 broadcasts. This update allows devices using standard NICs to effectively participate in network activities that involve L3 broadcasting. - Improved Frame Reception Logic: The
receive_framemethod of theNICclass has been updated to include additional checks and handling for L3 broadcasts, ensuring proper frame processing in a wider range of network scenarios.
- Layer 3 Broadcast Handling: Enhanced the existing
- Standardised the way network interfaces are accessed across all
Nodesubclasses (HostNode,Router,Switch) by maintaining a comprehensivenetwork_interfaceattribute. This attribute captures all network interfaces by their port number, streamlining the management and interaction with network interfaces across different types of nodes. - Refactored all tests to utilise new
Nodesubclasses (Computer,Server,Router,Switch) instead of creating genericNodeinstances and manually adding network interfaces. This change aligns test setups more closely with the intended use cases and hierarchies within the network simulation framework. - Updated all tests to employ the
Network()class for managing nodes and their connections, ensuring a consistent and structured approach to setting up network topologies in testing scenarios. - ACLRule Wildcard Masking: Updated the
ACLRuleclass to support IP ranges using wildcard masking. This enhancement allows for more flexible and granular control over traffic filtering, enabling the specification of broader or more specific IP address ranges in ACL rules. - Updated
NetworkInterfacedocumentation to reflect the new NMNE capturing features and how to use them. - Integration of NMNE capturing functionality within the
NICObservationclass. - Changed blue action set to enable applying node scan, reset, start, and shutdown to every host in data manipulation scenario
Removed
- Removed legacy simulation modules:
acl,common,environment,links,nodes,pol - Removed legacy training modules
- Removed tests for legacy code
Fixed
- Addressed network transmission issues that previously allowed ARP requests to be incorrectly routed and repeated across different subnets. This fix ensures ARP requests are correctly managed and confined to their appropriate network segments.
- Resolved problems in
Nodeand its subclasses where the default gateway configuration was not properly utilized for communications across different subnets. This correction ensures that nodes effectively use their configured default gateways for outbound communications to other network segments, thereby enhancing the network's routing functionality and reliability. - Network Interface Port name/num being set properly for sys log and PCAP output.
2.0.0 - 2023-07-26
Added
- Command Line Interface (CLI) for easy access and streamlined usage of PrimAITE.
- Application Directories to enable PrimAITE as a Python package with predefined directories for storage.
- Support for Ray Rllib, allowing training of PPO and A2C agents using Stable Baselines3 and Ray RLlib.
- Random Red Agent to train the blue agent against, with options for randomised Red Agent
POLandIER. - Repeatability of sessions through seed settings, and deterministic or stochastic evaluation options.
- Session loading to revisit previously run sessions for SB3 Agents.
- Agent Session Classes (
AgentSessionABCandHardCodedAgentSessionABC) to standardise agent training with a common interface. - Standardised Session Output in a structured format in the user's app sessions directory, providing four types of outputs:
- Session Metadata
- Results
- Diagrams
- Saved agents (training checkpoints and a final trained agent).
- Configurable Observation Space managed by the
ObservationHandlerclass for a more flexible observation space setup. - Benchmarking of PrimAITE performance, showcasing session and step durations for reference.
- Documentation overhaul, including automatic API and test documentation with recursive Sphinx auto-summary, using the Furo theme for responsive light/dark theme, and enhanced navigation with
sphinx-code-tabsandsphinx-copybutton.
Changed
- Action Space updated to discrete spaces, introducing a new
ANYaction space option for combinedNODEandACLactions. - Improved
Nodeattribute naming convention for consistency, now adhering toPascal Case. - Package Structure has been refactored for better build, distribution, and installation, with all source code now in the
src/directory, and thePRIMAITEPython package renamed toprimaiteto adhere to PEP-8 Package & Module Names. - Docs and Tests now sit outside the
src/directory. - Non-python files (example config files, Jupyter notebooks, etc.) now sit inside a
*/_package_data/directory in their respective sub-packages. - All dependencies are now defined in the
pyproject.tomlfile. - Introduced individual configuration for the number of episodes and time steps for training and evaluation sessions, with separate config values for each.
- Decoupled the lay down config file from the training config, allowing more flexibility in configuration management.
- Updated
Transactionsto only report pre-action observation, improving the CSV header and providing more human-readable descriptions for columns relating to observations. - Changes to
AccessControlList, where theacldictionary is now a list to accommodate changes to ACL action space and positioning ofACLRulesinside the list to signal their level of priority.
Fixed
- Various bug fixes, including Green IERs separation, correct clearing of links in the reference environment, and proper reward calculation.
- Logic to check if a node is OFF before executing actions on the node by the blue agent, preventing erroneous state changes.
- Improved functionality of Resetting a Node, adding "SHUTTING DOWN" and "BOOTING" operating states for more reliable reset commands.
- Corrected the order of actions in the
Primaiteenv to ensure the blue agent uses the current state for decision-making.
[1.1.1] - 2023-06-27
Bug Fixes
- Fixed bug whereby 'reference' environment links reach bandwidth capacity and are never cleared due to green & red IERs being applied to them. This bug had a knock-on effect that meant IERs were being blocked based on the full capacity of links on the reference environment which was not correct; they should only be based on the link capacity of the 'live' environment. This fix has been addressed by:
- Implementing a reference copy of all green IERs (
self.green_iers_reference). - Clearing the traffic on reference IERs at the same time as the live IERs.
- Passing the
green_iers_referenceto theapply_iersfunction at the reference stage. - Passing the
green_iers_referenceas an additional argument tocalculate_reward_function. - Updating the green IERs section of the
calculate_reward_functionto now take into account both the green reference IERs and live IERs. Thegreen_ier_blockedreward is only applied if the IER is blocked in the live environment but is running in the reference environment. - Re-ordering the actions taken as part of the step function to ensure the blue action happens first before other changes.
- Removing the unnecessary "Reapply PoL and IERs" action from the step function.
- Moving the deep-copy of nodes and links to below the "Implement blue action" stage of the step function.
- Implementing a reference copy of all green IERs (
[1.1.0] - 2023-03-13
Added
- The user can now initiate either a TRAINING session or an EVALUATION (test) session with the Stable Baselines 3 (SB3) agents via the config_main.yaml file. During evaluation/testing, the agent policy will be fixed (no longer learning) and subjected to the SB3
evaluate_policy()function. - The user can choose whether a saved agent is loaded into the session (with reference to a URL) via the
config_main.yamlfile. They specify a Boolean true/false indicating whether a saved agent should be loaded, and specify the URL and file name. - Active and Service nodes now possess a new "File System State" attribute. This attribute is permitted to have the states GOOD, CORRUPT, DESTROYED, REPAIRING, and RESTORING. This new feature affects the following components:
- Blue agent observation space;
- Blue agent action space;
- Reward function;
- Node pattern-of-life.
- The Red Agent node pattern-of-life has been enhanced so that node PoL is triggered by an 'initiator'. The initiator is either DIRECT (state change is applied to the node without any conditions), IER (state change is applied to the node based on IER entry condition), or SERVICE (state change is applied to the node based on a service state condition on the same node or a different node within the network).
- New default config named "config_5_DATA_MANIPULATION.yaml" and associated Training Use Case Profile.
- NodeStateInstruction has been split into
NodeStateInstructionGreenandNodeStateInstructionRedto reflect the changes within the red agent pattern-of-life capability. - The reward function has been enhanced so that node attribute states of resetting, patching, repairing, and restarting contribute to the overall reward value.
- The User Guide has been updated to reflect all the above changes.
Changed
- "config_1_DDOS_BASIC.yaml" modified to make it more simplistic to aid evaluation testing.
- "config_2_DDOS_BASIC.yaml" updated to reflect the addition of the File System State and the Red Agent node pattern-of-life enhancement.
- "config_3_DOS_VERY_BASIC.yaml" updated to reflect the addition of the File System State and the Red Agent node pattern-of-life enhancement.
- "config_UNIT_TEST.yaml" is a copy of the new "config_5_DATA_MANIPULATION.yaml" file.
- Updates to Transactions.
Fixed
- Fixed "config_2_DDOS_BASIC.yaml" by adding another ACL rule to allow traffic to flow from Node 9 to Node 3. Previously, there was no rule, so one of the green IERs could not flow by default.