Back to Projects

Cybersecurity & LLM Engineering ·

Clara: Cybersecurity based LLM for Anomaly and Risk Assessor

A privacy-preserving, local-first large language model fine-tuned on a custom refined PrimeVul corpus. Optimized to perform deep structural analysis of source code, trace visual logic bugs, map detailed CWE markers, and execute contextual risk assessments with out-of-the-box T-RAG capabilities.

Clara Project Logo
Clara Project Logo
Clara Project Logo

Minimalist local web terminal connecting directly to Ollama instance layers.

Problem Statement

As large language models exhibit superior software composition mechanics, traditional static application security testing (SAST) engines face major hurdles. Pattern-matching utilities and abstract syntax tree scanners reliably discover fixed syntactical rules but consistently fail to capture nuanced multi-file logical flows, dynamic execution context anomalies, and custom vulnerability vectors. Clara evaluates how fine-tuning an LLM on targeted vulnerabilities allows software security engineering to move away from rigid regex heuristics toward contextual reasoning.

Architecture Breakdown

  • Data Engineering Pipeline: Tailored Python extraction utilities parsing raw vulnerability databases. Resolves integer size crashes (> 2^32), drops high-variance metadata columns to limit execution noise, and converts raw methods into instruction-tuned dialogue formats.
  • Quantized Parameter Fine-Tuning: Leveraging the Unsloth frame layer to complete memory-efficient training utilizing 4-bit NormalFloat (NF4) primitives. Injects Q-LoRA adapters targeting critical attention weights (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj) at a target matrix rank of 16.
  • Alignment Token Masking: Incorporates explicit response-only training constraints via train_on_responses_only paradigms. Forces gradient calculation logic to safely ignore input code block matrices, isolating structural optimization updates onto security diagnostics payload parameters.
  • Local Integration Layer: Exported from 16-bit float maps into low-overhead, local binary tables (GGUF format via llama.cpp) executed via dedicated local Ollama system templates.

Why This Needed Custom Engineering

Vanilla foundational LLMs struggle to evaluate source anomalies cleanly due to high token densities and strict structural syntax conditions. Standard instruction models treat structural vulnerabilities as generalized semantic tokens, resulting in high false-positive frequencies and an inability to correctly parse spatial execution loops (such as multi-stage Use-After-Free code logic branches).

By structuring an instruction-to-telemetry model sequence, Clara binds raw functionality directly to standard Common Weakness Enumeration identifiers (CWEs) and precise mitigation statements, optimizing predictive accuracy within constrained parameter limits.

Operational Core Challenges and Fixes

ChallengeTechnical DescriptionPortfolio Mitigation Strategy
Data Boundary OverflowMemory compilation pipelines choked when handling exceptionally large out-of-bounds integer assignments (>2^32) found in unstructured logs.Constructed an intermediate JSONL normalization hook to re-type extreme boundaries as isolated string fields securely.
Input Context OverloadBroad feature inputs over-indexed gradient calculations on non-vulnerable syntax semantics, reducing weight precision.Integrated explicit token masking layers to ignore the user prompt array and compute loss maps exclusively on assistant classifications.
Logical Path BlindnessQuantized layers often skipped silent logical bugs (like hidden heap allocations) due to token consolidation layers.Supercharged sequence alignment by custom-mapping explicit response structures matching target CVE metrics directly into model weight profiles.
CORS Runtime ViolationsClient-side UI execution encountered cross-origin boundaries when communicating directly with local daemon APIs.Wired dynamic CORS origin configurations (OLLAMA_ORIGINS=*) during backend service instantiations to preserve data paths.

Security Diagnostics Capabilities

Clara operates as a secure, local auditing platform capable of executing cross-platform validation sweeps on production-level source configurations.

Capability LayerSupport LevelImplementation & Execution Notes
Multi-File Context SynthesisNativeIngests .js, .py, .json, .html, and .css assets directly into active inference queues via file streaming maps.
CWE Categorization MappingFullAutomatically isolates code anomalies and assigns strict classifications (e.g., CWE-416 Heap Bugs).
Temporal RAG (T-RAG)IntegratedConnects external database instances using proxy capture networks to ingest timely patch records.
Session State PreservationNativeParses raw DOM structures via regex handlers to write complete historical chat sequences to markdown logs.

Engineering Outcome

The compiled system successfully eliminates reliance on external SaaS-based security checkers, allowing comprehensive codebases to undergo deep security audits locally. This architecture eliminates the telemetry privacy leak vectors typical of third-party APIs while delivering low-latency, hardware-accelerated inference across memory-restricted developer environments.