@aegis-scan/skills 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/ATTRIBUTION.md +71 -20
  2. package/CHANGELOG.md +55 -0
  3. package/README.md +66 -18
  4. package/dist/bin.js +1 -1
  5. package/dist/commands/install.d.ts.map +1 -1
  6. package/dist/commands/install.js +17 -1
  7. package/dist/commands/install.js.map +1 -1
  8. package/dist/commands/list.d.ts.map +1 -1
  9. package/dist/commands/list.js +9 -2
  10. package/dist/commands/list.js.map +1 -1
  11. package/package.json +3 -2
  12. package/sbom.cdx.json +1 -0
  13. package/skills/compliance/aegis-native/brutaler-anwalt/SKILL.md +305 -0
  14. package/skills/compliance/aegis-native/brutaler-anwalt/references/abmahn-templates.md +306 -0
  15. package/skills/compliance/aegis-native/brutaler-anwalt/references/aegis-integration.md +241 -0
  16. package/skills/compliance/aegis-native/brutaler-anwalt/references/audit-patterns.md +277 -0
  17. package/skills/compliance/aegis-native/brutaler-anwalt/references/bgh-urteile.md +167 -0
  18. package/skills/compliance/aegis-native/brutaler-anwalt/references/branchenrecht.md +285 -0
  19. package/skills/compliance/aegis-native/brutaler-anwalt/references/checklisten.md +276 -0
  20. package/skills/compliance/aegis-native/brutaler-anwalt/references/dsgvo.md +238 -0
  21. package/skills/compliance/aegis-native/brutaler-anwalt/references/international.md +163 -0
  22. package/skills/compliance/aegis-native/brutaler-anwalt/references/it-recht.md +267 -0
  23. package/skills/compliance/aegis-native/brutaler-anwalt/references/strafrecht-steuer.md +193 -0
  24. package/skills/compliance/aegis-native/brutaler-anwalt/references/vertragsrecht.md +243 -0
  25. package/skills/defensive/README.md +33 -4
  26. package/skills/defensive/aegis-native/rls-defense/SKILL.md +174 -0
  27. package/skills/defensive/aegis-native/ssrf-defense/SKILL.md +179 -0
  28. package/skills/defensive/aegis-native/tenant-isolation-defense/SKILL.md +225 -0
  29. package/skills/mitre-mapped/README.md +36 -8
  30. package/skills/mitre-mapped/aegis-native/mapping-overview/SKILL.md +129 -0
  31. package/skills/mitre-mapped/aegis-native/t1078-valid-accounts/SKILL.md +136 -0
  32. package/skills/mitre-mapped/aegis-native/t1190-exploit-public-app/SKILL.md +108 -0
  33. package/skills/ops/README.md +39 -4
  34. package/skills/ops/aegis-native/escalation-runbook/SKILL.md +147 -0
  35. package/skills/ops/aegis-native/suppress-correctly/SKILL.md +196 -0
  36. package/skills/ops/aegis-native/triage-finding/SKILL.md +144 -0
