Inspiration Security tools are excellent at finding vulnerabilities, but identifying a problem is only the first step. Developers still need to understand each alert, write a secure fix, test the change, and ensure the application was not broken.

Aegis was created to close that gap. It combines deterministic security scanning with local AI to turn vulnerability findings into proposed, validated code patches while keeping source code offline and private.

What It Does Aegis is an autonomous, offline security remediation agent for Python projects.

Scans: Uses Semgrep to detect vulnerabilities such as SQL injection, command injection, path traversal, SSRF, secrets, and insecure deserialization. Analyzes: Extracts the vulnerable code and sends focused context to a local Phi-3 language model. Patches: Generates structured, context-aware remediation patches. Validates: Applies patches inside a sandbox, checks Python syntax, and rescans the modified code with Semgrep. Remembers: Stores successfully validated patch patterns for faster future remediation. Reports: Produces Markdown and PDF security reports containing findings, analysis, patch status, and validation results. How We Built It Static Security Analysis Semgrep is used as the deterministic detection layer. It identifies the vulnerability type, file, location, and relevant code context before the language model is invoked.

Local AI Remediation Aegis runs the Phi-3-mini 4-bit GGUF model through llama.cpp. The model operates locally on CPU-only hardware, allowing source code to remain on the user’s machine.

Prompt Engineering The model receives structured prompts containing the vulnerability rule, severity, root-cause context, and vulnerable code. The patch response must follow a strict JSON schema and provide replacement code.

Sandboxed Validation Generated patches are first applied inside aegis_workspace. Aegis performs syntax validation and runs Semgrep again to determine whether the original vulnerability remains. The original project is only changed after the patch is approved and validated.

Conversational Interface Users interact with Aegis through a conversational CLI. Natural-language requests can identify a file or directory, such as:

Challenges We Ran Into Running AI on Limited Hardware The system was designed for an approximately 8 GB RAM, CPU-only laptop. We addressed this by using a quantized Phi-3 model, limiting the context window, and restricting inference to physical CPU cores.

Reducing Hallucinations Sending an entire codebase to an LLM increases context usage and can lead to unnecessary rewrites. Semgrep provides precise vulnerability locations, allowing Aegis to send only the relevant code context to the model.

Patch Safety A generated patch can be syntactically valid while remaining insecure. Aegis therefore combines syntax checks with a second Semgrep scan, and it requires user approval before modifying the original project.

Reliable Target Resolution Natural-language prompts may refer to files using shortened names. Aegis now resolves evaluation targets such as demo/sqli_demo.py and demo/cmd_demo.py to their concrete project locations under demo.

Offline Dependency Handling The model and security workflow must work without cloud APIs. Aegis uses local model files, local Semgrep rules, and a bundled llama.cpp runtime.

Accomplishments We Are Proud Of Built an end-to-end workflow from vulnerability discovery to patch proposal and validation. Created a fully offline security remediation workflow for Python projects. Added SQL injection and command injection evaluation fixtures. Successfully detected both evaluation vulnerabilities with Semgrep. Validated secure SQL parameterization and safe subprocess argument-list remediation in temporary sandbox copies. Added local patch memory to reduce repeated inference work. Added ADTC-compatible metadata, model downloading, reporting, and compliance checks. Designed the system to operate on affordable CPU-only hardware. What We Learned Deterministic Tools and AI Work Better Together Semgrep is effective at precise vulnerability discovery, while the language model is useful for explaining the issue and proposing a remediation. Combining both produces a more controlled workflow than relying on either approach alone.

Prompt Precision Matters Clear file paths, vulnerability types, database requirements, and patch constraints significantly improve the quality of generated code.

Validation Must Be Independent A patch should not be considered secure simply because the model says it is fixed. Re-running static analysis in a sandbox provides an independent verification step.

Resource Limits Shape Architecture Memory and CPU constraints influenced the model choice, context size, inference settings, and the decision to cache validated patches locally.

What’s Next for Aegis Add broader language support beyond Python. Improve patch generation for larger and more complex code regions. Add automated unit-test execution after patch generation. Add GitHub Actions and GitLab CI integrations. Generate pull requests containing proposed security fixes. Improve report visualization and patch-diff presentation. Add stronger patch validation for behavioral regressions. Provide reproducible benchmark reports through the ADTC profiler. Project Technologies Python Semgrep Phi-3-mini GGUF llama.cpp SQLite JSON-based patch and report workflows CPU-only offline inference Submission Context Aegis was developed for the Africa Deep Tech Challenge 2026 Autonomous AI Agents track. It demonstrates how local AI and deterministic security tooling can provide practical application-security assistance without cloud infrastructure or expensive hardware.

Built With

Share this project:

Updates