Skip to content

About

IST Network and Computer Security project, 2025/2026

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

A41 ChainOfProduct Project Read Me

Team

Number Name User E-mail
102989 Marco Curto https://github.com/Supimpaaa mailto:[email protected]
103811 Tiago Deane https://github.com/TiDeane mailto:[email protected]
103284 Tito Pereira https://github.com/teravyte18 mailto:[email protected]

Marco Tiago Tito

Contents

This repository contains documentation and source code for the Network and Computer Security (SIRS) project.

The REPORT document provides a detailed overview of the key technical decisions and various components of the implemented project. It offers insights into the rationale behind these choices, the project's architecture, and the impact of these decisions on the overall functionality and performance of the system.

This document presents installation and demonstration instructions.

Installation

To see the project in action, it is necessary to setup a virtual environment, with a minimum of 5 networks and 6 machines. In our test environment we setup a total of 7 Networks and 8 Machines in order to have multiple clients in segragated networks.

The following diagram shows the networks and machines:

Network Diagram

Prerequisites

All virtual machines used in this project are based on a 64-bit Linux operating system. The infrastructure was implemented and tested using Kali Linux.

Kali Linux installation images can be obtained from the official website:

The experiments were conducted using VMware Workstation Pro as the virtualization platform. However, the proposed solution is not tied to a specific hypervisor. Any virtualization software may be used, provided it supports:

  • multiple virtual machines,

  • multiple network adapters per machine,

  • and the creation of isolated virtual networks or host-only networks.

A single base virtual machine was installed and configured with the required operating system. This base machine was then cloned to create the remaining machines in the infrastructure, ensuring a consistent initial environment across all components.

The following software packages and system tools are required across the different machines:

  • OpenJDK (Java Development Kit) — required to run the Spring Boot application.

  • Apache Maven — used to build and package the application.

  • iptables — used on dedicated firewall machines to enforce network-level access control.

  • iptables-persistent — used to persist firewall rules across reboots on firewall machines.

  • UFW (Uncomplicated Firewall) — used on application and database servers to enforce host-based firewall policies.

  • Git — used to retrieve application code and configuration scripts.

All required packages are available through the standard Debian package repositories and can be installed using the system package manager.

Machine configurations

Each machine in the infrastructure was configured following a manual, step-by-step procedure, starting from a clean Linux installation. The configuration process includes installing the required software packages, setting up network interfaces and routing, and applying the necessary firewall rules according to the role of each machine.

All application code and supporting scripts were retrieved using Git to ensure a consistent setup across machines.

Inside each machine, use Git to obtain a copy of all the scripts and code.

git clone https://github.com/tecnico-sec/A41-ChainOfProduct.git

Next we have custom instructions for each machine.

Machine 1 - WAN Client

This machine represents an external client located in the WAN zone. It is used to simulate requests originating from an untrusted network towards the application server. During testing, multiple WAN clients were deployed in different subnets. The configuration below describes a single representative client.

Network configuration

The WAN client uses a static IP address and a single network interface. The network configuration is performed by editing /etc/network/interfaces.

Configuration:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.1.20
    netmask 255.255.255.0
    gateway 192.168.1.1

After applying the configuration, the network service can be restarted or the machine rebooted.

Machine 2 — FW1 (WAN ↔ DMZ Firewall)

This machine acts as the perimeter firewall between the WAN zone and the DMZ. It is responsible for routing traffic between external client networks and the application server, while enforcing strict access control using packet-filtering rules.

Network configuration

FW1 is configured with multiple network interfaces, one for each WAN subnet and one connected to the DMZ. All interfaces use static IP addresses and act as default gateways for their respective networks.

Example network configuration (/etc/network/interfaces):

auto lo
iface lo inet loopback

# WAN subnet 1
auto eth0
iface eth0 inet static
    address 192.168.1.1
    netmask 255.255.255.0

# WAN subnet 2
auto eth1
iface eth1 inet static
    address 192.168.2.1
    netmask 255.255.255.0

# WAN subnet 3
auto eth2
iface eth2 inet static
    address 192.168.3.1
    netmask 255.255.255.0

