Skip to content

mmEASV/SecureSoftwareDevelopment

Repository files navigation

CRA-Compliant Automated Device Update System

A proof-of-concept implementation demonstrating EU Cyber Resilience Act (CRA) compliance for automatic security updates

.NET Blazor PostgreSQL Docker


πŸ“‹ Table of Contents


🎯 Problem Statement

Currently the client updates all of the deployed devices manually with flash drives. This kind of worked in the past, but it is slow and doesn't meet the new Cyber Resilience Act (CRA) requirements.

The CRA says manufacturers need to provide automatic security updates by default.

CRA Requirements (Annex 1 - 2, c)

According to the regulation:

ensure that vulnerabilities can be addressed through security updates, including, where applicable, through automatic security updates that are installed within an appropriate timeframe enabled as a default setting, with a clear and easy-to-use opt-out mechanism, through the notification of available updates to users, and the option to temporarily postpone them;

Key Requirements:

  • βœ… Automatic security updates enabled by default
  • βœ… Clear and easy opt-out mechanism
  • βœ… Notification of available updates
  • βœ… Option to temporarily postpone updates
  • βœ… Appropriate timeframe for security patches

πŸ’‘ Solution

The client needs a solution for semi-automatic updates, where they can release updates, but it will be up to their customers to deploy them.

The system provides:

  1. Vendor Portal (Admin.Api + Admin.Web)

    • Web app for the vendor to upload new updates
    • Create and manage releases
    • Monitor device deployment status
  2. Customer Portal (ClientPortal.Api + ClientPortal.Web)

    • Web portal for customers to view available updates
    • Schedule deployment of software updates
    • Configure automatic update settings
    • Postpone updates with reason tracking
  3. Device Agent (ClientPortal.UpdateAgent)

    • Background service on customer devices
    • Automatically checks for and installs updates
    • Verifies update integrity and authenticity
  4. Secure Delivery

    • SHA-256 file integrity verification
    • RSA-4096 digital signatures
    • HTTPS/TLS transport encryption
    • Cloudflare Tunnel support

✨ Features

CRA Compliance

Feature Status Implementation
Default automatic updates βœ… Device.AutomaticUpdates = true on registration
Easy opt-out βœ… Device settings API endpoint
Update notifications βœ… Customer portal lists all updates
Postpone capability βœ… Deployment postpone API with reason
Timeframe enforcement βœ… Max 7-day postpone for mandatory updates
Security transparency βœ… CVE lists, changelogs, severity levels

Technical Features

  • Separated APIs - Admin.Api (vendor) and ClientPortal.Api (customer)
  • Shared Database - Single PostgreSQL database for data consistency
  • File Upload - Multipart form-data with SHA-256 hashing
  • Digital Signatures - RSA-4096 for update authenticity
  • Deployment Tracking - Status, retry count, postpone tracking
  • Tenant Isolation - Multi-tenant support
  • Comprehensive Testing - 128 tests covering all features

πŸ—οΈ Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     VENDOR SIDE (Admin)                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Admin.Api          - Upload updates, create releases       β”‚
β”‚  Admin.Web          - Vendor admin portal (Blazor WASM)     β”‚
β”‚  Admin.Shared       - Shared models and DTOs                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   CUSTOMER SIDE (ClientPortal)               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  ClientPortal.Api   - View releases, manage devices         β”‚
β”‚  ClientPortal.Web   - Customer portal (Blazor WASM)         β”‚
β”‚  ClientPortal.UpdateAgent - Device agent (background svc)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     SHARED INFRASTRUCTURE                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PostgreSQL         - Shared database (AdminDb)             β”‚
β”‚  .NET Aspire        - Service orchestration                 β”‚
β”‚  Cloudflare Tunnel  - Secure remote access                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

  • .NET 10.0 - Application framework
  • ASP.NET Core Minimal APIs - Backend APIs
  • Blazor WebAssembly - Frontend portals
  • Entity Framework Core - Data access
  • PostgreSQL - Database
  • .NET Aspire - Orchestration
  • FluentUI - UI components
  • xUnit - Testing framework

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone <repository-url>
    cd SecureSoftwareDevelopment
  2. Restore packages

    dotnet restore
  3. Start Docker Desktop (required for PostgreSQL)

  4. Configure Aspire secrets (optional)

    cd src/AppHost
    dotnet user-secrets set "Parameters:postgres-username" "root"
    dotnet user-secrets set "Parameters:postgres-password" "password"
  5. Run with .NET Aspire

    cd src/AppHost
    dotnet run
  6. Access the application


