Skip to content

One-pass CWE ingestion → generate per-domain CWE taxonomies for PromptKit security audits #228

Closed

Description

Title

One-pass CWE ingestion → generate per-domain CWE taxonomies for PromptKit security audits

Problem / Motivation

PromptKit security audits risk being domain-incorrect unless we constrain what “classes of bugs” the model looks for. Example: it’s wasted effort to check for XSS during a kernel audit, or to check IRQL-level hazards when auditing JavaScript. We want audits to be domain-scoped, not generic, to reduce noise and increase yield.

PromptKit already describes a Layer 4 — Taxonomy in the composition stack intended for “domain classification.”
Also, we have evidence that structured PromptKit-driven security audits can produce materially better results when the LLM is guided with tighter methodology and structure. [PromptKit-Intro | PowerPoint], [promptkit-...our - Copy | PowerPoint] [MSRC style...PromptKit | Outlook], [IO Fabrics...Recording | Video], [eBPF & Cil...Transcript | Video]

Goal

Implement a pipeline that:

  1. Ingests the official CWE corpus (versioned) from MITRE. [cwe.mitre.org], [cwe.mitre.org]
  2. In a single run, generates per-domain CWE taxonomies (domain → relevant CWE subset + metadata) suitable for PromptKit templates/protocols.
  3. Updates PromptKit security audit prompts to:
    • Select the correct taxonomy by domain
    • Provide the LLM only the applicable CWE subset
    • Drive evidence-backed pattern matching (include CWE ID + evidence + confidence)

Non-Goals

  • Replace SAST tooling or build a full static analyzer.
  • Claim exploitability/proof automatically.
  • Fork/maintain a separate “proprietary CWE”; we should track upstream versions.

External References (authoritative sources)

Proposed Design (single pass → many outputs)

A) CWE ingestion (versioned, reproducible)

Add an ingestion tool/workflow that:

  • Accepts CWE XML/CSV (downloaded from MITRE or provided locally) and records:
    • CWE release/version (from filename or metadata)
    • Hash of the source artifact(s)
  • Parses into a normalized internal representation:
    • cwe_id, name, abstraction, status
    • description / short summary fields as available
    • platform/language/technology applicability fields when present (from CWE schema)
    • relationships graph: parents/children, related weaknesses
  • Emits artifacts under a versioned directory, e.g.:
    • data/cwe/<version>/cwe.json
    • data/cwe/<version>/edges.json
    • data/cwe/<version>/meta.json (version + hashes + generation info)

(Exact artifact shape is an implementation decision; the key requirement is version pinning and deterministic regeneration.)

B) Domain model (defined once, emitted for all domains)

Define a PromptKit “audit domain” list (the taxonomy keys). The goal is “all of them,” but it still must be a finite registry. The pipeline will generate outputs for every registered domain each run.

Example domain registry (strawman; edit as needed):

  • kernel-mode-c-cpp
  • native-user-mode-c-cpp
  • managed-dotnet
  • web-js-ts
  • web-backend
  • cloud-service
  • iac
  • firmware-embedded
  • crypto-protocols
  • data-processing
  • cli-tools
  • mobile-app
  • container-k8s

C) One-pass taxonomy generation algorithm

In the same run as ingestion, generate:

  • taxonomies/cwe-domains/<version>/domains.json
    • domain definitions (name, description, selection rules)
  • taxonomies/cwe-domains/<version>/domain_to_cwe.json
    • for each domain: list of CWEs + minimal metadata (id, short name, optional detection hints)
  • taxonomies/cwe-domains/<version>/diff/ (optional)
    • machine-readable diffs between versions to review mapping churn

Selection rules should be (in priority order):

  1. Use CWE-provided structuring where available (e.g., “helpful views” or language-specific views are explicitly listed as downloadable options). [cwe.mitre.org]
  2. Use schema-exposed applicability data (Applicable_Platforms, language/technology hints) when present. [cwe.mitre.org], [cwe.mitre.org]
  3. Allow PromptKit-maintained override/curation (“domain overrides”) to patch gaps or handle ambiguous areas.

D) PromptKit integration: taxonomy layer becomes real

Update security audit templates/protocols so YAML frontmatter can specify:

  • domain: kernel-mode-c-cpp (required, default none)

At composition time, PromptKit loads:

  • CWE dataset version pinned by the PromptKit release (or by a config)
  • The generated mapping for the requested domain

And injects into the audit prompt:

  • “Only consider CWE IDs in this domain subset.”
  • “If you find something plausible outside the subset, record it as out-of-scope candidate (don’t expand scope).”

This fits PromptKit’s stated “taxonomy layer” concept in its composition stack.
It also aligns with ongoing work to reduce ambiguity and make behavior more deterministic in PromptKit components (including discussions touching CWE assignment behavior). [PromptKit-Intro | PowerPoint], [promptkit-...our - Copy | PowerPoint] [Re: [micro...components | Outlook]

Acceptance Criteria

1) One-pass completeness

  • A single command/run produces taxonomy outputs for every registered domain (not a “pick one domain” workflow).
  • Outputs are versioned and reproducible from the same input CWE bundle.

2) Domain relevance sanity checks

  • Kernel domain mappings do not include web-only classes by default (e.g., XSS-style items).
  • Web JS/TS mappings do not include kernel-only defect classes by default (e.g., IRQL-level hazards).

(Implementation should include explicit regression tests on a few known “should-not-appear” examples.)

3) Prompt behavior

  • Security audit prompts can be parameterized with domain, and they incorporate only that domain’s CWE subset.
  • Output format includes CWE ID + evidence pointer + confidence (template decision), consistent with the structured security audit direction already being used in practice. [MSRC style...PromptKit | Outlook], [eBPF & Cil...Transcript | Video]

