Skip to content

Add USB-based hardware authentication for administrative operations - #265

Merged
makr-code merged 5 commits into
developfrom
copilot/add-security-feature-encrypted-usb
Jan 7, 2026
Merged

makr-code merged 5 commits into
developfrom
copilot/add-security-feature-encrypted-usb

Conversation

Copilot AI commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

Implements hardware-based admin authentication requiring encrypted USB device with per-license validation. Admin operations fail silently without valid USB present, integrating seamlessly with existing token/JWT authentication.

Core Components

  • USBAdminAuthenticator - Validates USB presence, license files, hardware binding (machine-id), and signatures
  • License format - JSON with hardware_id, expiry, admin_scopes, RSA signature
  • AuthMiddleware integration - USB check added for configurable admin scopes (admin, config:write, etc.)
  • Security mechanisms - Silent failure, audit logging, lockout after failed attempts, metrics tracking

Usage

AuthMiddleware auth;

// Enable USB authentication for admin scopes
auth.enableUSBAdminAuth(
    "/mnt/themis-admin",
    {"admin", "config:write", "admin:backup"}
);

// Admin operations now require both valid token AND USB device
// Without USB: silent 403, logged to audit

License File Format

{
  "license_key": "THEMIS-ENT-ADMIN-XXXXX",
  "hardware_id": "550e8400-e29b-41d4-a716-446655440000",
  "issued_date": "2026-01-01",
  "expiry_date": "2027-12-31",
  "admin_scopes": ["admin", "config:write"],
  "signature": "RSA-SHA256-SIGNATURE"
}

Platform Support

  • Linux - machine-id from /etc/machine-id
  • Windows - Placeholder for MachineGuid (needs registry implementation)

Production TODOs

⚠️ Security placeholders (clearly marked with warnings):

  1. RSA signature verification - currently accepts any non-empty signature
  2. Challenge-response mechanism - no replay protection implemented
  3. Windows hardware ID - needs registry access

Hardware ID fallback fails securely (empty string) rather than using shared static ID.

Additional Changes

  • Fixed pre-existing CMake errors (orphaned if/endif, VERSION format handling)
  • Added 14 unit tests covering USB detection, validation, lockout, metrics
  • Bilingual documentation (DE/EN)
Original prompt

Ich möchte ein Security-feature für die Themis erstellen. Dieses soll auf einem encryptet boot-USB (oder anderes Speicehrmedium) basieren, der pro Lizenz die Administration am Hardware-Server erlaubt. Dieser Stick soll sich in die Sicherheitsarchitektur natlos einfügen und die Systemebenen der Administratoren besonders gegen Manipulation schützen, so das ohne den Stick keine administrativen Funktionen ausgeführt werden (silent failure, aber logging)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add security feature for administrative access using encrypted USB Add USB-based hardware authentication for administrative operations Jan 7, 2026
Copilot AI requested a review from makr-code January 7, 2026 09:28
@makr-code
makr-code marked this pull request as ready for review January 7, 2026 10:21
@makr-code
makr-code merged commit b94a545 into develop Jan 7, 2026
@makr-code makr-code added this to the v1.0.2 milestone Mar 11, 2026
Copilot AI added a commit that referenced this pull request May 11, 2026
…HMAC/embedding stubs

- GGUFMetadata (stub #259): add HmacFn type alias + setHmacFn() static API;
  sign()/verify() delegate to injected fn when set, fall back to XOR stub;
  fail-closed on fn exception; source comments updated from #173 → #259

- FlareRetrieval (stub #260): add EmbeddingQueryFn type alias + setEmbeddingQueryFn()
  static API + buildQueryEmbedding() method; string buildQuery() path retained
  as documented fallback; fail-closed on fn exception

- TensorRAGPipeline (stub #261): add EmbeddingQueryFn + setEmbeddingQueryFn()
  static API; step() populates RAGDecision::flare_query_embedding when fn set
  and FLARE triggers; fail-closed on fn exception

- STUB_INVENTORY.md: 21 new entries (#259–#277, with #263 as a/b/c subtypes);
  header updated to 272 entries / 238 resolved / 34 active; source ID conflicts
  for AR-01 (#172→#265), AR-02 (#177→#266), mmap-bridge (#176→#270),
  fingerprint-graph (#174→#276) noted and source comments updated

- All three bridges follow the gpu_tensor.cpp pattern: static function-local
  mutex + static function-local std::function storage; thread-safe getter/setter

Co-authored-by: Copilot <[email protected]>

Co-authored-by: makr-code <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants