All projects
Nov 2024

Secure Programming: Vulnerability Analysis & Defense

A hands-on study of how real software fails and how to fix it: analysing two high-profile CVEs, then threat-modelling, exploiting and hardening a Flask application that manages WireGuard VPN configurations.

PythonCFlaskCVESTRIDESecurity

Hardening the VPN management app

01

Threat model

STRIDE analysis of authentication, storage and endpoints

02

Exploit

Demonstrated access to other users' and admin VPN configs

03

Fix

Encrypted storage and role-aware access control

04

Redesign

MFA, centralised RBAC, audit logging and rate limiting

CVE analysis

  • ▸CVE-2024-3094: the XZ Utils backdoor, malicious code hidden in a widely used compression library that could compromise SSH servers
  • ▸CVE-2020-11899: part of the Ripple20 vulnerabilities in the Treck TCP/IP stack used in embedded and IoT devices: an out-of-bounds read in IPv6 handling

Threat model (STRIDE)

  • ▸Spoofing: password-only login, and a session role value that could be manipulated
  • ▸Tampering: plaintext configuration files and a download endpoint allowing arbitrary file access
  • ▸Repudiation: no logging of user actions
  • ▸Information disclosure: sensitive server configs and keys stored in plaintext
  • ▸Denial of service: no rate limiting on expensive operations
  • ▸Elevation of privilege: guessable filenames exposing admin configuration

Fixes and redesign

Configuration files were encrypted with per-user keys, with separate keys for admin files, and download logic was rewritten so users can only access and decrypt their own files. A proposed redesign adds multi-factor authentication, centralised role-based access control, signed and encrypted sessions, AES-256 encryption with PBKDF2-derived keys, audit logging and rate limiting.