Skip to content

Commit e8d5810

Browse files
authored
Merge pull request #1073 from d-strat/develop
Fides Module
2 parents 7b847cd + dcb3baa commit e8d5810

File tree

93 files changed

+6595
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+6595
-62
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- test_dataset.py
3232
- test_pcap_dataset.py
3333
- test_zeek_dataset.py
34+
- test_fides.py
3435

3536
steps:
3637
- uses: actions/checkout@v4

.github/workflows/unit-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
- test_host_ip_manager.py
8484
- test_rnn_cc_detection.py
8585
- test_idea_format.py
86+
- test_fides_sqlite_db.py
87+
- test_fides_module.py
8688

8789
steps:
8890
- uses: actions/checkout@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,9 @@ output/
172172
config-live-macos-*
173173
dataset-private/*
174174
appendonly.aof
175+
/slipsOut/flows.sqlite
176+
/slipsOut/metadata/info.txt
177+
/slipsOut/metadata/slips.yaml
178+
/slipsOut/metadata/whitelist.conf
179+
/p2p_db.sqlite
180+

config/slips.yaml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ parameters:
7878
# zeek breaks the connection into smaller connections
7979
tcp_inactivity_timeout: 60
8080
# Should we delete the previously stored data in the DB when we start?
81-
# By default False. Meaning we don't DELETE the DB by default.
81+
# By default false. Meaning we don't DELETE the DB by default.
8282
deletePrevdb: true
8383
# You can remember the data in all the previous runs of the DB if
84-
# you put False.
84+
# you put false.
8585
# Redis will remember as long as the redis server is not down.
8686
# The persistence is in memory, not disk.
87-
# deletePrevdb : False
87+
# deletePrevdb : false
8888
# Set the label for all the flows that are being read.
8989
# For now only normal and malware directly. No option for setting labels
9090
# with a filter
@@ -154,7 +154,7 @@ detection:
154154
# May lead to false negatives
155155
evidence_detection_threshold: 0.25
156156
# Slips can show a popup/notification with every alert.
157-
popup_alerts: False
157+
popup_alerts: false
158158
#############################
159159
modules:
160160
# List of modules to ignore. By default we always ignore the template!
@@ -198,7 +198,7 @@ threatintelligence:
198198
# and all TI files are loaded successfully
199199
# this is usefull if you want to ensure that slips doesn't miss the
200200
# detection of any blacklisted IPs
201-
wait_for_TI_to_finish: False
201+
wait_for_TI_to_finish: false
202202
# Default Path to the folder with files holding malcious IPs
203203
# All the files in this folder are read and the IPs are considered malicious
204204
# The format of the files must be, per line: "Number","IP address","Rating",
@@ -275,7 +275,7 @@ exporting_alerts:
275275
# if your TAXII server is a remote server,
276276
# you can set the port to 443 or 80.
277277
port: 1234
278-
use_https: False
278+
use_https: false
279279
discovery_path: /services/discovery-a
280280
inbox_path: /services/inbox-a
281281
# Collection on the server you want to push stix data to
@@ -299,8 +299,8 @@ exporting_alerts:
299299
CESNET:
300300
# Slips supports exporting and importing evidence in the IDEA format to/from
301301
# warden servers.
302-
send_alerts: False
303-
receive_alerts: False
302+
send_alerts: false
303+
receive_alerts: false
304304
# warden configuration file. For format instructions check
305305
# yamllint disable-line rule:line-length
306306
# https://stratospherelinuxips.readthedocs.io/en/develop/exporting.html?highlight=exporting# cesnet-sharing
@@ -346,7 +346,7 @@ Docker:
346346
Profiling:
347347
# [11] CPU profiling
348348
# enable cpu profiling [yes,no]
349-
cpu_profiler_enable: False
349+
cpu_profiler_enable: false
350350
# Available options are [dev,live]
351351
# dev for deterministic profiling. this will give precise information
352352
# about the CPU usage
@@ -363,16 +363,23 @@ Profiling:
363363
# set the wait time between sampling sequences in seconds (live mode only)
364364
cpu_profiler_sampling_interval: 20
365365
# enable memory profiling [yes,no]
366-
memory_profiler_enable: False
366+
memory_profiler_enable: false
367367
# set profiling mode [dev,live]
368368
memory_profiler_mode: live
369369
# profile all subprocesses [yes,no]
370370
memory_profiler_multiprocess: True
371371
#############################
372372
web_interface:
373373
port: 55000
374+
375+
#############################
376+
global_p2p:
377+
# this is the global p2p's trust model. can only be enabled when
378+
# running slips on an interface
379+
use_fides: false
380+
374381
#############################
375382
P2P:
376383
# create p2p.log with additional info about peer communications?
377-
create_p2p_logfile: False
378-
use_p2p: False
384+
create_p2p_logfile: false
385+
use_p2p: false

docs/contributing.md

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,107 @@ Once all modules are done processing, EvidenceHandler is killed by the Process m
171171

172172
Using one of these 3 ways
173173

174-
<img src="https://raw.githubusercontent.com/stratosphereips/StratosphereLinuxIPS/develop/docs/images/gw_info.jpg"
174+
<img src="https://raw.githubusercontent.com/stratosphereips/StratosphereLinuxIPS/develop/docs/images/gw_info.jpg">
175+
176+
177+
## Global P2P - Fides contribution notes
178+
179+
Variables used in the trust evaluation and its accompanied processes, such as database-backup in persistent
180+
SQLite storage and memory persistent
181+
Redis database of Slips, are strings, integers and floats grouped into custom dataclasses. Aforementioned data classes can
182+
be found in modules/fidesModule/model. The reader may find that all of the floating variables are in the interval <-1; 1>
183+
and some of them are between <0; 1>, please refer to the modules/fidesModule/model directory.
184+
185+
The Fides Module is designed to cooperate with a global-peer-to-peer module. The communication is done using Slips' Redis
186+
channel, for more information please refer to communication and messages sections above.
187+
188+
An example of a message answering Fides-Module's opinion request follows.
189+
```
190+
import redis
191+
192+
# connect to redis database 0
193+
redis_client = redis.StrictRedis(host='localhost', port=6379, db=0)
194+
195+
message = '''
196+
{
197+
"type": "nl2tl_intelligence_response",
198+
"version": 1,
199+
"data": [
200+
{
201+
"sender": {
202+
"id": "peer1",
203+
"organisations": ["org_123", "org_456"],
204+
"ip": "192.168.1.1"
205+
},
206+
"payload": {
207+
"intelligence": {
208+
"target": {"type": "server", "value": "192.168.1.10"},
209+
"confidentiality": {"level": 0.8},
210+
"score": 0.5,
211+
"confidence": 0.95
212+
},
213+
"target": "stratosphere.org"
214+
}
215+
},
216+
{
217+
"sender": {
218+
"id": "peer2",
219+
"organisations": ["org_789"],
220+
"ip": "192.168.1.2"
221+
},
222+
"payload": {
223+
"intelligence": {
224+
"target": {"type": "workstation", "value": "192.168.1.20"},
225+
"confidentiality": {"level": 0.7},
226+
"score": -0.85,
227+
"confidence": 0.92
228+
},
229+
"target": "stratosphere.org"
230+
}
231+
}
232+
]
233+
}
234+
'''
235+
236+
# publish the message to the "network2fides" channel
237+
channel = "network2fides"
238+
redis_client.publish(channel, message)
239+
240+
print(f"Message published to channel '{channel}'.")
241+
```
242+
243+
For more information about message handling, please also refer to modules/fidesModule/messaging/message_handler.py
244+
and to modules/fidesModule/messaging/dacite/core.py for message parsing.
245+
246+
247+
### **Communication**
248+
The module uses Slips' Redis to receive and send messages related to trust intelligence,
249+
evaluation of trust in peers and alert message dispatch.
250+
251+
**Used Channels**
252+
modules/fidesModule/messaging/message_handler.py
253+
| **Slips Channel Name** | **Purpose** |
254+
|-----------------|-------------------------------------------------------------------------|
255+
| `slips2fides` | Provides communication channel from Slips to Fides |
256+
| `fides2slips` | Enables the Fides Module to answer requests from slips2fides |
257+
| `network2fides` | Facilitates communication from network (P2P) module to the Fides Module |
258+
| `fides2network` | Lets the Fides Module request network opinions form network modules |
259+
260+
For more details, the code [here](https://github.com/stratosphereips/fides/tree/bfac47728172d3a4bbb27a5bb53ceef424e45e4f/fides/messaging) may be read.
261+
262+
263+
### **Messages**
264+
265+
| **Message type (data['type'])** | **Channel** | **Call/Handle** | **Description** |
266+
|:-------------------------------:|-----------------|-----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
267+
| `alert` | `slips2fides` | FidesModule as self.__alerts.dispatch_alert(target=data['target'], confidence=data['confidence'],score=data['score']) | Triggers sending an alert to the network, about given target, which SLips believes to be compromised. |
268+
| `intelligence_request` | `slips2fides` | FidesModule as self.__intelligence.request_data(target=data['target']) | Triggers request of trust intelligence on given target. |
269+
| `tl2nl_alert` | `fides2network` | call dispatch_alert() of AlertProtocol class instance | Broadcasts alert through the network about the target. |
270+
| `tl2nl_intelligence_response` | `fides2network` | NetworkBridge.send_intelligence_response(...) | Shares Intelligence with peer that requested it. |
271+
| `tl2nl_intelligence_request` | `fides2network` | NetworkBridge.send_intelligence_request(...) | Requests network intelligence from the network regarding this target. |
272+
| `tl2nl_recommendation_response` | `fides2network` | NetworkBridge.send_recommendation_response(...) | Responds to given request_id to recipient with recommendation on target. |
273+
| `tl2nl_recommendation_request` | `fides2network` | NetworkBridge.send_recommendation_request(...) | Request recommendation from recipients on given peer. |
274+
| `tl2nl_peers_reliability` | `fides2network` | NetworkBridge.send_peers_reliability(...) | Sends peer reliability, this message is only for network layer and is not dispatched to the network. |
275+
276+
277+
Implementations of Fides_Module-network-communication can be found in ```modules/fidesModule/messaging/network_bridge.py```.

docs/fides_module.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Fides module
2+
3+
The Fides module is an essential component of the Global P2P system in Slips.
4+
5+
6+
Traditional network defense systems depend on centralized threat intelligence, which has limitations like single points of failure, inflexibility, and reliance on trust in centralized authorities. Peer-to-peer networks offer an alternative for sharing threat intelligence but face challenges in verifying the trustworthiness of participants, including potential malicious actors.
7+
8+
The Fides Module, based on [Master Theses](https://github.com/stratosphereips/fides/tree/bfac47728172d3a4bbb27a5bb53ceef424e45e4f) on CTU FEL by Lukáš Forst. The goal of this module is to address the challenge of trustworthiness of peers in peer-to-peer networks by providing several trust evaluation models. It evaluates peer behavior, considers membership in trusted organizations, and assesses incoming threat data to determine reliability. Fides aggregates and weights data to enhance intrusion prevention systems, even in adversarial scenarios. Experiments show that Fides can maintain accurate threat intelligence even when 75% of the network is controlled by malicious actors, assuming the remaining 25% are trusted.
9+
10+
The whole architecture is thoroughly documented in the thesis itself, which can be downloaded from the link above.
11+
12+
## Docker direct use
13+
You can use Slips with Fides Module by allowing it in the Slips config file or by using the following commands.
14+
15+
```
16+
docker pull stratosphereips/slips
17+
docker run -it --rm --net=host --cap-add=NET_ADMIN stratosphereips/slips
18+
```
19+
20+
To be able to use the fides module you should use ```--cap-add=NET_ADMIN```
21+
22+
## Installation:
23+
24+
```
25+
docker pull stratosphereips/slips
26+
docker run -it --rm --net=host --use_fides=True stratosphereips/slips
27+
```
28+
29+
***NOTE***
30+
31+
If you plan on using the Fides Module, lease be aware that it is used only
32+
if Slips is running on an interface. The `--use_fides=True` is ignored when Slips is run on a file.
33+
34+
### Configuration
35+
Evaluation model, evaluation thrash-holds and other configuration is located in fides.conf.yml
36+
37+
**Possible threat intelligence evaluation models**
38+
39+
| **Model Name** | **Description** |
40+
|:-----------------------|--------------------------------------------------------------|
41+
| `average` | Average Confidence Trust Intelligence Aggregation |
42+
| `weightedAverage` | Weighted Average Confidence Trust Intelligence Aggregation |
43+
| `stdevFromScore` | Standard Deviation From Score Trust Intelligence Aggregation |
44+
45+
## Usage in Slips
46+
47+
Fides is inactive by default in Slips.
48+
49+
To enable it, change ```use_fides=False``` to ```use_fides=True``` in ```config/slips.yaml```.
50+
51+
And start slips on your interface.
52+
53+
## Project sections
54+
55+
The project is built into Slips as a module and uses Redis for communication. Integration with Slips
56+
is seamless, and it should be easy to adjust the module for use with other IPSs.
57+
58+
- Slips, the Intrusion Prevention System
59+
- Fides Module the trust evaluation module for global p2p interaction
60+
61+
62+
## How it works:
63+
64+
Slips interacts with other slips peers for the following purposes:
65+
66+
### Sharing opinion on peers
67+
68+
If a peers A is asked for its opinion on peer B by peer C, peer A sends the aggregated opinion on peer B to peer C, if there is any.
69+
70+
### Asking for an opinion
71+
72+
Newly connected peer will create a base trust by asking ather peers for opinion.
73+
74+
### Dispatching alerts
75+
76+
If a threat so great it may impact whole network, one or more groups, threat alert is
77+
dispatched to peers, without regard to trust level accumulated on them.
78+
79+
### Answering and receiving requests form global P2P module.
80+
81+
## Logs
82+
83+
Slips contains a minimal log file for reports received by other peers and peer updates in
84+
```output``` directory if not manually specified using the appropriate slips parameter upon start.
85+
Custom logger ```modules/fidesModule/utils/logger.py``` is used by Fide Module for internal logging. Either Slips' logging is used, or the custom logger is defaulted to logging via Python's printing function.
86+
87+
## Limitations
88+
89+
For now, slips supports the trust intelligence evaluation, global p2p is to be implemented.
90+
91+
## Implementation notes and credit
92+
The mathematical models for trust evaluation were written by Lukáš Forst as part of his theses and can be accessed [here](https://github.com/LukasForst/fides/commits?author=LukasForst).
93+
94+
95+
## TLDR;
96+
97+
Slips (meaning Fides Module here) only shares trust level and confidence (numbers) generated by slips about IPs to the network,
98+
no private information is shared.

docs/images/gw_info.jpg

74.8 KB
Loading

docs/index.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ This documentation gives an overview how Slips works, how to use it and how to h
1818
- **Detection modules**. Explanation of detection modules in Slips, types of input and output. See :doc:`Detection modules <detection_modules>`.
1919

2020
- **Architecture**. Internal architecture of Slips (profiles, timewindows), the use of Zeek and connection to Redis. See :doc:`Architecture <architecture>`.
21-
22-
- **Training with your own data**. Explanation on how to re-train the machine learning system of Slips with your own traffic (normal or malicious).See :doc:`Training <training>`.
21+
22+
- **Training with your own data**. Explanation on how to re-train the machine learning system of Slips with your own traffic (normal or malicious).See :doc:`Training <training>`.
2323

2424
- **Detections per Flow**. Explanation on how Slips works to make detections on each flow with different techniques. See :doc:`Flow Alerts <flowalerts>`.
2525

@@ -41,9 +41,9 @@ This documentation gives an overview how Slips works, how to use it and how to h
4141
.. toctree::
4242
:maxdepth: 2
4343
:hidden:
44-
:caption: Slips
45-
46-
self
44+
:caption: Slips
45+
46+
self
4747
installation
4848
usage
4949
architecture
@@ -59,6 +59,4 @@ This documentation gives an overview how Slips works, how to use it and how to h
5959
FAQ
6060
code_documentation
6161
datasets
62-
63-
64-
62+
fides_module

fides

Submodule fides updated 1 file

0 commit comments

Comments
 (0)