@@ -0,0 +1,225 @@
1
+ <!-- aegis-local: AEGIS-native skill, MIT-licensed; mirrors @aegis-wizard/cli multi-tenant pattern + addresses AEGIS scanner finding: tenant-isolation-checker (CWE-639). -->
2
+
3
+ ---
4
+ name: defensive-tenant-isolation
5
+ description: "Multi-tenant SaaS isolation methodology. Covers tenant_id flow design, secureApiRouteWithTenant primitive usage, JWT-based tenant injection patterns, defense against IDOR + tenant-bypass, AEGIS tenant-isolation-checker remediation, public-route exception handling, and regression-test discipline. Use when designing multi-tenant Supabase or PostgreSQL applications, fixing tenant-isolation-checker findings, or auditing for cross-tenant data leakage."
6
+ ---
7
+
8
+ # Tenant Isolation Defense — Multi-Tenant SaaS Methodology
9
+
10
+ ## When to use this skill
11
+
12
+ - Designing a new multi-tenant SaaS — get the isolation invariant right from commit 0.
13
+ - Reviewing an existing multi-tenant codebase for cross-tenant exposure.
14
+ - Fixing AEGIS `tenant-isolation-checker` (CWE-639) findings.
15
+ - Auditing IDOR-class findings (CWE-639 Insecure Direct Object Reference).
16
+ - Hardening before a SOC 2 audit.
17
+
18
+ ## The core invariant
19
+
20
+ **Every database query touching tenant-scoped data MUST filter by `tenant_id`, AND the `tenant_id` MUST come from the authenticated session — never from request input.**
21
+
22
+ Two failure modes:
23
+
24
+ 1. **Missing filter** — query returns rows from all tenants. Catastrophic.
25
+ 2. **Filter sourced from request input** — attacker sends `?tenant_id=victim-tenant-uuid` and reads anyone's data. Equally catastrophic.
26
+
27
+ ## The secure pattern
28
+
29
+ ### Server-side primitive
30
+
31
+ ```typescript
32
+ // lib/security/secureApiRouteWithTenant.ts (AEGIS scaffold ships this)
33
+
34
+ import { createClient } from '@supabase/supabase-js';
35
+
36
+ export async function secureApiRouteWithTenant<T>(
37
+ req: Request,
38
+ handler: (ctx: { supabase: SupabaseClient; userId: string; tenantId: string }) => Promise<T>
39
+ ): Promise<Response> {
40
+ const supabase = createClient(
41
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
42
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
43
+ { global: { headers: { Authorization: req.headers.get('Authorization') ?? '' } } }
44
+ );
45
+
46
+ const { data: { user }, error } = await supabase.auth.getUser();
47
+ if (error || !user) return new Response('Unauthorized', { status: 401 });
48
+
49
+ const { data: profile } = await supabase
50
+ .from('profiles')
51
+ .select('tenant_id')
52
+ .eq('id', user.id)
53
+ .single();
54
+
55
+ if (!profile?.tenant_id) {
56
+ return new Response('Forbidden', { status: 403 });
57
+ }
58
+
59
+ // tenant_id is always derived from the session, never from the request body
60
+ return handler({
61
+ supabase,
62
+ userId: user.id,
63
+ tenantId: profile.tenant_id,
64
+ });
65
+ }
66
+ ```
67
+
68
+ ### Usage in API routes
69
+
70
+ ```typescript
71
+ // app/api/invoices/route.ts
72
+
73
+ export async function GET(req: Request) {
74
+ return secureApiRouteWithTenant(req, async ({ supabase, tenantId }) => {
75
+ const { data, error } = await supabase
76
+ .from('invoices')
77
+ .select('*')
78
+ .eq('tenant_id', tenantId); // tenant_id from session, NOT from query params
79
+
80
+ if (error) return Response.json({ error }, { status: 500 });
81
+ return Response.json(data);
82
+ });
83
+ }
84
+ ```
85
+
86
+ ## Anti-patterns the scanner flags
87
+
88
+ ### Anti-pattern 1 — Missing `tenant_id` filter
89
+
90
+ ```typescript
91
+ // FLAGGED by tenant-isolation-checker (CWE-639)
92
+ const { data } = await supabase
93
+ .from('invoices')
94
+ .select('*'); // returns ALL tenants' invoices — cross-tenant leak
95
+
96
+ // FIX
97
+ const { data } = await supabase
98
+ .from('invoices')
99
+ .select('*')
100
+ .eq('tenant_id', sessionTenantId);
101
+ ```
102
+
103
+ ### Anti-pattern 2 — `tenant_id` from request input
104
+
105
+ ```typescript
106
+ // FLAGGED by tenant-isolation-checker (CWE-639)
107
+ const { searchParams } = new URL(req.url);
108
+ const tenantId = searchParams.get('tenant_id');
109
+ const { data } = await supabase
110
+ .from('invoices')
111
+ .select('*')
112
+ .eq('tenant_id', tenantId); // attacker sets ?tenant_id=victim — IDOR
113
+
114
+ // FIX — always source tenant_id from session
115
+ const { tenantId } = await getAuthenticatedSession(req);
116
+ ```
117
+
118
+ ### Anti-pattern 3 — `tenant_id` in mutation body
119
+
120
+ ```typescript
121
+ // FLAGGED — mass-assignment + tenant-isolation
122
+ const body = await req.json();
123
+ await supabase.from('invoices').insert(body); // body can carry attacker's tenant_id
124
+
125
+ // FIX — strip tenant_id from input, inject from session
126
+ const body = MutationSchema.parse(await req.json());
127
+ await supabase.from('invoices').insert({
128
+ ...body,
129
+ tenant_id: sessionTenantId, // session-sourced, overrides any body field
130
+ });
131
+ ```
132
+
133
+ ## Public-route exceptions (rare, document each)
134
+
135
+ A small set of routes legitimately operate without a tenant scope:
136
+
137
+ - Auth/login endpoints (no tenant context exists yet at this point)
138
+ - Public marketing pages (no DB read at all, ideally)
139
+ - Health-check endpoints (no DB read)
140
+ - Webhook receivers from trusted vendors (verified by signature, then dispatched into tenant-scoped logic)
141
+
142
+ Document each exception explicitly:
143
+
144
+ ```typescript
145
+ // app/api/auth/login/route.ts
146
+ // AEGIS-EXCEPTION: tenant-isolation N/A — login endpoint runs before tenant context exists.
147
+ // Verified safe via signed-cookie + supabase-auth-helpers; no direct DB writes here.
148
+ export async function POST(req: Request) {
149
+ /* ... */
150
+ }
151
+ ```
152
+
153
+ The `aegis scan` config supports per-finding suppression with rationale; see `docs/suppressions.md`.
154
+
155
+ ## Multi-axis tenant scoping
156
+
157
+ Some apps need MORE than `tenant_id` — for example, organizations within tenants, or divisions within organizations:
158
+
159
+ ```sql
160
+ CREATE TABLE invoices (
161
+ id uuid PRIMARY KEY,
162
+ tenant_id uuid NOT NULL, -- Customer org
163
+ organization_id uuid, -- Sub-unit within the customer
164
+ user_id uuid NOT NULL, -- Creator
165
+ -- ...
166
+ );
167
+
168
+ -- RLS policy enforces all three when applicable
169
+ CREATE POLICY "tenant + org + user scoping"
170
+ ON public.invoices FOR SELECT
171
+ USING (
172
+ tenant_id IN (SELECT tenant_id FROM profiles WHERE id = auth.uid())
173
+ AND (organization_id IS NULL OR organization_id IN (
174
+ SELECT organization_id FROM organization_members WHERE user_id = auth.uid()
175
+ ))
176
+ );
177
+ ```
178
+
179
+ ## Regression-test pattern
180
+
181
+ ```typescript
182
+ // __tests__/tenant-isolation.test.ts
183
+ describe('Tenant Isolation', () => {
184
+ it('user from tenant A cannot read tenant B documents', async () => {
185
+ await seedTenant('A', { documents: [{ id: 'a1' }] });
186
+ await seedTenant('B', { documents: [{ id: 'b1' }] });
187
+
188
+ const sessionA = await createSession('A');
189
+ const res = await fetch('/api/documents', {
190
+ headers: { Authorization: `Bearer ${sessionA.token}` },
191
+ });
192
+ const docs = await res.json();
193
+ expect(docs).toHaveLength(1);
194
+ expect(docs[0].id).toBe('a1'); // not b1
195
+ });
196
+
197
+ it('tenant_id in request body is ignored', async () => {
198
+ await seedTenant('A', {});
199
+ await seedTenant('B', { documents: [{ id: 'b1' }] });
200
+
201
+ const sessionA = await createSession('A');
202
+ const res = await fetch('/api/documents', {
203
+ method: 'POST',
204
+ headers: { Authorization: `Bearer ${sessionA.token}` },
205
+ body: JSON.stringify({ tenant_id: 'B', name: 'attack' }), // attacker tries to set tenant
206
+ });
207
+ const created = await res.json();
208
+ expect(created.tenant_id).toBe('A'); // session-sourced wins
209
+ });
210
+ });
211
+ ```
212
+
213
+ Run this on every CI run. Tenant-isolation regressions silently leak data; you need a test that fails LOUDLY when the invariant breaks.
214
+
215
+ ## How AEGIS helps
216
+
217
+ - `tenant-isolation-checker` (CWE-639) — flags Supabase queries missing `tenant_id` and queries where `tenant_id` is sourced from request input.
218
+ - `mass-assignment-checker` (CWE-915) — flags unvalidated body → `.insert()`.
219
+ - `aegis-wizard/cli` scaffold — ships `secureApiRouteWithTenant`, the `tenants` + `profiles` schema with the auto-profile-on-signup trigger, and an exemplary API route demonstrating the composition pattern.
220
+
221
+ ## See also
222
+
223
+ - `defensive-rls-defense` skill — the RLS counterpart that complements API-route-level isolation.
224
+ - AEGIS patterns library — `docs/patterns/index.md` § "Multi-tenant Supabase pattern".
225
+ - AEGIS-finding suppression docs — `docs/suppressions.md`.
@@ -1,10 +1,38 @@
1
- # MITRE-Mapped Skills
1
+ # MITRE-Mapped Skills — `mitre-mapped/`
2
2
 