# DMZ
auto eth3
iface eth3 inet static
    address 192.168.10.1
    netmask 255.255.255.0

Routing configuration

IP forwarding is enabled to allow FW1 to route traffic between interfaces, apply the following command to guarantee this change is persistent:

echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-ipforward.conf

Firewall rules

Traffic filtering is implemented using iptables, following a default-deny approach.

# Flush existing rules
sudo iptables -F
sudo iptables -X

# Default policies
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT

# Allow loopback
sudo iptables -A INPUT -i lo -j ACCEPT

# Allow established and related traffic
sudo iptables -A INPUT   -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# Allow WAN → Application Server on application port
sudo iptables -A FORWARD \
    -d 192.168.10.10 \
    -p tcp --dport 8443 \
    -m conntrack --ctstate NEW \
    -j ACCEPT

# Save rules
sudo iptables-save | sudo tee /etc/iptables/rules.v4

Machine 3 — Application Server (DMZ)

This machine hosts the application server and is deployed in the DMZ. It acts as an intermediary between external clients and the internal database, while not performing any routing functions.

Network configuration

The application server is configured with two network interfaces, each serving a distinct purpose:

  • a front-facing interface connected to the WAN-facing DMZ, used for client communication;

  • a back-facing interface connected to the internal-facing DMZ, used for backend communication.

Static IP addressing is used for both interfaces. The configuration is performed by editing /etc/network/interfaces.

auto lo
iface lo inet loopback

# Front DMZ (WAN-facing)
auto eth0
iface eth0 inet static
    address 192.168.10.10
    netmask 255.255.255.0
    gateway 192.168.10.1

# Back DMZ (internal-facing)
auto eth1
iface eth1 inet static
    address 192.168.20.10
    netmask 255.255.255.0
    post-up ip route add 192.168.0.0/24 via 192.168.20.1 dev eth1
    pre-down ip route del 192.168.0.0/24 via 192.168.20.1 dev eth1

The default gateway is configured only on the front-facing interface. A specific static route is added to direct internal traffic through the internal firewall (FW2). IP forwarding remains disabled on this machine.

Host firewall configuration

Host-based access control is enforced using UFW. The firewall is configured to allow incoming connections from external clients only on the application port, while permitting outbound connections required for backend communication.

Example UFW configuration:

sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow client access to the application service
sudo ufw allow in on eth0 to any port 8443 proto tcp

# Allow backend communication to the internal network
sudo ufw allow out on eth1 to 192.168.0.0/24

sudo ufw enable

Machine 4 — FW2 (DMZ ↔ LAN Firewall)

This machine acts as the internal firewall between the DMZ and the internal (LAN) network. Its purpose is to strictly control access to internal services, allowing only the application server to communicate with the database server.

Network configuration

FW2 is configured with two network interfaces:

  • one connected to the internal-facing DMZ;

  • one connected to the LAN.

Both interfaces use static IP addresses. The configuration is performed by editing /etc/network/interfaces.

Example configuration:

auto lo
iface lo inet loopback

# DMZ (back)
auto eth0
iface eth0 inet static
    address 192.168.20.1
    netmask 255.255.255.0

# LAN
auto eth1
iface eth1 inet static
    address 192.168.0.1
    netmask 255.255.255.0

Routing Configuration

IP forwarding is enabled to allow FW2 to route traffic between the DMZ and the internal network:

echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-ipforward.conf

Firewall rules

Traffic filtering is implemented using iptables, following a default-deny approach.

# Flush existing rules
sudo iptables -F
sudo iptables -X

# Default policies
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT

# Allow loopback
sudo iptables -A INPUT -i lo -j ACCEPT

# Allow established and related traffic
sudo iptables -A INPUT   -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

# Allow Application Server → Database
sudo iptables -A FORWARD \
    -s 192.168.20.10 \
    -d 192.168.0.20 \
    -p tcp --dport 5432 \
    -m conntrack --ctstate NEW \
    -j ACCEPT

# Allow Application Server → Security Challange Database
sudo iptables -A FORWARD \
    -s 192.168.20.10 \
    -d 192.168.0.20 \
    -p tcp --dport 5432 \
    -m conntrack --ctstate NEW \
    -j ACCEPT

sudo iptables-save | sudo tee /etc/iptables/rules.v4

Machine 5 — Database Server (LAN)

This machine hosts the database server and is deployed in the internal (LAN) zone, which is the most trusted part of the infrastructure. The database is not exposed to external networks and is accessible only from the application server through the internal firewall (FW2).

Network configuration

The database server is configured with a single network interface and a static IP address. The default gateway points to the internal firewall (FW2). The configuration is performed by editing /etc/network/interfaces.

Example configuration:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.0.20
    netmask 255.255.255.0
    gateway 192.168.0.1

Host firewall configuration

Host-based access control is enforced using UFW. The firewall is configured to deny all inbound traffic by default and allow database connections only from the application server.

Example UFW configuration:

sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow database access only from the application server
sudo ufw allow from 192.168.20.10 to any port 5432 proto tcp

sudo ufw enable

PostgreSQL configuration

The database service is provided by PostgreSQL. To ensure that the database is not exposed beyond the internal network, PostgreSQL is configured to listen only on the server’s LAN IP address.

Edit the PostgreSQL configuration file:

sudo nano /etc/postgresql/*/main/postgresql.conf

Set the following parameter:

listen_addresses = '192.168.0.20'

Restart the service:

sudo systemctl restart postgresql

To restrict database access to the application server, the PostgreSQL client authentication configuration is updated.

Edit:

sudo nano /etc/postgresql/*/main/pg_hba.conf

Add the following entry:

host    all     all     192.168.20.10/32    scram-sha-256

Reload the configuration:

sudo systemctl reload postgresql

To verify that PostgreSQL is listening on the correct address and port:

ss -lntp | grep 5432

Machine 6 — Security Challenge Server (LAN)

This machine hosts the Security Challenge service and is deployed in the internal (LAN) zone, alongside the database server. Its configuration is identical to the Database Server, including network setup, firewall rules, and service-level access restrictions.

The only difference is the static IP address, which is assigned from the same internal subnet. All security controls remain unchanged, and the machine is reachable only from the application server through the internal firewall (FW2).

No additional configuration steps are required beyond those described for the Database Server.

Additional Configuration: Application Artifacts, Keys, and Certificates

After cloning the project repository, several application artifacts and cryptographic materials must be placed on the appropriate machines. This section describes the required directory structure, key distribution assumptions, and build steps for the client and server components.

Key distribution assumptions

The project assumes the following key distribution model:

  • All machines have access to all public keys.

  • Private keys are present only on the machine they belong to (i.e., a client private key exists only on that client, and the server private key exists only on the server).

Client-side directory structure

On each WAN client machine, the application files are placed under the user’s home directory with the following structure:

/home/<user>/client/
├── client/
│   └── client.jar
├── keys/
│   ├── <public and private key files>
│   ├── document.json
│   ├── document2.json
│   └── tls/
│       └── <client TLS certificates>
  • The client.jar file contains the compiled client application.

  • The keys directory contains all required public keys, the client’s private key, and the JSON documents provided in the repository.

  • The tls subdirectory contains the TLS certificates generated for the client.

TLS certificates for the client and server are generated by running the provided script after cloning the repository:

./scripts/setup-TLS.sh

Server-side directory structure

On the application server, files are placed under the user’s home directory using a similar structure:

/home/<user>/server/
├── server/
│   └── server.jar
├── keys/
│   ├── <public and private key files>
│   └── tls/
│       └── <server TLS certificates>
  • The server.jar file contains the compiled server application.

  • The keys directory contains all public keys and the server’s private key.

  • The tls subdirectory contains the TLS certificates generated for the server.

Building the application artifacts

Before deploying the client and server applications, the project must be built locally using Maven.

After cloning the repository, the following steps are performed:

# Build shared libraries client and server
cd A41-ChainOfProduct
mvn clean install

This process produces the client.jar and server.jar files.

The resulting JAR files are then copied to their respective machines and placed in the directory structures described above.

Summary

In summary:

  • All machines share public keys; private keys remain local to their owners.

  • Clients and the server follow a fixed directory structure under the user’s home directory.

  • TLS certificates are generated and deplyed manually using the provided script.

  • Application artifacts are built using Maven and deployed manually to the appropriate machines.