4) Maintenance

  • Updating to a new CWE release is: run ingestion → regenerate all domains → review diff.

Implementation Tasks

  • Add CWE ingestion tool / workflow (XML+CSV input, normalized output). [cwe.mitre.org], [cwe.mitre.org]
  • Create domain registry (authoritative list of domains PromptKit supports).
  • Implement mapping rules using CWE downloadable structuring + schema applicability + overrides. [cwe.mitre.org], [cwe.mitre.org], [cwe.mitre.org]
  • Emit per-domain taxonomy artifacts for all domains in one run.
  • Integrate taxonomy selection into PromptKit composition (Layer 4). [PromptKit-Intro | PowerPoint], [promptkit-...our - Copy | PowerPoint]
  • Update security audit template(s) to require domain and to scope findings accordingly.
  • Add unit/regression tests:
    • domain mapping sanity checks (negative sets)
    • determinism: same input → same mapping output
  • Documentation: how to choose domain, how to override/extend mappings.

Nice-to-have (but not required for v1)

  • Diff report that highlights:
    • CWEs added/removed per domain between CWE releases
    • Overrides that are now redundant because upstream improved applicability tagging

Activity

  1. Alan-Jowett commented on Apr 8, 2026

    @Alan-Jowett
    ContributorAuthor

    Design Notes: Why this is a single‑pass ingestion pipeline (not on‑demand filtering)

    This feature should be implemented as:

    One ingestion pass over the upstream CWE corpus that emits all per‑domain taxonomies as versioned PromptKit artifacts

    —not as runtime filtering or per‑audit selection logic.

    Rationale

    1. PromptKit already separates classification from reasoning

    PromptKit’s architecture explicitly composes prompts from:

    persona → protocols → formats → taxonomies → templates
    

    Where the taxonomy layer exists to classify findings and attach contextual metadata that informs downstream reasoning and output structure. [github.com], [PromptKit_Intro | PowerPoint]

    Taxonomy is therefore:

    • Input to reasoning
    • Not something derived dynamically during reasoning

    So domain selection (e.g., kernel vs web) belongs at:

    • taxonomy assembly time
    • not LLM audit time

    If we instead defer CWE selection to the prompt runtime:

    • the model must infer domain relevance heuristically
    • audit scope becomes nondeterministic
    • and audit coverage becomes prompt‑dependent rather than taxonomy‑dependent

    That is directly at odds with PromptKit’s goal of treating prompts as engineered, version‑controlled artifacts rather than ad‑hoc runtime behavior. [github.com]


    2. CWE already ships domain‑relevant structural “views”

    The CWE dataset is not a flat list — MITRE publishes:

    • language‑specific views (e.g., Software Written in C)
    • implementation phase views
    • platform‑oriented slices
    • assurance trend categorizations

    Example:

    CWE VIEW SLICE: Weaknesses in Software Written in C (View‑658)
    Filter: Applicable_Platforms/Language='C' [cwe.mitre.org]

    And the CWE catalog explicitly includes:

    • Software Written in C
    • Software Written in C++
    • Software Written in Java
    • Weaknesses in Mobile Applications
    • Introduced During Implementation
    • etc. [cwe.mitre.org]

    These are already:

    ✅ machine‑derivable domain subsets
    ✅ maintained upstream
    ✅ versioned by CWE release

    Which makes them ideal raw inputs for a build‑time taxonomy generator.


    3. PromptKit treats prompts as compiled artifacts

    PromptKit does not store full prompts.
    Instead, it stores:

    • reusable components (persona / protocol / taxonomy / template)
    • and assembles prompts dynamically based on task metadata

    As described internally:

    Prompts are assembled from reusable components … indexed in a manifest and composed on demand via a bootstrap meta‑prompt. [RE: Prompt...el aspects | Outlook]

    The assembled prompt is effectively:

    a compiled artifact rather than a static snippet [RE: Prompt...el aspects | Outlook]

    Domain‑scoped CWE taxonomies should therefore be:

    • generated once (from upstream CWE)
    • committed as versioned PromptKit components
    • consumed by templates as compile‑time inputs

    This keeps:

    • audit scope deterministic
    • component composition reproducible
    • and audit behavior diffable across releases

    4. Runtime filtering breaks determinism guarantees

    If CWE subsets are selected at runtime:

    Property Build‑time taxonomy Runtime filtering
    Deterministic audit scope ✅ ❌
    Diffable between CWE releases ✅ ❌
    Manifest‑traceable ✅ ❌
    CI‑testable ✅ ❌
    Prompt reproducibility ✅ ❌

    PromptKit’s manifest is intended to be the:

    source of truth for component discovery and assembly [github.com]

    So CWE domain mappings must live there (or in derived artifacts),
    not be recomputed by the model mid‑audit.


    Resulting Build Model

    Each ingestion run should:

    Upstream CWE XML/CSV
            ↓
    Normalize + version
            ↓
    Apply:
      - CWE views
      - schema applicability fields
      - PromptKit overrides
            ↓
    Emit:
      taxonomies/cwe-domains/<version>/
          kernel-mode-c-cpp.json
          web-js-ts.json
          firmware-embedded.json
          cloud-service.json
          ...
    

    Security audit templates then simply declare:

    taxonomy:
      - cwe-domains/kernel-mode-c-cpp

    No filtering.
    No inference.
    No runtime heuristics.

    The taxonomy layer becomes:

    the contract between CWE ingestion and PromptKit reasoning protocols.


    TL;DR

    We are not teaching the LLM:

    “which CWEs matter for this domain”

    We are compiling:

    domain‑specific vulnerability ontologies from CWE upstream

    and giving the LLM:

    a scoped search space for evidence‑backed pattern matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions