Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ web/.next
web/out
server/webui/dist
/artex
data
/data
keys
backups
.env
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project are documented in this file. The format is b

### Added

- **Pentest knowledge pack**: the planner and the workers can call a read-only `knowledge_lookup` tool to resolve a MITRE ATT&CK technique, an OWASP WSTG test or a CWE weakness by id or keyword, and cite the id in findings and facts. The pack is generated from the official sources by `scripts/knowledge/build.py`, with the source URL, license, retrieval date and source SHA-256 recorded, keeps its own licenses in `knowledge/NOTICE` and `knowledge/licenses`, and is embedded in the binary, so no network is needed at runtime. Descriptions are capped and each entry carries the canonical URL (#521).
- **Wildcard domains in asset scope**: a scope line such as `*.example.com`, the way bug bounty programs write a domain and its subdomains, is accepted in company and task asset scope and stored as the `example.com` domain rule, which already covers its subdomains. A URL form (`https://*.example.com/`) works too. The wildcard is accepted only on a registrable domain: `*.api.example.com`, `*.co.uk` and `*.<IP>` are still rejected, because no rule covers only a subdomain's subdomains (#519).
- **Stream viewer direction filter** (follow-up to #380): the Traffic detail's Stream tab can show all messages, client-to-server messages or server-to-client messages. Pagination and refresh keep the selected direction, changing the filter resets the list, and opening another exchange resets the direction to all. Recording-limit warnings remain visible but are excluded from the displayed message counts.
- **Security response headers on every response**: `X-Content-Type-Options: nosniff`, a same-origin referrer policy, `X-Frame-Options: SAMEORIGIN` and a `frame-ancestors 'self'` CSP are now set by one wrapper around the whole handler tree, so the JSON API carries them too; previously only the console route did. Console documents additionally get `Permissions-Policy` and COOP/CORP. `Strict-Transport-Security` is sent only when the request is known to be HTTPS: directly over TLS, or via `X-Forwarded-Proto: https` from a peer in `ARTEX_TRUSTED_PROXIES`, so a direct client cannot claim HTTPS on its own. The README reverse-proxy recipe now starts with an 80 to 443 redirect.
Expand Down
49 changes: 49 additions & 0 deletions agent/knowledge_tool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package agent

import (
"context"
"encoding/json"
"strings"

"github.com/Autumn-27/artex/knowledge"
actool "github.com/Autumn-27/norma/tool"
)

// knowledgeLookup is a read-only taxonomy lookup shared by the planner and the
// workers. It has no task store dependency: the pack is embedded in the binary.
func (t *ToolSet) knowledgeLookup() actool.CoreTool {
return readTool("knowledge_lookup",
"Look up a stable security taxonomy entry by id or keyword. Sources: attack (MITRE ATT&CK technique), wstg (OWASP Web Security Testing Guide test), cwe (MITRE Common Weakness Enumeration). Use it to choose a test or technique while planning, or to cite an id when reporting a finding or fact. Returns id, name, category, a capped description and the canonical url; truncated=true means the full text is at the url. Read-only.",
obj(map[string]any{
"source": str("taxonomy to search: attack, wstg or cwe"),
"query": str("entry id (for example T1190, WSTG-ATHN-01, CWE-79) or keywords"),
"limit": intp("maximum matches, default 5, max 20"),
}, "source", "query"),
knowledgeLookupRun)
}

func knowledgeLookupRun(_ context.Context, in json.RawMessage) (actool.Result, error) {
var a struct {
Source string `json:"source"`
Query string `json:"query"`
Limit int `json:"limit"`
}
if err := json.Unmarshal(in, &a); err != nil {
return actool.Errorf("invalid input: " + err.Error()), nil
}
pack, err := knowledge.Default()
if err != nil {
return actool.Errorf(err.Error()), nil
}
source := strings.ToLower(strings.TrimSpace(a.Source))
matches, total, err := pack.Search(source, a.Query, a.Limit)
if err != nil {
return actool.Errorf(err.Error()), nil
}
return jsonResult(map[string]any{
"source": source,
"query": strings.TrimSpace(a.Query),
"matches": matches,
"total": total,
})
}
90 changes: 90 additions & 0 deletions agent/knowledge_tool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package agent

import (
"encoding/json"
"strings"
"testing"
)

func TestKnowledgeLookupRunExactID(t *testing.T) {
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(`{"source":"attack","query":"T1190"}`))
if err != nil {
t.Fatalf("run: %v", err)
}
if res.IsError {
t.Fatalf("unexpected tool error: %s", res.Flatten())
}
out := res.Flatten()
for _, want := range []string{`"T1190"`, "Exploit Public-Facing Application", "attack.mitre.org"} {
if !strings.Contains(out, want) {
t.Errorf("output missing %q: %s", want, out)
}
}
}

func TestKnowledgeLookupRunKeyword(t *testing.T) {
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(`{"source":"wstg","query":"default credentials","limit":3}`))
if err != nil {
t.Fatalf("run: %v", err)
}
if res.IsError {
t.Fatalf("unexpected tool error: %s", res.Flatten())
}
if !strings.Contains(res.Flatten(), "WSTG-ATHN-01") {
t.Errorf("output does not contain WSTG-ATHN-01: %s", res.Flatten())
}
}

func TestKnowledgeLookupRunLimitIsClamped(t *testing.T) {
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(`{"source":"cwe","query":"data","limit":100}`))
if err != nil {
t.Fatalf("run: %v", err)
}
if res.IsError {
t.Fatalf("unexpected tool error: %s", res.Flatten())
}
var out struct {
Matches []map[string]any `json:"matches"`
Total int `json:"total"`
}
if err := json.Unmarshal([]byte(res.Flatten()), &out); err != nil {
t.Fatalf("decode: %v", err)
}
if len(out.Matches) > 20 {
t.Fatalf("matches = %d, want at most 20", len(out.Matches))
}
if out.Total <= len(out.Matches) {
t.Fatalf("total = %d, matches = %d", out.Total, len(out.Matches))
}
}

func TestKnowledgeLookupRunErrors(t *testing.T) {
cases := []struct {
name, in, want string
}{
{"unknown source", `{"source":"nope","query":"x"}`, "unknown knowledge source"},
{"empty query", `{"source":"attack","query":" "}`, "query is required"},
{"invalid json", `{`, "invalid input"},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
res, err := knowledgeLookupRun(t.Context(), json.RawMessage(c.in))
if err != nil {
t.Fatalf("run: %v", err)
}
if !res.IsError || !strings.Contains(res.Flatten(), c.want) {
t.Fatalf("result = %q (isError=%v), want error containing %q", res.Flatten(), res.IsError, c.want)
}
})
}
}

func TestKnowledgeLookupToolIsReadOnly(t *testing.T) {
tool := (&ToolSet{}).knowledgeLookup()
if tool.Name() != "knowledge_lookup" {
t.Fatalf("name = %q", tool.Name())
}
if !tool.IsReadOnly(nil) {
t.Fatal("tool is not read-only")
}
}
2 changes: 1 addition & 1 deletion agent/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,7 @@ func (t *ToolSet) listWorkerTraces() actool.CoreTool {
// PlannerTools is the read + intent-generation + goal-judgement tool set.
func (t *ToolSet) PlannerTools() []actool.CoreTool {
return []actool.CoreTool{
t.graphOverview(), t.listFindings(), t.listFacts(), t.nodeDetail(),
t.graphOverview(), t.listFindings(), t.listFacts(), t.nodeDetail(), t.knowledgeLookup(),
// cold-digest §6.1: restore folded cold nodes (digest body → members → detail).
t.expandDigest(),
t.getWorkerOutput(), t.getWorkerTrace(), t.searchAllWorkerTraces(), t.listGoals(), t.addIntent(), t.proveGoal(), t.goalMet(),
Expand Down
3 changes: 3 additions & 0 deletions agent/tools_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ func (t *ToolSet) WorkerTools() []actool.CoreTool {
// node_detail: once a worker has an intent_id/node id, it can look up that node's
// full detail (pairs with the review above).
t.nodeDetail(),
// knowledge_lookup: cite a stable ATT&CK/WSTG/CWE id when reporting a
// finding or a fact, or look up a test while executing an intent.
t.knowledgeLookup(),
// The following tools are still [not given] to workers, reserved for
// planner/main (reading context, cross-work retrospection are planning duties; a
// worker only executes and writes back its single intent):
Expand Down
2 changes: 2 additions & 0 deletions intercept/target_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var noTargetTools = toolSet(
"insert_assets", "add_company_scope", "add_task_scope", "list_assets",
"list_untested_assets", "list_companies", "report_finding", "record_fact",
"save_task_credential", "list_task_credentials", "ingest_bbot", "ingest_scan_output", "record_coverage",
// taxonomy lookup: the input is an id or a keyword, never a connection
"knowledge_lookup",
// cross-task orchestration, findings and retests (server)
"list_tasks", "list_llm_profiles", "spawn_task", "pause_task", "get_task_graph",
"list_task_findings", "add_task_hint", "get_task_worker_trace",
Expand Down
27 changes: 27 additions & 0 deletions knowledge/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Knowledge pack attribution

The files under knowledge/data/ are generated from the sources below and are
distributed under their own terms. They are not covered by the repository's
AGPL-3.0 license.

MITRE ATT&CK
Copyright © 2026 The MITRE Corporation. This work is reproduced and
distributed with the permission of The MITRE Corporation.
License: knowledge/licenses/ATTACK-LICENSE.txt
Source: https://github.com/mitre-attack/attack-stix-data

OWASP Web Security Testing Guide
Copyright © OWASP Foundation. Licensed under CC-BY-SA-4.0.
Changes: descriptions are shortened for tool output; ids, names and
references are unchanged.
License: knowledge/licenses/WSTG-LICENSE.txt
Source: https://github.com/OWASP/wstg

MITRE CWE
Copyright © 2006-2026 The MITRE Corporation. This work is reproduced and
distributed with the permission of The MITRE Corporation.
Terms: knowledge/licenses/CWE-TERMS.txt
Source: https://cwe.mitre.org/data/csv/1000.csv

The canonical text and the full license terms are at the URL in each entry and
in knowledge/licenses/.
63 changes: 63 additions & 0 deletions knowledge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Knowledge pack

Small, versioned security taxonomy pack embedded in the ARTEX binary. It gives
the planner and the workers stable identifiers to plan against and to cite in
findings and facts:

- **attack**: MITRE ATT&CK Enterprise techniques (706 entries).
- **wstg**: OWASP Web Security Testing Guide tests (133 entries).
- **cwe**: MITRE Common Weakness Enumeration weaknesses (956 entries).

Each entry carries an id, a name, a category (tactics, WSTG category or CWE
abstraction), a short description capped by the build script, a `truncated` flag
when the description was cut, and the canonical URL.

## Sources and licenses

The data files are generated from the official sources and keep their own
licenses. They are not covered by the repository's AGPL-3.0 license.

| source | license | source |
|---|---|---|
| attack | MITRE ATT&CK Terms of Use | https://github.com/mitre-attack/attack-stix-data |
| wstg | CC-BY-SA-4.0 | https://github.com/OWASP/wstg |
| cwe | MITRE CWE Terms of Use | https://cwe.mitre.org/data/csv/1000.csv |

See [NOTICE](NOTICE) and [licenses/](licenses/) for the attribution and the
license texts. The WSTG descriptions are shortened; IDs, names and references
are unchanged.

## Files

- `data/attack.json`, `data/wstg.json`, `data/cwe.json`: the embedded entries.
- `data/sources.json`: source URL, license, retrieval date, source SHA-256 and
entry count for each file.
- `licenses/`: the license texts.
- `../scripts/knowledge/build.py`: the generator.

## Rebuilding

```sh
python3 scripts/knowledge/build.py
```

The script downloads the official sources, rewrites the three JSON files and
`sources.json`, and refreshes the license files. The generated data is committed
so the binary needs no network at runtime. Review the diff before committing:
the result is a new pack version.

## How it is used

The read-only `knowledge_lookup` tool is available to the planner and the
workers. It accepts a `source`, a `query` (an id such as `T1190`,
`WSTG-ATHN-01`, `CWE-79`, or keywords) and an optional `limit` (default 5, max
20), and returns the matching entries. It reads the embedded pack, never the
network.

## What it is not

- Not a training corpus, not a fine-tuning dataset, not a RAG dump.
- No exploit code, no scraped lab writeups, no vendor-specific material.
- Not the place for dynamic feeds (CISA KEV, NVD, OSV). Those change daily and
belong to a fetch-at-runtime layer, not to a committed pack.
- Descriptions are capped for tool output; open the entry URL for the full text.
Loading
Loading