This organization ensures a clear separation of responsibilities, reproducible setup steps, and proper handling of sensitive cryptographic material.

Database Setup

Before executing the demonstration, the database must be initialized with the required schema and data. This setup is performed from the Application Server, which is the only machine authorized to connect to the database.

Database connection

This demonstrates the steps to configure the first database, the security challenge database should be configured using the same command with the appropriate IP and files.

From the Application Server, connect to the PostgreSQL instance running on the internal database server:

psql -h 192.168.0.20 -U postgres

Successful connection confirms that network-level and database-level access controls are correctly configured.

Database creation

Once connected, create the required database:

CREATE DATABASE chain_of_product;

For Security Challenge:

CREATE DATABASE company_groups;

Then Connect to the database:

\c chain_of_product

Schema and data initialization

With the correct database selected, execute the provided schema and population scripts included in the repository:

\i documents_schema.sql
\i documents_populate.sql

Client identity requirements

It is important to note that client identities used during the demonstration must already exist in the database. For example following the steps below company could have the entities for example:

  • Client 1: LaysChips

  • Client 2: FutureTech

These identities are inserted as part of the database population step and are required for authentication, authorization, and permission management to function correctly. Using client names that are not present in the database will result in failed operations.

Demonstration

This section demonstrates the correct operation of the system and highlights the enforced security mechanisms. The demonstration follows the same sequence that would be used in a live execution, starting the server, running multiple clients, and executing protected operations while observing both successful and rejected actions.

Server startup

The demonstration begins by starting the application server on the Application Server (DMZ) machine.

cd ~/server/server
java -jar server.jar

The expected result is that the server starts listening on the configured port and prints messages indicating successful initialization and readiness to accept client connections.

Client 1 startup and document protection

On a WAN client machine, the first client is started:

cd ~/client/client
java -jar client.jar Client1

Now we should see the Client console. To protect a document, the following command is executed in the client console:

protect ../document.json

The expected result is:

  • the document is successfully protected,

  • the server logs indicate a valid authenticated request.

Document access by Client 1

To retrieve the protected document, Client 1 executes:

unprotect 123 # (Document ID)

The document is correctly returned, confirming that the owner of the document has full access rights.

Granting permissions to a Third Party

Client 1 grants access permissions to another client:

update-permissions 123 Client2

The expected result is a confirmation message indicating that permissions were updated successfully.

Client 2 startup and permission verification

On a different WAN client machine (with the correct keys for Client2), the second client is started:

cd ~/client/client
java -jar client.jar Client2

Client 2 queries the permissions associated with the document:

see-permissions 123

The output shows that Client 2 has access to the document.

Client 2 then successfully retrieves the document:

unprotect 123

This demonstrates that access control rules are correctly enforced for authorized third parties.

Unauthorized operation attempt

Client 2 attempts to update permissions:

update-permissions 123 OtherClient

This operation fails, and an error message is displayed indicating insufficient permissions. This step demonstrates that only the buyer or seller is allowed to modify access permissions, and that unauthorized actions are correctly rejected.

Group-based permission update

Client 1 updates the document permissions to grant access to a group:

update-permissions 123 Group_A

Client 1 then verifies the permissions:

see-permissions 123

The output displays all entities (clients and groups) with access to the document.

Permission visibility from Client 2

Finally, Client 2 queries the permissions again:

see-permissions 123

The output shows only the entities relevant to Client 2’s role (e.g., buyer, seller, and Client2), confirming that permission visibility is restricted according to the client’s privileges.

Security mechanisms in action

Throughout the demonstration, the following security mechanisms are actively enforced and observable:

  • Secure client–server communication using TLS.

  • Authentication of clients using cryptographic keys.

  • Fine-grained access control on protected documents.

  • Rejection of unauthorized operations with explicit error messages.

This concludes the demonstration.

Additional Information

Links to Used Tools and Libraries

Versioning

We use SemVer for versioning.

License

This project is licensed under the MIT License - see the LICENSE.txt for details.

(switch to another license, or no license, as you see fit)


END OF README

About

IST Network and Computer Security project, 2025/2026

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages