JSPM

cortexhq

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 20
  • Score
    100M100P100Q71953F
  • License MIT

CortexHQ: Security & Guardrails for AI Code

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cortexhq) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    ๐Ÿ›ก๏ธ CORTEX

    Intent-Aware Security for AI-Generated Code

    The first security engine designed specifically for "vibe coding"

    TypeScript License Security Rules Detection Layers

    Quick Start โ€ข Detection Engine โ€ข CLI Commands โ€ข Benchmarks


    ๐ŸŽฏ The Problem

    AI coding assistants (Cursor, Copilot, Claude) generate code that works but isn't secure:

    Issue What Happens CORTEX Detection
    Client-side auth if (password === 'admin') in React โœ… Invariant violation
    RLS bypass using (true) in Supabase policies โœ… Policy misconfiguration
    Hallucinated packages npm install react-native-encrypt-fast โœ… Slopsquatting detection
    Missing rate limits Public /api/signup with no protection โœ… Absence-of-control
    SQL injection Template literals in queries โœ… Taint analysis

    Traditional SAST misses these because the code is "correct" โ€” it just violates security intent.


    โœ… The Solution

    CORTEX is an Intent-Aware Security Engine with 6 detection layers:

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                    CORTEX DETECTION ENGINE                  โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚  Layer 1:   Semgrep Patterns (SQLi, XSS, secrets)          โ”‚
    โ”‚  Layer 1.5: Dependency Intelligence (CVEs, hallucinations) โ”‚
    โ”‚  Layer 2:   Taint Analysis (source โ†’ sink tracking)        โ”‚
    โ”‚  Layer 3:   Policy Semantics (RLS, Firebase, CORS)         โ”‚
    โ”‚  Layer 3.5: Invariant Analysis (client-side auth)          โ”‚
    โ”‚  Layer 4:   Absence Detection (missing rate limits)        โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚  Layer 5:   Confidence Scoring + Explainable Findings      โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

    ๐Ÿš€ Quick Start

    # Install
    npm install -g cortex-ai
    
    # Run a security scan
    cortex detect scan ./src
    
    # Check dependencies for hallucinations
    cortex detect deps
    
    # Run benchmarks
    cortex benchmark run

    Example Output

    ๐Ÿ”ฌ CORTEX Intent-Aware Detection Engine v2.0
    
    ๐Ÿ“Š SECURITY SCAN SUMMARY
    โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
    ๐Ÿ”ด Critical: 2
    ๐ŸŸ  High:     3
    ๐ŸŸก Medium:   1
    ๐Ÿ”ต Low:      0
    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
    Total:      6 findings
    
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚ ๐Ÿ”ด CRITICAL: Client-Side Authentication                         โ”‚
    โ”‚                                                                  โ”‚
    โ”‚ File: src/components/Login.tsx:15                                โ”‚
    โ”‚ Confidence: 92%                                                  โ”‚
    โ”‚                                                                  โ”‚
    โ”‚ CODE:                                                            โ”‚
    โ”‚ > if (password === 'admin123') { setLoggedIn(true); }           โ”‚
    โ”‚                                                                  โ”‚
    โ”‚ WHY THIS IS DANGEROUS:                                           โ”‚
    โ”‚ โ€ข Authentication check performed in browser context              โ”‚
    โ”‚ โ€ข Client-side checks can be bypassed via DevTools                โ”‚
    โ”‚                                                                  โ”‚
    โ”‚ INVARIANT VIOLATED:                                              โ”‚
    โ”‚ "Authentication decisions must occur server-side"                โ”‚
    โ”‚                                                                  โ”‚
    โ”‚ FIX:                                                             โ”‚
    โ”‚ Move authentication to server-side with HttpOnly cookies         โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

    ๐Ÿ”ฌ Detection Engine

    Detection Classes

    Class What It Detects Examples
    exploit Active vulnerabilities SQL injection, XSS, command injection
    invariant Security intent violations Client-side auth, trust boundaries
    policy Misconfigured policies RLS using(true), CORS wildcards
    supply-chain Dependency risks CVEs, hallucinated packages
    absence Missing security controls No rate limiting, no CAPTCHA

    55+ Security Rules

    Category Count Examples
    Injection 10 SQL, NoSQL, command, path traversal
    XSS 6 innerHTML, dangerouslySetInnerHTML
    Secrets 8 API keys, tokens, hardcoded passwords
    Auth/Authz 8 Client-side auth, IDOR, missing auth
    Policy 6 RLS, Firebase, CORS, S3 buckets
    Supply Chain 6 CVEs, hallucinations, deprecated
    Abuse Control 7 Missing rate limits, no CAPTCHA
    Crypto 4 Weak hashing, insecure storage

    ๐Ÿ’ป CLI Commands

    Detection Engine

    cortex detect scan [path]       # Full security scan
    cortex detect deps              # Dependency intelligence
    cortex detect invariants <f>    # Check invariant violations
    cortex detect policies <f>      # Check policy misconfigurations
    cortex detect summary           # Show detection capabilities

    Benchmarking

    cortex benchmark run              # Run all benchmarks
    cortex benchmark run --update-baseline  # Update baseline
    cortex benchmark list             # List benchmark categories

    Feedback (Confidence Calibration)

    cortex feedback accept <id>     # Mark as true positive
    cortex feedback dismiss <id>    # Mark as false positive
    cortex feedback stats           # View precision per rule

    Scope Management

    cortex scope init               # Create scope.yaml
    cortex scope show               # Display current scope
    cortex scope check <path>       # Check if file allowed

    Other Commands

    cortex version                  # Show version
    cortex security rules           # List all security rules
    cortex patterns detect          # Auto-detect framework
    cortex learn progress           # Learning mode progress

    ๐Ÿงช Benchmarks

    CORTEX includes a benchmark harness with ground truth:

    benchmarks/
    โ”œโ”€โ”€ sql-injection/          # SQL injection samples
    โ”œโ”€โ”€ xss/                    # Cross-site scripting
    โ”œโ”€โ”€ client-auth-bypass/     # Client-side auth issues
    โ”œโ”€โ”€ rls-misconfig/          # RLS policy problems
    โ”œโ”€โ”€ firebase-public/        # Public storage buckets
    โ”œโ”€โ”€ slopsquatting/          # Hallucinated packages
    โ”œโ”€โ”€ race-condition/         # Race condition patterns
    โ”œโ”€โ”€ unprotected-endpoint/   # Missing abuse controls
    โ””โ”€โ”€ expected-findings.json  # 26 ground truth findings

    Regression Protection: If a previously passing test regresses, CI fails.


    ๐Ÿ”ง Configuration

    # .cortex/scope.yaml
    task: "Add user authentication"
    
    allow:
      - src/auth/**
      - src/components/Login.tsx
    
    block:
      - .env*
      - src/core/**
    
    limits:
      files: 10
      lines: 500

    ๐Ÿ“š Documentation


    โญ Star on GitHub โ€ข ๐Ÿ› Report Bug โ€ข ๐Ÿ’ก Request Feature