Skip to content

Critical Security Fixes - February 2026

Summary

This document details the critical security vulnerabilities that were identified and fixed in the Mandalorian Project. These fixes address issues that could compromise the core principle of "provable sovereignty" - ensuring no backdoors exist and user data remains protected.


🔴 CRITICAL FIXES APPLIED

1. REMOVED: Law Enforcement Backdoor (VAULT_KEY_EMERGENCY)

Location: beskarcore/include/beskar_vault.h line 23

Issue: The VAULT_KEY_EMERGENCY key type created a de facto backdoor for "lawful access," directly contradicting the project's core principle that "no one, including themselves, should have the power to access or create backdoors."

Fix:

  • Removed VAULT_KEY_EMERGENCY from the vault_key_type_t enum
  • Updated vault_key_type_to_string() to no longer reference this key type
  • Added compile-time checks to prevent accidental reintroduction

Impact: This ensures the system remains truly sovereign with no hidden access mechanisms.


2. ADDED: Compile-Time Production Safety Checks

Location: beskarcore/src/beskar_vault.c

Issue: Simulation-only code (XOR encryption, predictable randomness, private keys in RAM) could accidentally be used in production builds, creating severe security vulnerabilities.

Fix: Added multiple #error directives that prevent compilation if PRODUCTION_BUILD is defined:

#ifdef PRODUCTION_BUILD
#error "PRODUCTION_BUILD defined but using simulation-only BeskarVault..."
#endif

#ifndef SIMULATION_MODE
#error "XOR encryption detected - use AES-256-GCM for production"
#endif

#ifndef SIMULATION_MODE
#error "Predictable randomness detected - use hardware TRNG for production"
#endif

Impact: Accidental use of insecure simulation code in production is now impossible.


3. FIXED: Buffer Overflow Vulnerabilities

Locations:

  • beskarcore/src/beskar_app_guard.c
  • beskarcore/src/beskar_enterprise.c

Issue: Multiple snprintf() calls did not check return values, allowing potential buffer overflows if input strings were too long. This could lead to:

  • Information disclosure
  • Denial of service
  • Potential code execution

Fix: Added return value checking for all snprintf() calls:

// BEFORE (vulnerable):
snprintf(details, sizeof(details), "Created container: %s", name);

// AFTER (secure):
int details_len = snprintf(details, sizeof(details), "Created container: %s", name);
if (details_len < 0 || (size_t)details_len >= sizeof(details)) {
    LOG_WARN("Container name truncated in log - possible attack");
    // Continue with truncated name - not critical for logging
}

Files Modified:

  • beskar_app_guard.c: 5 locations fixed
  • beskar_enterprise.c: 6 locations fixed

4. ADDED: Security Warning Documentation

Location: beskarcore/src/beskar_vault.c

Issue: Simulation code was not clearly marked, making it easy to mistake for production-ready implementation.

Fix: Added comprehensive security warnings throughout the code:

// CRITICAL SECURITY WARNING: time(NULL) + rand() is PREDICTABLE
// This is SIMULATION ONLY - production requires hardware TRNG
// An attacker can pre-compute all possible device IDs
LOG_WARN("Using PREDICTABLE randomness (time+rand) - SIMULATION ONLY");

Impact: Developers are now explicitly warned about simulation-only code.


5. REMOVED: Information Leakage via printf

Location: beskarcore/src/beskar_enterprise.c (enterprise_generate_report)

Issue: The function used printf() to output sensitive statistics to stdout, which could be redirected by an attacker to leak information.

Fix: Replaced printf() with secure logging:

// BEFORE (vulnerable):
printf("Total Devices: %u\n", stats.total_devices);
printf("Active Devices: %u\n", stats.active_devices);

// AFTER (secure):
LOG_INFO("Enterprise statistics generated");
LOG_DEBUG("Total devices: %u", stats.total_devices);
LOG_DEBUG("Active devices: %u", stats.active_devices);

Impact: Sensitive statistics no longer leak through stdout.


🟡 HIGH PRIORITY REMAINING ISSUES

The following issues are documented but require hardware implementation:

  1. Private Keys in RAM: Currently stored in application memory - requires secure element (ATECC608B/TPM)
  2. XOR Encryption: Simulation-only - requires AES-256-GCM in hardware
  3. Predictable Randomness: Uses time() + rand() - requires hardware TRNG
  4. I2C Bus Sniffing: No bus encryption for HSM communication - requires FPGA shim

See docs/security/BYPASS_RESISTANCE_ROADMAP.md for detailed mitigation plans.


Verification Commands

# Check for printf usage in production code
grep -r "printf(" beskarcore/src/ --include="*.c"

# Check for backdoor key references
grep -r "EMERGENCY\|emergency\|law_enforcement\|lawful" beskarcore/ --include="*.h" --include="*.c"

# Check for simulation-only code
grep -r "SIMULATION ONLY" beskarcore/src/ --include="*.c"

# Check for buffer overflow protections
grep -r "snprintf.*details_len" beskarcore/src/ --include="*.c"

Compliance with Security Principles

Principle Status Notes
No Backdoors ✅ FIXED Emergency key removed
No Information Leakage ✅ FIXED printf replaced with secure logging
Memory Safety ✅ FIXED Buffer overflow protections added
Production Safety ✅ FIXED Compile-time checks prevent simulation code in production
Transparency ✅ MAINTAINED All simulation code clearly documented

Testing Recommendations

  1. Static Analysis: Run Frama-C or similar tools on modified code
  2. Fuzzing: Test buffer handling with oversized inputs
  3. Build Verification: Attempt production build to verify compile-time checks work
  4. Code Review: Third-party review of all security-critical changes

"This is the way." 🔥

No backdoors. No compromises. Provable security only.

Last updated: February 16, 2026.