Skip to content

An open-source, faster Devin alternative

TypeScript

feat(cve-swarm): seed swarm payload with live feeds + discovery angles

Mohamed Habib via Computer22e5b65bd442
diff --git a/web/src/managed-agents/security/catalog.test.ts b/web/src/managed-agents/security/catalog.test.ts
index 5015388f..146399b2 100644
--- a/web/src/managed-agents/security/catalog.test.ts
+++ b/web/src/managed-agents/security/catalog.test.ts
@@ -49,16 +49,37 @@ describe('swarm fan-out', () => {
expect(first).not.toBe(second)
})
- it('narrows the prompt to a single repository and CVE', () => {
+ it('narrows the prompt to a single repository and CVE seed', () => {
const prompt = composeCellPrompt(payload, {
repository: 'acme/web',
cveId: 'CVE-2026-1',
})
expect(prompt).toContain('Repository: acme/web')
- expect(prompt).toContain('CVE: CVE-2026-1')
+ expect(prompt).toContain('CVE seed: CVE-2026-1')
expect(prompt).toContain('scan_surface')
expect(prompt).not.toContain('acme/api')
})
+
+ it('seeds the cell with live feeds and keeps probing scoped to the target', () => {
+ const prompt = composeCellPrompt(payload, {
+ repository: 'acme/web',
+ cveId: 'CVE-2026-1',
+ })
+ expect(prompt).toContain('cve.now')
+ expect(prompt).toContain('pwn.watch')
+ expect(prompt).toContain('/workspace')
+ // Probing is pinned to the attested host, named explicitly.
+ expect(prompt).toContain('Stay on https://app.example.com')
+ })
+
+ it('drops target-only discovery steps when no target is given', () => {
+ const prompt = composeCellPrompt(
+ { ...payload, target: '' },
+ { repository: 'acme/web', cveId: 'CVE-2026-1' },
+ )
+ expect(prompt).not.toContain('scan_surface')
+ expect(prompt).toContain('reachable in this code')
+ })
})
describe('parseCellFinding', () => {
diff --git a/web/src/managed-agents/security/catalog.ts b/web/src/managed-agents/security/catalog.ts
index 369729a5..09128c1d 100644
--- a/web/src/managed-agents/security/catalog.ts
+++ b/web/src/managed-agents/security/catalog.ts
@@ -3,6 +3,8 @@
// the user connects, and the code-owned safety rails live in the deployed
// cve-swarm template. Nothing here widens scope; it only prefills the payload.
+import { assignAngles, feedSeedingLines } from './feeds'
+
// The deployable template the security flow installs. Must be a public repo the
// template-installation backend can inspect.
export const SECURITY_SWARM_TEMPLATE_REPOSITORY =
@@ -233,24 +235,46 @@ export function listManifestDocs(
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
}
-// One cell's first-run input: a single repository checked against a single CVE.
-// The worker agent already collapses to a 1×1 matrix when the payload names one
-// of each, so this is the launch prompt narrowed to the cell.
+// How a cell turns the repository into a live hunt once it has fingerprinted the
+// target. Shared by the cell and launch prompts so "derive routes, probe, keep
+// evidence" reads identically everywhere. Scoped hard to the attested host — the
+// authorization boundary is the operator's ownership declaration, so probing
+// must never leave that one target.
+export function discoveryLines(target: string): string[] {
+ if (!target) {
+ return [
+ 'Read the repository clone to prove whether the seeded CVEs are reachable in this code, then save the finding with memory_save.',
+ ]
+ }
+ return [
+ 'Discover, do not just read:',
+ '- Read the repository clone to derive its real routes, parameters and auth flows — that map is what you probe.',
+ `- Fingerprint ${target} with scan_surface, then exercise the mapped routes on that host to prove whether the exposure is actually reachable. Stay on ${target}; never touch another host.`,
+ '- Record evidence into /workspace as you go (request/response logs, screenshots, a finding.md) so the proof outlives the session.',
+ '- Save the finding with memory_save.',
+ ]
+}
+
+// One cell's first-run input. A cell still carries one repository and one CVE
+// seed, but the task is discovery, not a lockfile read: pull live feed
+// intelligence, derive the repo's routes, probe the attested target, and keep
+// evidence. The worker collapses to a single hunt when the payload names one
+// repository and one CVE.
export function composeCellPrompt(payload: SwarmPayload, cell: SwarmCell): string {
const lines = [
'Launch a CVE swarm cell against my own assets.',
'',
`Declaration: ${SCAN_DECLARATION}`,
payload.target
- ? `Target endpoint (passive scan only): ${payload.target}`
+ ? `Target (authorized discovery within this host only): ${payload.target}`
: null,
`Repository: ${cell.repository}`,
- `CVE: ${cell.cveId}`,
+ `CVE seed: ${cell.cveId}`,
`Model: ${payload.model}`,
'',
- payload.target
- ? 'Run scan_surface on the target once to fingerprint it passively, then prove whether this CVE is reachable in this repository by reading the clone, then save the one finding with memory_save.'
- : 'Prove whether this CVE is reachable in this repository by reading the clone, then save the one finding with memory_save.',
+ ...feedSeedingLines(),
+ '',
+ ...discoveryLines(payload.target),
'If the verdict is EXPOSED, open_fix_pull_request (dependency-only, single pin). Honor PUBLISH_ENABLED — dry run unless it is enabled.',
].filter((line): line is string => line !== null)
return lines.join('\n')
@@ -447,20 +471,24 @@ export function composeLaunchPrompt(payload: SwarmPayload): string {
payload.cveIds.length > 0
? payload.cveIds.join(', ')
: "this week's full feed"
+ const angles = assignAngles(Math.max(payload.repositories.length, 1))
+ .map((a) => a.label)
+ .join(', ')
const lines = [
'Launch a CVE swarm against my own assets.',
'',
`Declaration: ${SCAN_DECLARATION}`,
payload.target
- ? `Target endpoint (passive scan only): ${payload.target}`
+ ? `Target (authorized discovery within this host only): ${payload.target}`
: null,
`Repositories: ${repos}`,
- `CVEs: ${cves}`,
+ `CVE seeds: ${cves}`,
+ `Discovery angles to spread across the swarm: ${angles}`,
`Model: ${payload.model}`,
'',
- payload.target
- ? 'Run scan_surface on the target to fingerprint it passively, then prove reachability across the repository × CVE matrix by reading each clone, then save the findings once with memory_save.'
- : 'Prove reachability across the repository × CVE matrix by reading each clone, then save the findings once with memory_save.',
+ ...feedSeedingLines(),
+ '',
+ ...discoveryLines(payload.target),
'For any EXPOSED verdict, open_fix_pull_request (dependency-only, single pin). Honor PUBLISH_ENABLED — dry run unless it is enabled.',
].filter((line): line is string => line !== null)
return lines.join('\n')
diff --git a/web/src/managed-agents/security/feeds.test.ts b/web/src/managed-agents/security/feeds.test.ts
new file mode 100644
index 00000000..33138c01
--- /dev/null
+++ b/web/src/managed-agents/security/feeds.test.ts
@@ -0,0 +1,54 @@
+import { describe, expect, it } from 'vitest'
+import {
+ DISCOVERY_ANGLES,
+ SWARM_FEEDS,
+ assignAngles,
+ feedSeedingLines,
+} from './feeds'
+
+describe('discovery angles', () => {
+ it('round-robins angles across cells so a swarm diverges', () => {
+ const three = assignAngles(3).map((a) => a.id)
+ expect(three).toEqual(DISCOVERY_ANGLES.slice(0, 3).map((a) => a.id))
+ expect(new Set(three).size).toBe(3)
+ })
+
+ it('wraps back to the first angle once the catalog is exhausted', () => {
+ const count = DISCOVERY_ANGLES.length + 2
+ const assigned = assignAngles(count)
+ expect(assigned).toHaveLength(count)
+ expect(assigned[DISCOVERY_ANGLES.length].id).toBe(DISCOVERY_ANGLES[0].id)
+ expect(assigned[DISCOVERY_ANGLES.length + 1].id).toBe(DISCOVERY_ANGLES[1].id)
+ })
+
+ it('is empty for a non-positive count', () => {
+ expect(assignAngles(0)).toEqual([])
+ expect(assignAngles(-3)).toEqual([])
+ })
+
+ it('every angle carries an id, label and focus line', () => {
+ for (const angle of DISCOVERY_ANGLES) {
+ expect(angle.id).toMatch(/^[a-z-]+$/)
+ expect(angle.label.length).toBeGreaterThan(0)
+ expect(angle.focus.length).toBeGreaterThan(0)
+ }
+ })
+})
+
+describe('feed seeding', () => {
+ it('names both live feeds with reachable JSON endpoints', () => {
+ const ids = SWARM_FEEDS.map((f) => f.id)
+ expect(ids).toContain('cve.now')
+ expect(ids).toContain('pwn.watch')
+ for (const feed of SWARM_FEEDS) {
+ expect(feed.json).toMatch(/^https:\/\//)
+ }
+ })
+
+ it('points the agent at live feeds and the lockfile match', () => {
+ const text = feedSeedingLines().join('\n')
+ expect(text).toContain('cve.now')
+ expect(text).toContain('pwn.watch')
+ expect(text).toContain('check_stack')
+ })
+})
diff --git a/web/src/managed-agents/security/feeds.ts b/web/src/managed-agents/security/feeds.ts
new file mode 100644
index 00000000..e98ac604
--- /dev/null
+++ b/web/src/managed-agents/security/feeds.ts
@@ -0,0 +1,147 @@
+// Live vulnerability feeds and the discovery-angle model for the CVE Swarm.
+//
+// These are the real, public endpoints the swarm seeds from. Nothing here is a
+// credential or a scope grant — they are read-only intelligence sources the
+// cell agents can reach over the sandbox's open egress with a plain `curl`.
+// The swarm uses them for two jobs:
+// 1. Seed each cell with *current* vulnerability intelligence (what is being
+// exploited this week), so the hunt stays fresh without a code change.
+// 2. Match a repository's dependency manifest to the CVEs that actually apply
+// to it, so a cell targets real exposure instead of guessing.
+//
+// Both feeds are agent-native: each publishes an `llms.txt` describing itself,
+// and cve.now additionally runs an MCP server whose `check_stack` tool maps a
+// lockfile to applicable advisories. We prefer the plain JSON endpoints for the
+// payload because they work today with zero client dependencies; the MCP path
+// is the precise upgrade once the template wires an MCP client.
+
+export type VulnerabilityFeed = {
+ readonly id: string
+ readonly label: string
+ // One line on what the feed is good for, surfaced in the payload so the agent
+ // knows why it is being pointed at this source.
+ readonly purpose: string
+ // The zero-dependency JSON endpoint a cell can curl directly.
+ readonly json: string
+ // Human/RSS entry point, kept for the UI and for operators.
+ readonly rss: string
+}
+
+// cve.now — merges CVE List, GHSA, OSV, NVD, CISA KEV, EPSS and Exploit-DB into
+// one enriched entry per vulnerability. The enrichment (EPSS exploit
+// probability, KEV known-exploited status) is what lets a cell prioritise.
+export const CVE_NOW: VulnerabilityFeed = {
+ id: 'cve.now',
+ label: 'cve.now',
+ purpose:
+ 'Enriched per-CVE intelligence (EPSS, CISA KEV, CWE) merged from CVE List, GHSA, OSV, NVD and Exploit-DB.',
+ json: 'https://cve.now/feed?format=json',
+ rss: 'https://cve.now/feed',
+}
+
+// pwn.watch — live incident tracker (Patch-now / Breaches / Supply-chain) with
+// CVE ids, patch status and KEV flags. This is the "what is hot right now"
+// pulse that keeps the swarm weighted toward active threats.
+export const PWN_WATCH: VulnerabilityFeed = {
+ id: 'pwn.watch',
+ label: 'pwn.watch',
+ purpose:
+ 'Live security-incident pulse: what is being exploited, patched or supply-chain-compromised this week.',
+ json: 'https://pwn.watch/incidents.json',
+ rss: 'https://pwn.watch/all/feed.xml',
+}
+
+export const SWARM_FEEDS: readonly VulnerabilityFeed[] = [CVE_NOW, PWN_WATCH]
+
+// cve.now's newest-first entries endpoint (cursor-paginated). A cell curls this
+// to pull the current feed slice for its angle.
+export const CVE_NOW_ENTRIES_API = 'https://cve.now/api/v1/entries'
+
+// cve.now's MCP server. `check_stack` matches a repository's lockfile against
+// known advisories — the precise "which CVEs hit THIS repo" primitive. Referenced
+// in the payload as the upgrade path; not required for the curl-only flow.
+export const CVE_NOW_MCP = 'https://mcp.cve.now/mcp'
+
+// A discovery angle: one lens a cell hunts the target through. Giving each cell
+// a different angle is what makes a swarm of N agents *diverge* instead of
+// converging on the same finding — diversity is the whole point of fanning out.
+export type DiscoveryAngle = {
+ readonly id: string
+ readonly label: string
+ // What this cell hunts for, in one imperative line dropped into its prompt.
+ readonly focus: string
+}
+
+// The attack-surface lenses, ordered roughly by how commonly they turn up real
+// exposure. `assignAngles` round-robins these across the cells so every swarm
+// covers the surface broadly before it doubles up any one lens.
+export const DISCOVERY_ANGLES: readonly DiscoveryAngle[] = [
+ {
+ id: 'auth-session',
+ label: 'Authentication & session',
+ focus:
+ 'Probe login, token issuance, session fixation, password reset and multi-factor flows for broken authentication.',
+ },
+ {
+ id: 'access-control',
+ label: 'Broken access control / IDOR',
+ focus:
+ 'Enumerate object ids and privileged routes to find data or actions reachable without the right authorization.',
+ },
+ {
+ id: 'injection',
+ label: 'Injection',
+ focus:
+ 'Test request parameters, headers and bodies for SQL, NoSQL, command and template injection reflected by the app.',
+ },
+ {
+ id: 'ssrf-request',
+ label: 'SSRF & request forgery',
+ focus:
+ 'Hunt server-side request forgery, open redirects and CSRF in features that fetch URLs or act on behalf of a user.',
+ },
+ {
+ id: 'client-side',
+ label: 'Client-side & JS routes',
+ focus:
+ 'Crawl the client bundle for hidden routes and API calls, then test for XSS and client-side trust failures.',
+ },
+ {
+ id: 'business-logic',
+ label: 'Business logic',
+ focus:
+ 'Abuse multi-step workflows — pricing, quotas, state transitions — for logic flaws no scanner signature catches.',
+ },
+ {
+ id: 'supply-chain',
+ label: 'Dependency & supply-chain',
+ focus:
+ 'Match the repository manifest against live advisories and prove whether a vulnerable dependency is actually served.',
+ },
+]
+
+// Spread `count` cells across the angle catalog, round-robin. Returns one angle
+// per cell, so the launcher can hand each fanned-out session a distinct lens.
+// With more cells than angles the lenses repeat in order, which is intended —
+// a second pass on the same angle from a fresh agent still finds different
+// things. `count <= 0` yields an empty assignment.
+export function assignAngles(count: number): DiscoveryAngle[] {
+ const assigned: DiscoveryAngle[] = []
+ for (let i = 0; i < count; i += 1) {
+ assigned.push(DISCOVERY_ANGLES[i % DISCOVERY_ANGLES.length])
+ }
+ return assigned
+}
+
+// The feed-seeding steps, as prompt lines shared by the cell and launch prompts
+// so there is one source of truth for how a cell pulls live intelligence. Kept
+// curl-first (works today over open egress); the MCP path is named as the
+// precise upgrade, not a requirement.
+export function feedSeedingLines(): string[] {
+ return [
+ 'Seed the hunt from live intelligence before touching the target:',
+ `- Pull the current feed from ${CVE_NOW.json} and ${PWN_WATCH.json} (plain JSON over egress) to see what is being exploited now.`,
+ `- Match this repository's dependency manifest against applicable advisories — cve.now's check_stack (MCP at ${CVE_NOW_MCP}) is the precise path; fall back to ${CVE_NOW_ENTRIES_API} by product if MCP is unavailable.`,
+ '- Weight the hunt toward CISA KEV / high-EPSS entries that line up with the routes this repository actually exposes.',
+ ]
+}