πŸ“– Usage

Development Commands

# Build the solution
dotnet build

# Run tests (128 tests)
dotnet test

# Run specific test project
dotnet test tests/Admin.Api.Tests/

# Database migrations
cd src/Admin.Api
dotnet ef migrations add <MigrationName>
dotnet ef database update

# Clean build artifacts
dotnet clean

Project Structure

src/
β”œβ”€β”€ Admin.Api/              # Vendor backend API
β”œβ”€β”€ Admin.Web/              # Vendor portal (Blazor WASM)
β”œβ”€β”€ Admin.Shared/           # Shared models and DTOs
β”œβ”€β”€ ClientPortal.Api/       # Customer backend API
β”œβ”€β”€ ClientPortal.Web/       # Customer portal (Blazor WASM)
β”œβ”€β”€ ClientPortal.UpdateAgent/ # Device agent
β”œβ”€β”€ AppHost/                # .NET Aspire orchestration
└── ServiceDefaults/        # Common configurations

tests/
└── Admin.Api.Tests/        # Test suite (128 tests)

API Endpoints

Admin.Api (Vendor Operations):

POST   /api/updates              # Upload new update
GET    /api/updates              # List all updates
GET    /api/updates/{id}/download # Download update file
POST   /api/releases             # Create release
GET    /api/releases             # List all releases

ClientPortal.Api (Customer Operations):

GET    /api/releases/active      # View active releases
POST   /api/devices              # Register device
PUT    /api/devices/{id}/settings # Configure auto-updates
POST   /api/deployments/schedule # Schedule deployment
PUT    /api/deployments/{id}/postpone # Postpone deployment

βœ… CRA Compliance

How It Works

  1. Default Automatic Updates

    • All devices registered with AutomaticUpdates = true by default
    • Complies with CRA requirement for default automatic updates
  2. Clear Opt-Out Mechanism

    • Device settings endpoint allows disabling automatic updates
    • Customer portal provides UI to configure settings
  3. Update Notifications

    • Customer portal lists all available updates
    • Shows severity, CVE lists, changelogs
  4. Postpone Capability

    • Customers can postpone deployments with reason
    • System tracks postpone count and reasons
  5. Appropriate Timeframe

    • Mandatory security updates have 7-day max postpone period
    • Enforced at API level to ensure compliance
  6. Security Transparency

    • All updates show CVE lists
    • Severity levels (Critical, High, Medium, Low)
    • Detailed changelogs and security fixes

Compliance Verification

Run the CRA compliance integration tests:

dotnet test --filter "Category=CRACompliance"

All 10 CRA compliance tests verify:

  • Default automatic updates
  • Opt-out functionality
  • Postpone mechanism
  • Mandatory update enforcement
  • Security transparency

πŸ“š Documentation


πŸ§ͺ Testing

Test Coverage: 128 Tests

  • βœ… 96 Repository tests (CRUD operations)
  • βœ… 13 File storage tests (integrity verification)
  • βœ… 9 API endpoint tests (behavior validation)
  • βœ… 10 CRA compliance tests (regulatory requirements)

Run all tests:

dotnet test
# Passed!  - Failed: 0, Passed: 128, Skipped: 0, Total: 128

πŸ”’ Security

Security Layers:

  1. API Key Authentication (device authentication)
  2. SHA-256 File Hashing (integrity verification)
  3. RSA-4096 Digital Signatures (authenticity verification)
  4. TLS/HTTPS (transport encryption)
  5. Tenant Isolation (database-level separation)
  6. Cloudflare Tunnel (secure remote access)

Production Considerations:

  • Hash API keys before storage
  • Implement rate limiting
  • Add DDoS protection
  • Use certificate-based device auth
  • Encrypt files at rest
  • Security scan uploaded files

πŸ“ License

This is an educational project demonstrating CRA compliance principles.

Recommended for:

  • βœ… Learning CRA compliance
  • βœ… Architecture reference
  • βœ… Starting point for production systems
  • βœ… Academic/research purposes

Before production use:

  • Security audit and penetration testing
  • Implement production-grade authentication
  • Add monitoring and alerting
  • Set up proper CI/CD pipeline

πŸ™ Acknowledgments

  • EU Cyber Resilience Act - Regulatory framework
  • .NET Foundation - ASP.NET Core, Blazor, EF Core
  • Microsoft - .NET Aspire, FluentUI
  • Cloudflare - Secure tunneling solution

Built with .NET 10.0 | January 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published