3
- Reserved for cherry-picked skills from an upstream cybersecurity
4
- framework-mapped skills source, with MITRE ATT&CK / D3FEND / NIST
5
- CSF mappings applied. Target: `skills-v0.2`.
3
+ Skills that cross-walk AEGIS scanner findings to MITRE ATT&CK Enterprise,
4
+ ATLAS (AI/ML threats), D3FEND (defensive countermeasures), NIST CSF 2.0,
5
+ and NIST AI RMF. Use these to translate AEGIS reports into the MITRE
6
+ language your SIEM / EDR / IR tooling already speaks.
6
7
 
7
- Per-skill quality-audit is required before integration. The upstream-
8
- source details and integration-matrix are tracked in the repository's
9
- internal planning tree; ask the maintainer for access if you are
10
- contributing to the framework-mapped-skills effort.
8
+ ## Sources
9
+
10
+ | Source dir | License | Skills |
11
+ |---|---|---|
12
+ | `aegis-native/` | MIT (AEGIS-original) | 3 |
13
+
14
+ ## AEGIS-native skills
15
+
16
+ | Skill | Coverage |
17
+ |---|---|
18
+ | `mapping-overview` | Top-level cross-walk: per-CWE → ATT&CK technique, plus tactic-level coverage summary. ATLAS overlay for AI/LLM threats. D3FEND defensive-countermeasure mapping. NIST CSF 2.0 + NIST AI RMF function-level alignment. |
19
+ | `t1190-exploit-public-app` | Deep-dive on T1190 (Exploit Public-Facing Application) coverage — SQLi, XSS, SSRF, RCE, command-injection, file-upload, auth-bypass. |
20
+ | `t1078-valid-accounts` | Deep-dive on T1078 (Valid Accounts) coverage — credential leakage detection, JWT-format detection, cloud-credential protection, T1078.001-004 sub-technique map. |
21
+
22
+ License: MIT. See top-level [`ATTRIBUTION.md`](../../ATTRIBUTION.md) for
23
+ attribution chain.
24
+
25
+ ## Roadmap
26
+
27
+ Future expansions:
28
+
29
+ - Per-tactic deep-dive skills for high-coverage tactics (Credential Access TA0006, Exfiltration TA0010, Privilege Escalation TA0004).
30
+ - ATLAS-specific deep-dive on AML.T0051 (Direct + Indirect Prompt Injection).
31
+ - D3FEND countermeasure-recommendation skill that turns AEGIS findings into specific D3FEND-technique recommendations.
32
+
33
+ ## See also
34
+
35
+ - AEGIS scanner inventory in the top-level `README.md` — authoritative per-scanner CWE list.
36
+ - MITRE ATT&CK — https://attack.mitre.org/
37
+ - MITRE ATLAS — https://atlas.mitre.org/
38
+ - MITRE D3FEND — https://d3fend.mitre.org/
@@ -0,0 +1,129 @@
1
+ <!-- aegis-local: AEGIS-native skill, MIT-licensed; cross-walks AEGIS scanner findings to MITRE ATT&CK Enterprise v15 (latest stable as of 2026-04-27). -->
2
+
3
+ ---
4
+ name: mitre-mapping-overview
5
+ description: "Top-level cross-walk between AEGIS scanner findings and MITRE ATT&CK Enterprise v15 techniques. Provides the per-finding-CWE → ATT&CK-technique mapping with rationale, plus per-tactic coverage summary. Use when integrating AEGIS findings into a MITRE-aligned threat-model, mapping AEGIS reports to D3FEND defensive countermeasures, building executive risk reports framed in MITRE language, or aligning AEGIS coverage with NIST CSF 2.0 / NIST AI RMF tagged controls."
6
+ ---
7
+
8
+ # MITRE ATT&CK Mapping — AEGIS Scanner Findings
9
+
10
+ ## Why this matters
11
+
12
+ Many security teams operate in MITRE-language. AEGIS findings are CWE-tagged; this skill translates them into ATT&CK techniques so AEGIS reports can be consumed alongside SIEM / EDR / IR-tool reports without manual re-mapping.
13
+
14
+ **Mapping target:** MITRE ATT&CK Enterprise v15 (https://attack.mitre.org/).
15
+ **Companion frameworks:** MITRE D3FEND v1.0 (defensive countermeasures), NIST CSF 2.0, NIST AI RMF.
16
+
17
+ ## Coverage summary by tactic
18
+
19
+ ATT&CK has 14 tactics (TA0001..TA0040). AEGIS findings concentrate on a subset:
20
+
21
+ | Tactic | ATT&CK ID | AEGIS coverage strength |
22
+ |---|---|---|
23
+ | Initial Access | TA0001 | High — SQLi/XSS/SSRF/RCE/auth-bypass |
24
+ | Execution | TA0002 | Medium — eval injection, prompt injection, command injection |
25
+ | Persistence | TA0003 | Low — most persistence is post-RCE; AEGIS's mass-assignment + auth findings prevent the entry point |
26
+ | Privilege Escalation | TA0004 | Medium — RLS bypass, JWT misuse, role-escalation patterns |
27
+ | Defense Evasion | TA0005 | Low — out of scope for static analysis |
28
+ | Credential Access | TA0006 | High — entropy-scanner, jwt-detector, next-public-leak, crypto-auditor |
29
+ | Discovery | TA0007 | Low — defensive scanner |
30
+ | Lateral Movement | TA0008 | Out of scope — runtime-only |
31
+ | Collection | TA0009 | Low — sensitive-data flagging via PII patterns |
32
+ | Command and Control | TA0011 | Out of scope — runtime-only |
33
+ | Exfiltration | TA0010 | Medium — SSRF, server-component data leak (CWE-200) |
34
+ | Impact | TA0040 | Low — DoS findings (CWE-770, CWE-1333) |
35
+
36
+ Out-of-scope tactics are intentionally not covered — AEGIS is a SAST + light DAST tool, not an EDR.
37
+
38
+ ## Per-CWE → ATT&CK mapping
39
+
40
+ The complete mapping lives in the AEGIS scanner inventory; the high-leverage entries are:
41
+
42
+ | AEGIS scanner | CWE | ATT&CK technique | ATT&CK ID |
43
+ |---|---|---|---|
44
+ | `taint-analyzer` (SQLi) | CWE-89 | Exploit Public-Facing Application | T1190 |
45
+ | `template-sql-checker` | CWE-89 | Exploit Public-Facing Application | T1190 |
46
+ | `sql-concat-checker` | CWE-89 | Exploit Public-Facing Application | T1190 |
47
+ | `xss-checker` | CWE-79 | Drive-by Compromise (when stored XSS used as initial access) | T1189 |
48
+ | `ssrf-checker` | CWE-918 | Cloud Metadata Discovery / Internal Service Discovery | T1552.005 / T1538 |
49
+ | `path-traversal-checker` | CWE-22 | Exploit Public-Facing Application | T1190 |
50
+ | `crypto-auditor` (eval injection) | CWE-94 | Command and Scripting Interpreter | T1059 |
51
+ | `prompt-injection-checker` | CWE-77, CWE-1426 | Direct/Indirect Prompt Injection (ATLAS) | AML.T0051.000 / AML.T0051.001 |
52
+ | `auth-enforcer` | CWE-285, CWE-306 | Valid Accounts | T1078 |
53
+ | `middleware-auth-checker` | CWE-285 | Valid Accounts | T1078 |
54
+ | `jwt-checker` | CWE-327, CWE-345 | Forge Web Credentials (Web Cookies / SAML / Tokens) | T1606 |
55
+ | `jwt-detector` | CWE-798 | Valid Accounts (cloud accounts) | T1078.004 |
56
+ | `next-public-leak` | CWE-200, CWE-798 | Unsecured Credentials (Credentials in Files) | T1552.001 |
57
+ | `entropy-scanner` | CWE-798 | Unsecured Credentials | T1552 |
58
+ | `tenant-isolation-checker` | CWE-639 | Authorization Bypass / IDOR | T1565 (Data Manipulation) when used for cross-tenant write; T1530 (Data from Cloud Storage) for read |
59
+ | `rls-bypass-checker` | CWE-863 | Authorization Bypass | T1078 (Valid Accounts) when service_role escalates |
60
+ | `rsc-data-checker` | CWE-200 | Sensitive Data Discovery / Exfiltration Over Web Service | T1530 / T1567 |
61
+ | `mass-assignment-checker` | CWE-915 | Modify Authentication Process | T1556 |
62
+ | `open-redirect-checker` | CWE-601 | Spearphishing Link | T1566.002 |
63
+ | `cors-checker` | CWE-346 | Cross-Origin / Browser Session Hijack | T1539 |
64
+ | `csrf-checker` | CWE-352 | Drive-by Compromise (CSRF as initial access) | T1189 |
65
+ | `header-checker` | CWE-693 | Generic — defense-in-depth, maps to D3FEND DOM-ALL |
66
+ | `cookie-checker` | CWE-614, CWE-1004 | Steal Web Session Cookie | T1539 |
67
+ | `timing-safe-checker` | CWE-208 | Brute Force | T1110 |
68
+ | `upload-validator` | CWE-434 | Exploitation for Privilege Escalation (file upload to RCE) | T1068 |
69
+
70
+ ## ATLAS — AI/ML threat model overlay
71
+
72
+ For AI/LLM-touching findings, AEGIS also maps to MITRE ATLAS (Adversarial Threat Landscape for AI Systems):
73
+
74
+ | AEGIS scanner | ATLAS technique | ATLAS ID |
75
+ |---|---|---|
76
+ | `prompt-injection-checker` (direct) | LLM Prompt Injection: Direct | AML.T0051.000 |
77
+ | `prompt-injection-checker` (indirect) | LLM Prompt Injection: Indirect | AML.T0051.001 |
78
+ | `prompt-injection-checker` (system prompt extraction) | Retrieve Sensitive ML Capabilities | AML.T0019 |
79
+
80
+ ATLAS is the AI-specific companion to ATT&CK. For LLM apps, both maps are relevant simultaneously.
81
+
82
+ ## D3FEND — defensive countermeasure mapping
83
+
84
+ D3FEND is MITRE's defensive countermeasure ontology. AEGIS findings naturally map to D3FEND techniques the scanner is enforcing:
85
+
86
+ | AEGIS scanner | D3FEND technique | What the scanner enforces |
87
+ |---|---|---|
88
+ | `ssrf-checker` | Outbound Traffic Filtering | D3-OTF |
89
+ | `crypto-auditor` | Strong Password Policy / Cryptographic Authentication | D3-SPP / D3-CA |
90
+ | `csrf-checker` | Authentication Cache Invalidation / Session Token | D3-ACI |
91
+ | `header-checker` | Domain Account Monitoring (via CSP/HSTS) | D3-DAM |
92
+ | `auth-enforcer` | Process Self-Modification Detection | D3-PSMD |
93
+ | `tenant-isolation-checker` | Resource Access Pattern Analysis | D3-RAPA |
94
+ | `rate-limit-checker` | Inbound Traffic Filtering | D3-ITF |
95
+
96
+ ## NIST CSF 2.0 — high-level alignment
97
+
98
+ NIST CSF 2.0 organizes around 6 functions: Govern, Identify, Protect, Detect, Respond, Recover. AEGIS contributes primarily to:
99
+
100
+ - **Identify (ID)** — `supply-chain`, `dep-confusion-checker`, `getAllScanners()` registry, scanner-coverage README all support asset-management + threat-identification.
101
+ - **Protect (PR)** — every defensive scanner contributes (auth, crypto, headers, cookies, CSP, CSRF, SSRF, RLS, etc.).
102
+ - **Detect (DE)** — `[LOW-CONFIDENCE]` PR badge + per-finding confidence-rules support detection-of-detection-gaps.
103
+ - **Respond (RS)** — out of scope (runtime-only).
104
+ - **Recover (RC)** — out of scope.
105
+ - **Govern (GV)** — the OWASP-APTS conformance posture (`docs/compliance/owasp-apts/`) directly contributes to GV.PO (Policy) and GV.OV (Oversight).
106
+
107
+ ## NIST AI RMF — AI/LLM-specific alignment
108
+
109
+ For LLM-touching code, AEGIS contributes to NIST AI RMF Map / Measure / Manage functions:
110
+
111
+ - **Map** — `prompt-injection-checker` identifies AI risk surface.
112
+ - **Measure** — confidence-scoring on AI-related findings; FP rate disclosure.
113
+ - **Manage** — `aegis fix` provides a remediation workflow for AI-related findings.
114
+
115
+ ## How to use this mapping
116
+
117
+ 1. **For executive reports** — translate each AEGIS finding's CWE to its ATT&CK technique using the per-CWE table; group by tactic for a "what the attacker could do with what we ship" narrative.
118
+ 2. **For threat models** — overlay AEGIS scanner coverage onto your team's threat model. Gaps in tactics (TA0008 lateral movement, TA0011 C2) need other tools (EDR, SIEM, network).
119
+ 3. **For compliance crosswalk** — when an auditor asks "what NIST CSF controls does this tool implement?", point to the function-level alignment above.
120
+ 4. **For SOC integration** — if your SIEM ingests SARIF, the SARIF emitter already includes the CWE; configure the SIEM to tag inbound findings with the corresponding ATT&CK technique using this mapping table.
121
+
122
+ ## See also
123
+
124
+ - `mitre-t1190-exploit-public-app` skill — deep-dive on T1190 coverage.
125
+ - `mitre-t1078-valid-accounts` skill — deep-dive on T1078 coverage.
126
+ - AEGIS scanner inventory in `README.md` — authoritative per-scanner CWE list.
127
+ - MITRE ATT&CK — https://attack.mitre.org/
128
+ - MITRE ATLAS — https://atlas.mitre.org/
129
+ - MITRE D3FEND — https://d3fend.mitre.org/
@@ -0,0 +1,136 @@
1
+ <!-- aegis-local: AEGIS-native skill, MIT-licensed; deep-dive on MITRE ATT&CK T1078 (Valid Accounts) coverage in AEGIS. -->
2
+
3
+ ---
4
+ name: mitre-t1078-valid-accounts
5
+ description: "MITRE ATT&CK T1078 (Valid Accounts) — deep-dive coverage map for AEGIS credential-protection scanner family. T1078 is one of the most consistently top-3 Initial Access techniques (Verizon DBIR multi-year). Covers stolen credentials, weak credentials, default accounts, cloud-IAM credentials, and JWT-format credentials. Use when responding to T1078 alerts, building credential-coverage reports, or determining which AEGIS scanners speak to a specific T1078 sub-technique."
6
+ ---
7
+
8
+ # T1078 — Valid Accounts
9
+
10
+ ## Why T1078 matters
11
+
12
+ ATT&CK technique T1078 captures any compromise where the attacker uses credentials they obtained (stolen, leaked, default, weak). Sub-techniques cover Default (T1078.001), Domain (T1078.002), Local (T1078.003), and Cloud (T1078.004) accounts.
13
+
14
+ T1078 is consistently top-3 in Verizon DBIR. Credential-leak via source-code is among the most common entry-points; AEGIS's credential-protection scanner family is purpose-built for this.
15
+
16
+ ## AEGIS coverage map — credential-protection scanner family
17
+
18
+ AEGIS ships four scanners that detect credentials at code-review time, plus the `safeFetch` SSRF defense that protects cloud-metadata-IMDSv2-credential-theft adjacent paths.
19
+
20
+ ### entropy-scanner (CWE-798)
21
+
22
+ Shannon-entropy-based detection of high-entropy strings in source code. Catches credentials that don't match a known format (e.g., random API tokens, custom secret formats).
23
+
24
+ - **What it catches:** any string with entropy > threshold (configurable).
25
+ - **What it misses:** low-entropy credentials (passwords like `Password123!`), structured credentials that look "normal" (e.g., a UUID-shaped token).
26
+ - **Sister scanners:** `gitleaks` (external wrapper) covers known-format credentials; `trufflehog` (external) covers verified-credential validation.
27
+
28
+ ### jwt-detector (CWE-798)
29
+
30
+ Detects literal JWT tokens (`eyJ...` strings) hardcoded in source. Catches:
31
+
32
+ - Service-role tokens shipped in source.
33
+ - Demo / development tokens accidentally committed.
34
+ - Tokens copy-pasted into code as hard-coded auth.
35
+
36
+ Comment-aware via `stripComments` — excluded from doc strings and inline `// example: eyJ...` comments to avoid false positives on documentation.
37
+
38
+ ### next-public-leak (CWE-200, CWE-798)
39
+
40
+ Specialty scanner for Next.js — catches:
41
+
42
+ - Secrets accidentally prefixed `NEXT_PUBLIC_*` (which Next.js bundles into client code).
43
+ - Server-only env vars read in `'use client'` files (which leaks the value to the bundle).
44
+
45
+ This is a Next.js-specific T1078.004 (Cloud Accounts) protection because cloud credentials prefixed `NEXT_PUBLIC_` end up in every browser session of every user.
46
+
47
+ ### crypto-auditor (CWE-326, CWE-327, CWE-338, CWE-798)
48
+
49
+ Detects:
50
+
51
+ - Weak hash algorithms (MD5, SHA-1) used for security purposes (not just checksumming).
52
+ - Insecure RNG (`Math.random()` for security tokens — biased + predictable).
53
+ - Hardcoded secret literals (a separate detection path from entropy-scanner; catches structured-format secrets).
54
+ - `eval()` injection (CWE-94, adjacent to T1059 but listed here because crypto-auditor is the scanner).
55
+
56
+ ## T1078 sub-technique coverage
57
+
58
+ ### T1078.001 — Default Accounts
59
+
60
+ | Vector | AEGIS scanner | Strength |
61
+ |---|---|---|
62
+ | Default credentials shipped in source | `entropy-scanner`, `crypto-auditor` | medium (depends on default value entropy) |
63
+ | Default-admin route without auth gate | `auth-enforcer` (CWE-285, CWE-306) | strict |
64
+
65
+ ### T1078.002 — Domain Accounts
66
+
67
+ Out of scope for SAST — domain accounts are an Active-Directory-runtime concern.
68
+
69
+ ### T1078.003 — Local Accounts
70
+
71
+ Partially in scope:
72
+
73
+ | Vector | AEGIS scanner | Strength |
74
+ |---|---|---|
75
+ | Hardcoded local-account password in source | `entropy-scanner`, `crypto-auditor` | strict-when-entropy-high |
76
+ | Service-role-key (Supabase) in source | `next-public-leak`, `entropy-scanner`, `jwt-detector` | strict (multi-layer) |
77
+
78
+ ### T1078.004 — Cloud Accounts
79
+
80
+ Highest-leverage AEGIS coverage:
81
+
82
+ | Vector | AEGIS scanner | Strength |
83
+ |---|---|---|
84
+ | AWS access key in source | `entropy-scanner` (AKIA prefix detection) | strict |
85
+ | GCP service-account JSON in source | `entropy-scanner`, `gitleaks` (external) | strict |
86
+ | Anthropic / OpenAI API keys in source | `entropy-scanner`, `crypto-auditor` | strict |
87
+ | Cloud-metadata-IMDS-credential exfil via SSRF | `ssrf-checker` (cloud-metadata IP block-rules) | strict |
88
+ | `NEXT_PUBLIC_` cloud-secret leak | `next-public-leak` | strict (Next.js-specific) |
89
+
90
+ ## What T1078 patterns AEGIS does NOT cover
91
+
92
+ - **Credential stuffing detection** — runtime concern; no SAST coverage.
93
+ - **Brute-force detection** — runtime concern (rate-limit-checker covers the *prevention* side: missing rate-limit on auth endpoints).
94
+ - **MFA-fatigue / push-bombing** — runtime-only.
95
+ - **Compromised-credential-database lookup** — needs a real-time API like HaveIBeenPwned; out of scope for SAST.
96
+
97
+ For these, integrate AEGIS findings with your SIEM / EDR / IdP.
98
+
99
+ ## Defensive playbook (T1078 prevention)
100
+
101
+ ### Source-code-side (AEGIS does this)
102
+
103
+ 1. Run `aegis scan .` in CI; fix every `entropy-scanner`, `jwt-detector`, `next-public-leak`, `crypto-auditor` BLOCKER finding.
104
+ 2. Wire `gitleaks` (external wrapper) for known-format-credentials coverage.
105
+ 3. Wire `trufflehog` (external wrapper) for verified-credential validation.
106
+ 4. Pin pre-commit hooks (`.husky/pre-push` runs `aegis scan --fail-on-blocker`).
107
+
108
+ ### Operational-side (out of AEGIS scope)
109
+
110
+ 1. Use a secret manager (Vault, 1Password, AWS Secrets Manager). Never `.env` files in production.
111
+ 2. Rotate credentials on a schedule; rotate immediately on any credential-related finding.
112
+ 3. Enable MFA on every cloud-IAM root account.
113
+ 4. Use short-lived credentials (AWS STS, GCP service account impersonation) wherever possible.
114
+ 5. Audit IAM roles quarterly — least-privilege is a journey, not a one-shot.
115
+
116
+ ### Detection-side (out of AEGIS scope)
117
+
118
+ 1. SIEM rules for impossible-travel logins.
119
+ 2. EDR rules for service-account login from unexpected sources.
120
+ 3. Cloud-provider GuardDuty / Security Hub findings for anomalous IAM use.
121
+
122
+ ## Response runbook (post-credential-leak)
123
+
124
+ 1. **Rotate immediately** — every credential pattern AEGIS flags is potentially compromised; assume worst case.
125
+ 2. **Audit usage logs** — for each rotated credential, pull the access log for the leak window.
126
+ 3. **Identify reach** — for each authenticated session, what data / actions did it touch?
127
+ 4. **Notify** — GDPR Art. 33 if PII reached; SEC-rule disclosures if material; vendor contracts if vendor-credentials.
128
+ 5. **Patch** — remove the credential from source; replace with secret-manager reference.
129
+ 6. **Post-incident review** — was there a control gap? Should AEGIS scanner sensitivity be tuned? Should pre-commit hooks be tightened?
130
+
131
+ ## See also
132
+
133
+ - `mitre-mapping-overview` skill — top-level scanner-to-technique mapping.
134
+ - `defensive-rls-defense` — Supabase service-role-key safety.
135
+ - AEGIS scaffold's `lib/security/secureApiRouteWithTenant` primitive — wires session-sourced authentication automatically.
136
+ - MITRE ATT&CK T1078 — https://attack.mitre.org/techniques/T1078/
@@ -0,0 +1,108 @@
1
+ <!-- aegis-local: AEGIS-native skill, MIT-licensed; deep-dive on MITRE ATT&CK T1190 (Exploit Public-Facing Application) coverage in AEGIS. -->
2
+
3
+ ---
4
+ name: mitre-t1190-exploit-public-app
5
+ description: "MITRE ATT&CK T1190 (Exploit Public-Facing Application) — deep-dive coverage map for AEGIS scanners. T1190 is the most common Initial Access pattern (Verizon DBIR 2024 #1). Covers SQL injection, XSS, SSRF, command injection, deserialization, and authentication bypass. Use when responding to T1190 alerts, building T1190-coverage reports, or determining which AEGIS scanners speak to a specific T1190 sub-pattern."
6
+ ---
7
+
8
+ # T1190 — Exploit Public-Facing Application
9
+
10
+ ## Why T1190 matters
11
+
12
+ ATT&CK technique T1190 is the **#1 Initial Access vector** in Verizon DBIR 2024. It captures any vulnerability in an internet-facing application that lets an attacker execute code, read data, or pivot. Covered sub-patterns include SQL injection, XSS leading to session hijack, SSRF reaching internal services, RCE via deserialization, command injection, file-upload exploits, and auth-bypass.
13
+
14
+ A defense in depth program that doesn't have strong T1190 coverage is incomplete by definition.
15
+
16
+ ## AEGIS coverage map
17
+
18
+ AEGIS contributes the following defensive scanners to T1190 coverage:
19
+
20
+ ### SQL injection — taint-analyzer + template-sql-checker + sql-concat-checker
21
+
22
+ | Vector | AEGIS scanner | Strength |
23
+ |---|---|---|
24
+ | Same-file taint (request → template → query) | `taint-analyzer` | strict-30/30 benchmark |
25
+ | Cross-file taint | `taint-analyzer` | medium-confidence |
26
+ | Template-literal SQL via `.rpc()` / `.execute()` / `.query()` / `.$queryRawUnsafe()` | `template-sql-checker` | strict |
27
+ | String concatenation SQL | `sql-concat-checker` | strict |
28
+
29
+ **T1190 sub-pattern coverage:** error-based, UNION-based, blind, second-order — all covered at the taint-source-to-sink level. AEGIS doesn't generate live SQL payloads (that's siege-mode + Strix/PTAI). It catches the vulnerable pattern at code-review time.
30
+
31
+ ### XSS — xss-checker + taint-analyzer
32
+
33
+ | Vector | AEGIS scanner | Notes |
34
+ |---|---|---|
35
+ | Reflected (response includes user input) | `xss-checker`, `taint-analyzer` | per-CWE: `DOMPurify.sanitize()` recognized as sanitizer; `parseInt()`, `encodeURIComponent()` partial-recognized per context |
36
+ | Stored XSS (DB writes user content used in HTML) | `xss-checker`, `taint-analyzer` | mass-assignment + render-without-sanitizer pattern |
37
+ | DOM-based XSS | `xss-checker` (lints `innerHTML` + `dangerouslySetInnerHTML`) | partial |
38
+
39
+ ### SSRF — ssrf-checker + taint-analyzer
40
+
41
+ | Vector | AEGIS scanner | Notes |
42
+ |---|---|---|
43
+ | Direct fetch from user input | `ssrf-checker`, `taint-analyzer` | RFC 1918 / link-local literal recognition; `isForbiddenIP` helper recognition |
44
+ | URL-position-only check | `ssrf-checker` | only the first arg of `fetch(url, …)` counts; tainted values in headers/body do not |
45
+ | Library-wrapper hoisting | `ssrf-checker` (Z4 heuristic) | exported fetch-wrappers where the URL is a parameter no longer emit at the wrapper site |
46
+ | DNS rebinding | not detected by SAST | requires runtime defense (`safeFetch` with pinned IP) — see `defensive-ssrf` skill |
47
+
48
+ ### Command injection — crypto-auditor (eval injection) + cli `getChangedFiles` hardening
49
+
50
+ | Vector | AEGIS scanner | Notes |
51
+ |---|---|---|
52
+ | `eval(userInput)`, `Function(userInput)()` | `crypto-auditor` (CWE-94) | strict |
53
+ | Shell injection via `execSync(template-literal)` | `taint-analyzer` (CWE-78) | strict via sink-list |
54
+ | Prompt-injection-as-cmd-injection (LLM tool-use) | `prompt-injection-checker` (CWE-77, CWE-1426) | ATLAS-aligned |
55
+
56
+ ### File-upload exploits — upload-validator
57
+
58
+ `upload-validator` flags uploads without magic-byte validation (CWE-434), which is the entry-point for path-traversal-via-filename, executable-upload-then-execute, and content-type confusion attacks.
59
+
60
+ ### Authentication bypass — auth-enforcer + middleware-auth-checker + jwt-checker
61
+
62
+ | Vector | AEGIS scanner | Notes |
63
+ |---|---|---|
64
+ | Missing auth guard on API route | `auth-enforcer` (CWE-285, CWE-306) | per-route detection |
65
+ | RBAC gap | `auth-enforcer` (CWE-285) | role-check pattern detection |
66
+ | Next.js middleware auth-bypass (CVE-2025-29927) | `middleware-auth-checker` (CWE-285) | `x-middleware-subrequest` header pattern |
67
+ | JWT 'none' algorithm | `jwt-checker` (CWE-327) | strict |
68
+ | JWT weak signing | `jwt-checker` (CWE-345) | partial |
69
+
70
+ ### Server-Component data-leak — rsc-data-checker
71
+
72
+ CWE-200 — Server Components passing full DB records to client. T1190-adjacent because the leaked data may include credentials or session tokens that enable downstream compromise.
73
+
74
+ ## What T1190 sub-patterns AEGIS does NOT cover
75
+
76
+ - **Deserialization (CWE-502)** — AEGIS has no `deserialization-checker` today; this is a known gap. The Strix/PTAI/Pentest-Swarm-AI wrappers cover it via their own DAST testing during siege-mode.
77
+ - **XML External Entity (XXE)** — same as above, runtime-only via wrappers.
78
+ - **Server-Side Template Injection (SSTI)** — same as above.
79
+ - **HTTP Request Smuggling** — runtime-only via wrappers.
80
+
81
+ These gaps are documented in `README.md` § "Honest limitations" and in the `@aegis-scan/skills` offensive-skills library (`offensive/snailsploit-fork/{deserialization,xxe,ssti,request-smuggling}/SKILL.md`) so red-team agents know to test these classes manually.
82
+
83
+ ## Detection-side — how to know you're under T1190 attack
84
+
85
+ ATT&CK technique procedures cite these detection signals, which your SIEM should already be ingesting:
86
+
87
+ - WAF logs flagging known SQLi/XSS/SSRF payloads.
88
+ - Anomalous outbound connections from server-side processes (SSRF reach indicator).
89
+ - 5xx error spikes correlated with specific input patterns (probing).
90
+ - New process spawns from web-server contexts (RCE indicator).
91
+ - `npm install` / `pip install` events on production hosts (post-RCE persistence).
92
+
93
+ AEGIS doesn't run at runtime; SIEM/EDR/WAF do. AEGIS prevents the vulnerable code from shipping in the first place — preventive, not detective.
94
+
95
+ ## Response runbook (post-T1190 detection)
96
+
97
+ 1. **Containment** — block the offending source IP at the WAF / load balancer.
98
+ 2. **Forensics** — pull the request log for the affected window; identify the specific endpoint that was exploited.
99
+ 3. **AEGIS finding cross-reference** — run `aegis history . --blame` filtered to the affected file/path; identify whether AEGIS had previously flagged this endpoint.
100
+ 4. **Patch** — depending on the sub-pattern, follow `defensive-ssrf` / `defensive-rls-defense` / `defensive-tenant-isolation` skills.
101
+ 5. **Post-incident** — file a regression test that the patched endpoint cannot be re-exploited; add to AEGIS canary fixtures if the sub-pattern was novel.
102
+
103
+ ## See also
104
+
105
+ - `mitre-mapping-overview` skill — top-level scanner-to-technique mapping.
106
+ - `defensive-ssrf` / `defensive-rls-defense` / `defensive-tenant-isolation` — defensive playbooks.
107
+ - AEGIS taint-analyzer engine — `README.md` § "Taint Analysis Engine".
108
+ - MITRE ATT&CK T1190 — https://attack.mitre.org/techniques/T1190/