Skip to content

An open-source, faster Devin alternative

TypeScript

feat(cve-swarm): one agent per CVE from a live severity-sorted feed

Mohamed Habib via Computer5c9ad61ef97d
diff --git a/web/src/managed-agents/api.ts b/web/src/managed-agents/api.ts
index ee67b0df..e335dc6e 100644
--- a/web/src/managed-agents/api.ts
+++ b/web/src/managed-agents/api.ts
@@ -2655,7 +2655,8 @@ export async function runManagedAgent(
/**
* Creates a session and queues its first turn without waiting for the run to
* finish. This is the fan-out primitive: a swarm launch calls it once per cell
- * (one repository × one CVE), each with its own findings-document binding and
+ * (one agent per CVE, every repo as shared evidence), each with its own
+ * findings-document binding and
* labels that tie the session back to the run and cell, then returns the
* session ids for the grid to poll. Unlike `runManagedAgent` it never blocks on
* completion or suspends — the turn is admitted in `queue` mode and runs on the
diff --git a/web/src/managed-agents/security/SecurityOnboarding.tsx b/web/src/managed-agents/security/SecurityOnboarding.tsx
index 6f15ca9a..027f69f1 100644
--- a/web/src/managed-agents/security/SecurityOnboarding.tsx
+++ b/web/src/managed-agents/security/SecurityOnboarding.tsx
@@ -46,7 +46,6 @@ import {
SCAN_DECLARATION,
SECURITY_FINDINGS_RESOURCE,
SECURITY_SWARM_TEMPLATE_REPOSITORY,
- SEED_CVES,
serializeRunManifest,
swarmCells,
SWARM_LOGIN_PASSWORD_VAR,
@@ -55,16 +54,21 @@ import {
type SwarmCell,
type SwarmPayload,
} from './catalog'
+import { fetchLiveCves, type FeedCve } from './feeds'
// The throwaway test-account credentials, carried from the form to the launch
// handler out-of-band from SwarmPayload so they never reach the cell prompt or
// the run manifest. They go only to the project's encrypted runtime variables.
type SwarmCredentials = { username: string; password: string }
-// Each cell is one microVM session, so cap the matrix to keep an accidental
-// 20×20 launch from spinning up hundreds of sandboxes at once.
+// Each cell is one microVM session — one agent per CVE — so cap the swarm to
+// keep a careless "top 200" from spinning up hundreds of sandboxes at once.
const MAX_SWARM_CELLS = 24
+// How many of the live, severity-sorted CVEs to preselect on first load, so a
+// first swarm runs with no typing. Clamped to the cap and the feed size.
+const DEFAULT_TOP_N = 8
+
// Deploying the swarm project is no longer a step the operator clicks through —
// it starts on its own the moment GitHub is connected and runs while they fill
// in the payload, so by launch time it's usually already done.
@@ -143,7 +147,7 @@ async function launchCellsInBackground(args: {
resource: SECURITY_FINDINGS_RESOURCE,
environment: 'default',
id,
- title: `${cell.repository} · ${cell.cveId}`,
+ title: cell.cveId,
text: '{}',
})
const { sessionId } = await startManagedAgentSession(
@@ -356,8 +360,9 @@ export default function SecurityOnboarding() {
? 'deploying'
: 'idle'
- // Launch fans the payload's repository × CVE matrix out into one bound session
- // per cell. The slow part is booting each cell's sandbox, so we don't block the
+ // Launch fans the payload's picked CVEs out into one bound session per CVE —
+ // each agent hunts a single CVE against the live target, with every repo as
+ // shared evidence. The slow part is booting each cell's sandbox, so we don't block the
// UI on it: we write the run manifest immediately with every cell `starting`,
// navigate to the run page, then boot the sandboxes in the background (see
// launchCellsInBackground), flipping each cell to `started` with its session id
@@ -380,11 +385,11 @@ export default function SecurityOnboarding() {
}> => {
const cells = swarmCells(payload)
if (cells.length === 0) {
- throw new Error('Add at least one repository and one CVE to swarm.')
+ throw new Error('Pick at least one CVE and one repository to swarm.')
}
if (cells.length > MAX_SWARM_CELLS) {
throw new Error(
- `That is ${cells.length} cells (repos × CVEs). Trim to ${MAX_SWARM_CELLS} or fewer — each cell is its own sandbox.`,
+ `That is ${cells.length} CVEs. Pick ${MAX_SWARM_CELLS} or fewer — each CVE is its own sandbox.`,
)
}
// The deploy runs in the background from the moment GitHub connects. If the
@@ -689,12 +694,37 @@ function PayloadBuilder({
const [loginUsername, setLoginUsername] = useState('')
const [loginPassword, setLoginPassword] = useState('')
const [repositories, setRepositories] = useState<string[]>([])
- // Prefill every CVE in this week's feed so a first swarm runs with no typing.
- const [cveIds, setCveIds] = useState<string[]>(() =>
- SEED_CVES.map((c) => c.id),
- )
+ const [cveIds, setCveIds] = useState<string[]>([])
const [preview, setPreview] = useState<string | null>(null)
+ // The live, severity-sorted CVE feed. We pull a generous slice (worst first)
+ // and let the operator pick the top N to swarm. cve.now sends CORS `*`, so the
+ // browser fetches it directly — no backend proxy.
+ const liveCves = useQuery({
+ queryKey: ['swarm-live-cves'],
+ queryFn: ({ signal }) => fetchLiveCves(50, signal),
+ staleTime: 5 * 60_000,
+ retry: 1,
+ })
+ const feed = useMemo(() => liveCves.data ?? [], [liveCves.data])
+
+ // Preselect the top N by severity the first time the feed lands, so a first
+ // swarm runs with no typing. One-shot: once defaulted (or the operator edits)
+ // we leave the selection alone.
+ const cvesDefaultedRef = useRef(false)
+ useEffect(() => {
+ if (cvesDefaultedRef.current || feed.length === 0) return
+ cvesDefaultedRef.current = true
+ const n = Math.min(DEFAULT_TOP_N, feed.length, MAX_SWARM_CELLS)
+ setCveIds(feed.slice(0, n).map((c) => c.id))
+ }, [feed])
+
+ // Replace the selection with the top N of the live feed (severity-sorted).
+ const pickTopN = (n: number) => {
+ const clamped = Math.max(0, Math.min(n, feed.length))
+ setCveIds(feed.slice(0, clamped).map((c) => c.id))
+ }
+
// A login needs both a username and a password; the URL is optional (the cell
// can find the login page itself). Only then is the scan authenticated.
const authenticated = loginUsername.trim() !== '' && loginPassword !== ''
@@ -737,11 +767,13 @@ function PayloadBuilder({
// unauthenticated, so block the launch until both fields are set or both empty.
const loginComplete =
(loginUsername.trim() === '') === (loginPassword === '')
- // Each cell is one sandbox, so a repository × CVE matrix past the cap is a
- // launch we won't start — surface it before the click, not on it.
- const cellCount = repositories.length * cveIds.length
+ // One agent per picked CVE — so the cell count is just the CVEs. Each cell is
+ // its own sandbox, so a pick past the cap is a launch we won't start; surface
+ // it before the click, not on it.
+ const cellCount = cveIds.length
const overCap = cellCount > MAX_SWARM_CELLS
- // Fan-out needs explicit repositories: one session per repository × CVE cell.
+ // A swarm needs at least one CVE to hunt and at least one repo as shared
+ // evidence for every cell to investigate against.
const ready =
declaration &&
cveIds.length > 0 &&
@@ -813,7 +845,7 @@ function PayloadBuilder({
<Field
label="Repositories"
- hint="Every repo from your GitHub install, selected by default. Each repository is checked against each CVE as its own parallel cell."
+ hint="Every repo from your GitHub install, selected by default. These are shared evidence — every CVE agent gets all of them cloned to investigate the target against."
>
<RepoPicker
available={availableRepos}
@@ -824,40 +856,19 @@ function PayloadBuilder({
</Field>
<Field
- label="CVEs"
- hint="This week's feed, pre-selected. Trim to focus a run."
+ label="CVEs to swarm"
+ hint="This week's feed, newest and most severe first. Pick the top N by severity — one agent hunts each — or fine-tune the list below."
>
- <div className="grid gap-1.5 sm:grid-cols-2">
- {SEED_CVES.map((cve) => {
- const checked = cveIds.includes(cve.id)
- return (
- <label
- key={cve.id}
- htmlFor={`cve-${cve.id}`}
- className="hover:bg-muted/50 flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2 text-sm"
- >
- <Checkbox
- id={`cve-${cve.id}`}
- checked={checked}
- onCheckedChange={(value) =>
- setCveIds((current) =>
- value
- ? [...current, cve.id]
- : current.filter((id) => id !== cve.id),
- )
- }
- className="mt-0.5"
- />
- <span className="min-w-0">
- <span className="block font-mono text-xs">{cve.id}</span>
- <span className="text-muted-foreground block truncate">
- {cve.product} · {cve.severity} {cve.cvss.toFixed(1)}
- </span>
- </span>
- </label>
- )
- })}
- </div>
+ <CvePicker
+ feed={feed}
+ loading={liveCves.isLoading}
+ error={liveCves.isError}
+ onRetry={() => void liveCves.refetch()}
+ selected={cveIds}
+ onChange={setCveIds}
+ onPickTopN={pickTopN}
+ maxCells={MAX_SWARM_CELLS}
+ />
</Field>
<Field label="Model">
@@ -897,17 +908,17 @@ function PayloadBuilder({
>
Preview payload
</Button>
- {repositories.length > 0 && cveIds.length > 0 ? (
+ {cveIds.length > 0 ? (
<span
className={cn(
'text-xs',
overCap ? 'text-destructive' : 'text-muted-foreground',
)}
>
- {repositories.length} × {cveIds.length} = {cellCount} cell
- {cellCount === 1 ? '' : 's'}
+ {cellCount} agent{cellCount === 1 ? '' : 's'} ·{' '}
+ {repositories.length} repo{repositories.length === 1 ? '' : 's'} each
{overCap
- ? ` — over the ${MAX_SWARM_CELLS} limit, trim repositories or CVEs`
+ ? ` — over the ${MAX_SWARM_CELLS} limit, pick fewer CVEs`
: null}
</span>
) : null}
@@ -1069,6 +1080,173 @@ function RepoPicker({
)
}
+// The CVE band shown on each row, derived from the stated severity or, failing
+// that, the CVSS score. Drives the badge colour and label.
+function cveSeverityLabel(cve: FeedCve): { label: string; className: string } {
+ const band =
+ cve.statedSeverity?.toLowerCase() ??
+ (typeof cve.cvss === 'number'
+ ? cve.cvss >= 9
+ ? 'critical'
+ : cve.cvss >= 7
+ ? 'high'
+ : cve.cvss >= 4
+ ? 'medium'
+ : 'low'
+ : null)
+ switch (band) {
+ case 'critical':
+ return { label: 'Critical', className: 'text-destructive' }
+ case 'high':
+ return { label: 'High', className: 'text-destructive/80' }
+ case 'medium':
+ return { label: 'Medium', className: 'text-muted-foreground' }
+ case 'low':
+ return { label: 'Low', className: 'text-muted-foreground/70' }
+ default:
+ return { label: 'Unscored', className: 'text-muted-foreground/70' }
+ }
+}
+
+// The live-CVE picker: pick the top N by severity in one move, or toggle rows to
+// fine-tune. The feed arrives severity-sorted (worst first), so "top N" is just
+// the first N. Rows past the cap are disabled unless already selected.
+function CvePicker({
+ feed,
+ loading,
+ error,
+ onRetry,
+ selected,
+ onChange,
+ onPickTopN,
+ maxCells,
+}: {
+ feed: FeedCve[]
+ loading: boolean
+ error: boolean
+ onRetry: () => void
+ selected: string[]
+ onChange: (ids: string[]) => void
+ onPickTopN: (n: number) => void
+ maxCells: number
+}) {
+ const [topN, setTopN] = useState(DEFAULT_TOP_N)
+
+ if (loading) {
+ return (
+ <div className="text-muted-foreground inline-flex items-center gap-2 text-sm">
+ <Loader2 className="size-4 animate-spin" />
+ Loading this week's CVE feed…
+ </div>
+ )
+ }
+ if (error || feed.length === 0) {
+ return (
+ <div className="flex items-center gap-3 text-sm">
+ <span className="text-destructive">
+ {error ? "Couldn't load the live CVE feed." : 'No CVEs in the feed right now.'}
+ </span>
+ <button
+ type="button"
+ onClick={onRetry}
+ className="text-foreground underline underline-offset-4"
+ >
+ Retry
+ </button>
+ </div>
+ )
+ }
+
+ const cap = Math.min(maxCells, feed.length)
+ return (
+ <div className="space-y-3">
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-muted-foreground text-xs">Pick the top</span>
+ <Input
+ type="number"
+ min={1}
+ max={cap}
+ value={topN}
+ onChange={(e) => setTopN(Number(e.target.value))}
+ className="w-20"
+ />
+ <span className="text-muted-foreground text-xs">by severity</span>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onPickTopN(Math.max(1, Math.min(topN, cap)))}
+ >
+ Select top {Math.max(1, Math.min(topN, cap))}
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={() => onChange([])}
+ disabled={selected.length === 0}
+ >
+ Clear
+ </Button>
+ <span className="text-muted-foreground ml-auto text-xs">
+ {selected.length} of {feed.length} selected
+ </span>
+ </div>
+
+ <div className="grid max-h-80 gap-1.5 overflow-auto sm:grid-cols-2">
+ {feed.map((cve) => {
+ const checked = selected.includes(cve.id)
+ const sev = cveSeverityLabel(cve)
+ const atCap = !checked && selected.length >= maxCells
+ return (
+ <label
+ key={cve.id}
+ htmlFor={`cve-${cve.id}`}
+ className={cn(
+ 'flex items-start gap-2.5 rounded-md border px-3 py-2 text-sm',
+ atCap
+ ? 'cursor-not-allowed opacity-50'
+ : 'hover:bg-muted/50 cursor-pointer',
+ )}
+ >
+ <Checkbox
+ id={`cve-${cve.id}`}
+ checked={checked}
+ disabled={atCap}
+ onCheckedChange={(value) =>
+ onChange(
+ value
+ ? [...selected, cve.id]
+ : selected.filter((id) => id !== cve.id),
+ )
+ }
+ className="mt-0.5"
+ />
+ <span className="min-w-0 flex-1">
+ <span className="flex items-center gap-2">
+ <span className="font-mono text-xs">{cve.id}</span>
+ {cve.kev ? (
+ <span className="text-destructive text-[10px] font-semibold uppercase">
+ KEV
+ </span>
+ ) : null}
+ </span>
+ <span className="text-muted-foreground block truncate">
+ {cve.title}
+ </span>
+ <span className={cn('block text-xs', sev.className)}>
+ {sev.label}
+ {typeof cve.cvss === 'number' ? ` · ${cve.cvss.toFixed(1)}` : ''}
+ </span>
+ </span>
+ </label>
+ )
+ })}
+ </div>
+ </div>
+ )
+}
+
function Field({
label,
hint,
diff --git a/web/src/managed-agents/security/SwarmGrid.tsx b/web/src/managed-agents/security/SwarmGrid.tsx
index 3007b120..7da1dfeb 100644
--- a/web/src/managed-agents/security/SwarmGrid.tsx
+++ b/web/src/managed-agents/security/SwarmGrid.tsx
@@ -141,11 +141,7 @@ export function RunReportCard({
) : (
<ul className="divide-y">
{actionable.map((c) => (
- <ReportRow
- key={`${c.repository}__${c.cveId}`}
- cell={c}
- projectId={projectId}
- />
+ <ReportRow key={c.cveId} cell={c} projectId={projectId} />
))}
</ul>
)}
@@ -175,10 +171,7 @@ function ReportRow({
{meta.label}
</span>
<div className="min-w-0 flex-1">
- <div className="font-mono text-xs">
- {cell.repository}{' '}
- <span className="text-muted-foreground">· {cell.cveId}</span>
- </div>
+ <div className="font-mono text-xs">{cell.cveId}</div>
{cell.reasoning ? (
<p className="text-muted-foreground mt-1 line-clamp-2 text-xs leading-5">
{cell.reasoning}
@@ -242,18 +235,17 @@ function CellTile({
projectId: string
}) {
const phase = cellPhase(state)
- const [owner, name] = state.cell.repository.split('/')
+ const repoCount = state.cell.repositories.length
return (
<div className="rounded-lg border p-3">
<div className="flex items-start justify-between gap-2">
<div className="min-w-0">
- <div className="truncate font-mono text-xs">
- <span className="text-muted-foreground">{owner}/</span>
- {name}
- </div>
- <div className="text-muted-foreground mt-0.5 font-mono text-xs">
- {state.cell.cveId}
- </div>
+ <div className="truncate font-mono text-xs">{state.cell.cveId}</div>
+ {repoCount > 0 ? (
+ <div className="text-muted-foreground mt-0.5 text-xs">
+ {repoCount} repo{repoCount === 1 ? '' : 's'} as evidence
+ </div>
+ ) : null}
</div>
<CellBadge state={state} phase={phase} />
</div>
diff --git a/web/src/managed-agents/security/SwarmPanels.tsx b/web/src/managed-agents/security/SwarmPanels.tsx
index 0fbaf470..8dfcfcd9 100644
--- a/web/src/managed-agents/security/SwarmPanels.tsx
+++ b/web/src/managed-agents/security/SwarmPanels.tsx
@@ -118,10 +118,7 @@ export function FindingsPanel({
{reportable.map((s) => {
const status = cellStatus(s)
return (
- <li
- key={`${s.cell.repository}__${s.cell.cveId}`}
- className="px-4 py-2.5 font-mono text-xs"
- >
+ <li key={s.cell.cveId} className="px-4 py-2.5 font-mono text-xs">
<div className="flex items-center justify-between gap-2">
<span
className="font-bold uppercase tracking-wide"
@@ -142,8 +139,7 @@ export function FindingsPanel({
) : null}
</div>
<div className="mt-1" style={{ color: PALETTE.text }}>
- {s.cell.cveId}{' '}
- <span style={{ color: PALETTE.ink }}>· {s.cell.repository}</span>
+ {s.cell.cveId}
</div>
{s.sessionId ? (
<Link
@@ -192,7 +188,7 @@ export function CellDispatchPanel({
<div className="flex items-center gap-3 px-4 py-2 font-mono text-xs">
<span style={{ color: PALETTE.ink }}>{label}</span>
<span className="min-w-0 flex-1 truncate" style={{ color: PALETTE.text }}>
- {s.cell.repository}
+ {s.cell.cveId}
</span>
<span
className="shrink-0 font-bold uppercase tracking-wide"
@@ -203,7 +199,7 @@ export function CellDispatchPanel({
</div>
)
return (
- <li key={`${s.cell.repository}__${s.cell.cveId}`}>
+ <li key={s.cell.cveId}>
{s.sessionId ? (
<Link
to={`/projects/${encodeURIComponent(projectId)}/sessions/${encodeURIComponent(s.sessionId)}`}
diff --git a/web/src/managed-agents/security/catalog.test.ts b/web/src/managed-agents/security/catalog.test.ts
index ec1ecb1b..1aed1d7c 100644
--- a/web/src/managed-agents/security/catalog.test.ts
+++ b/web/src/managed-agents/security/catalog.test.ts
@@ -26,44 +26,53 @@ const payload: SwarmPayload = {
}
describe('swarm fan-out', () => {
- it('expands the repository × CVE matrix into one cell per pair', () => {
+ it('expands into one cell per CVE, every repo shared as evidence', () => {
expect(swarmCells(payload)).toEqual([
- { repository: 'acme/web', cveId: 'CVE-2026-1' },
- { repository: 'acme/web', cveId: 'CVE-2026-2' },
- { repository: 'acme/api', cveId: 'CVE-2026-1' },
- { repository: 'acme/api', cveId: 'CVE-2026-2' },
+ { cveId: 'CVE-2026-1', repositories: ['acme/web', 'acme/api'] },
+ { cveId: 'CVE-2026-2', repositories: ['acme/web', 'acme/api'] },
])
})
- it('is empty when either dimension is empty', () => {
- expect(swarmCells({ ...payload, repositories: [] })).toEqual([])
+ it('is empty only when there are no CVEs to hunt', () => {
expect(swarmCells({ ...payload, cveIds: [] })).toEqual([])
+ // No repos is still a swarm — the CVEs just have no evidence to lean on.
+ expect(swarmCells({ ...payload, repositories: [] })).toEqual([
+ { cveId: 'CVE-2026-1', repositories: [] },
+ { cveId: 'CVE-2026-2', repositories: [] },
+ ])
})
- it('builds a stable, slash-free document id unique per cell', () => {
+ it('builds a stable, slash-free document id unique per CVE', () => {
const run = 'run-abc'
- const first = cellDocumentId(run, { repository: 'acme/web', cveId: 'CVE-2026-1' })
- const second = cellDocumentId(run, { repository: 'acme/api', cveId: 'CVE-2026-1' })
- expect(first).toBe('run-abc__acme-web__cve-2026-1')
+ const first = cellDocumentId(run, {
+ cveId: 'CVE-2026-1',
+ repositories: ['acme/web'],
+ })
+ const second = cellDocumentId(run, {
+ cveId: 'CVE-2026-2',
+ repositories: ['acme/api'],
+ })
+ expect(first).toBe('run-abc__cve-2026-1')
expect(first).not.toContain('/')
expect(first).not.toBe(second)
})
- it('narrows the prompt to a single repository and CVE seed', () => {
+ it('names the cell CVE and every repo as shared evidence', () => {
const prompt = composeCellPrompt(payload, {
- repository: 'acme/web',
cveId: 'CVE-2026-1',
+ repositories: ['acme/web', 'acme/api'],
})
- expect(prompt).toContain('Repository: acme/web')
- expect(prompt).toContain('CVE seed: CVE-2026-1')
+ expect(prompt).toContain('Your CVE to hunt: CVE-2026-1')
+ expect(prompt).toContain('acme/web')
+ // Every repo is shared evidence now, not a per-cell narrowing.
+ expect(prompt).toContain('acme/api')
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',
+ repositories: ['acme/web'],
})
expect(prompt).toContain('cve.now')
expect(prompt).toContain('pwn.watch')
@@ -78,16 +87,16 @@ describe('swarm fan-out', () => {
it('drops target-only discovery steps when no target is given', () => {
const prompt = composeCellPrompt(
{ ...payload, target: '' },
- { repository: 'acme/web', cveId: 'CVE-2026-1' },
+ { cveId: 'CVE-2026-1', repositories: ['acme/web'] },
)
expect(prompt).not.toContain('scan_surface')
- expect(prompt).toContain('reachable in this code')
+ expect(prompt).toContain('reachable in your code')
})
it('tells the cell to log in when the scan is authenticated', () => {
const prompt = composeCellPrompt(
{ ...payload, authenticated: true, loginUrl: 'https://app.example.com/login' },
- { repository: 'acme/web', cveId: 'CVE-2026-1' },
+ { cveId: 'CVE-2026-1', repositories: ['acme/web'] },
)
// Reads the creds from the environment, never carries them.
expect(prompt).toContain('SWARM_LOGIN_USERNAME')
@@ -98,8 +107,8 @@ describe('swarm fan-out', () => {
it('says nothing about logging in for an unauthenticated scan', () => {
const prompt = composeCellPrompt(payload, {
- repository: 'acme/web',
cveId: 'CVE-2026-1',
+ repositories: ['acme/web'],
})
expect(prompt).not.toContain('SWARM_LOGIN_USERNAME')
expect(prompt).not.toContain('log in')
@@ -156,12 +165,12 @@ describe('run manifest', () => {
target: 'https://app.example.com',
cells: [
{
- cell: { repository: 'acme/web', cveId: 'CVE-2026-1' },
+ cell: { cveId: 'CVE-2026-1', repositories: ['acme/web', 'acme/api'] },
sessionId: 's1',
launch: 'started',
},
{
- cell: { repository: 'acme/api', cveId: 'CVE-2026-1' },
+ cell: { cveId: 'CVE-2026-2', repositories: ['acme/web', 'acme/api'] },
sessionId: 's2',
launch: 'started',
},
@@ -171,7 +180,10 @@ describe('run manifest', () => {
it('keeps the manifest document clear of cell findings documents', () => {
expect(runManifestDocumentId('run-abc')).toBe('manifest__run-abc')
expect(runManifestDocumentId('run-abc')).not.toBe(
- cellDocumentId('run-abc', { repository: 'acme/web', cveId: 'CVE-2026-1' }),
+ cellDocumentId('run-abc', {
+ cveId: 'CVE-2026-1',
+ repositories: ['acme/web'],
+ }),
)
})
@@ -257,16 +269,15 @@ describe('run manifest', () => {
describe('run report', () => {
const cells: ReportCell[] = [
- { repository: 'acme/web', cveId: 'CVE-2026-9', disposition: 'not-exposed' },
+ { cveId: 'CVE-2026-9', disposition: 'not-exposed' },
{
- repository: 'acme/api',
cveId: 'CVE-2026-2',
disposition: 'exposed',
reasoning: 'vulnerable version in lockfile',
pullRequest: 'https://github.com/acme/api/pull/7',
},
- { repository: 'acme/db', cveId: 'CVE-2026-5', disposition: 'failed' },
- { repository: 'acme/ui', cveId: 'CVE-2026-3', disposition: 'needs-review' },
+ { cveId: 'CVE-2026-5', disposition: 'failed' },
+ { cveId: 'CVE-2026-3', disposition: 'needs-review' },
]
const meta = {
runId: 'run-abc',
diff --git a/web/src/managed-agents/security/catalog.ts b/web/src/managed-agents/security/catalog.ts
index 921708ec..bdd55632 100644
--- a/web/src/managed-agents/security/catalog.ts
+++ b/web/src/managed-agents/security/catalog.ts
@@ -23,55 +23,6 @@ export const SECURITY_FINDINGS_RESOURCE = 'cve-findings'
export const SCAN_DECLARATION =
'I declare that I own this web application and I am authorized to perform this penetration test.'
-export type SeedCve = {
- readonly id: string
- readonly product: string
- readonly severity: 'critical' | 'high' | 'medium' | 'low'
- readonly cvss: number
-}
-
-// This week's feed, mirroring the launch page and the template's feed.ts. The
-// payload builder opens with all of these pre-selected so a first swarm runs
-// with zero typing.
-export const SEED_CVES: readonly SeedCve[] = [
- {
- id: 'CVE-2026-109618',
- product: 'PHP2Shell',
- severity: 'critical',
- cvss: 9.8,
- },
- {
- id: 'CVE-2026-110264',
- product: 'GitLab CE/EE',
- severity: 'critical',
- cvss: 9.6,
- },
- {
- id: 'CVE-2026-96951',
- product: 'Windows Shell',
- severity: 'high',
- cvss: 8.1,
- },
- {
- id: 'CVE-2026-21445',
- product: 'Oracle Access Manager',
- severity: 'critical',
- cvss: 10.0,
- },
- {
- id: 'CVE-2026-21446',
- product: 'Oracle SOA Suite',
- severity: 'critical',
- cvss: 10.0,
- },
- {
- id: 'CVE-2026-21447',
- product: 'Oracle E-Business Suite',
- severity: 'critical',
- cvss: 10.0,
- },
-]
-
export type SwarmPayload = {
readonly target: string
readonly declarationAccepted: boolean
@@ -94,13 +45,14 @@ export type SwarmPayload = {
export const SWARM_LOGIN_USERNAME_VAR = 'SWARM_LOGIN_USERNAME'
export const SWARM_LOGIN_PASSWORD_VAR = 'SWARM_LOGIN_PASSWORD'
-// A single unit of swarm work: one repository checked against one CVE. The
-// launch fans the payload's repository × CVE matrix into one cell per pair, and
-// starts one bound session for each so they run in parallel and each writes its
-// own findings document.
+// A single unit of swarm work: one agent hunting one CVE against the target,
+// with every connected repository available to it as evidence. The launch starts
+// one bound session per CVE so they run in parallel and each writes its own
+// findings document. Repos are shared context, not a fan-out dimension — a cell
+// carries the full list, not a single repo.
export type SwarmCell = {
- readonly repository: string
readonly cveId: string
+ readonly repositories: readonly string[]
}
// Where a cell is in the launch itself, before any agent work. The launch writes
@@ -120,18 +72,16 @@ export type LaunchedCell = {
readonly launch: CellLaunchStatus
}
-// Expand the payload into the matrix of cells. Fan-out needs explicit
-// repositories and CVEs — the "all connected repositories" / "full feed"
-// shorthands only make sense for the single-session controller, so a caller
-// that means to fan out must resolve those to concrete lists first.
+// One cell per CVE, each carrying all the repos as shared evidence. Fan-out needs
+// an explicit CVE list — the "full feed" shorthand only makes sense for the
+// single-session controller, so a caller that means to fan out must resolve it to
+// a concrete list first. Repos ride along as context and no longer multiply the
+// count, so the cell total is exactly the number of CVEs.
export function swarmCells(payload: SwarmPayload): SwarmCell[] {
- const cells: SwarmCell[] = []
- for (const repository of payload.repositories) {
- for (const cveId of payload.cveIds) {
- cells.push({ repository, cveId })
- }
- }
- return cells
+ return payload.cveIds.map((cveId) => ({
+ cveId,
+ repositories: payload.repositories,
+ }))
}
// Reduce a free-form identifier to the characters a memory document id and a
@@ -148,14 +98,14 @@ function slug(value: string): string {
// this document read-write and saves the one finding it proves; the reducer
// reads them all back as a collection.
export function cellDocumentId(runId: string, cell: SwarmCell): string {
- return `${runId}__${slug(cell.repository)}__${slug(cell.cveId)}`
+ return `${runId}__${slug(cell.cveId)}`
}
// The launch records what it started as a run manifest, persisted as its own
// document under the findings resource so the swarm page can rebuild the grid
// after navigation or a reload (the session ids live in the manifest, not in
// React state). The `manifest__` prefix keeps it clear of the cell findings
-// documents, whose ids are `<runId>__<repo>__<cve>`.
+// documents, whose ids are `<runId>__<cve>`.
export const SWARM_MANIFEST_PREFIX = 'manifest__'
export function runManifestDocumentId(runId: string): string {
@@ -191,14 +141,16 @@ export function parseRunManifest(text: string): SwarmRunManifest | null {
if (!entry || typeof entry !== 'object') return null
const e = entry as Record<string, unknown>
const cell = e.cell as Record<string, unknown> | undefined
- if (
- !cell ||
- typeof cell.repository !== 'string' ||
- typeof cell.cveId !== 'string' ||
- typeof e.sessionId !== 'string'
- ) {
+ if (!cell || typeof cell.cveId !== 'string' || typeof e.sessionId !== 'string') {
return null
}
+ // Repos are shared context on the cell. Back-compat: a manifest from the old
+ // repo×CVE model carried a single `repository` string instead of a list.
+ const repositories = Array.isArray(cell.repositories)
+ ? cell.repositories.filter((r): r is string => typeof r === 'string')
+ : typeof cell.repository === 'string'
+ ? [cell.repository]
+ : []
// Back-compat: a manifest written before incremental launch has no `launch`
// field — a cell there with a session id is already `started`.
const launch: CellLaunchStatus =
@@ -208,7 +160,7 @@ export function parseRunManifest(text: string): SwarmRunManifest | null {
? 'started'
: 'starting'
cells.push({
- cell: { repository: cell.repository, cveId: cell.cveId },
+ cell: { cveId: cell.cveId, repositories },
sessionId: e.sessionId,
launch,
})
@@ -257,12 +209,12 @@ export function listManifestDocs(
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.',
+ 'Read the repository clones to prove whether this CVE is reachable in your 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.',
+ '- Read the repository clones to derive their 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.`,
'- A headless Chromium is preinstalled in the sandbox: `npm i playwright` (the browser is already downloaded), then drive it to load pages, reach client-side routes and capture screenshots.',
'- Record evidence into /workspace as you go (request/response logs, screenshots, a finding.md) so the proof outlives the session.',
@@ -270,11 +222,10 @@ export function discoveryLines(target: string): string[] {
]
}
-// 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.
+// One cell's first-run input. Each cell owns one CVE and hunts it against the
+// target with every connected repository available as evidence: pull live feed
+// intelligence, derive the repos' routes, probe the attested target, and keep
+// evidence.
// When the operator supplied a throwaway test account, tell the cell to log in
// first and scan behind the auth wall. The credentials themselves are NOT here —
// they are in the environment as encrypted runtime variables; the prompt only
@@ -298,8 +249,10 @@ export function composeCellPrompt(payload: SwarmPayload, cell: SwarmCell): strin
payload.target
? `Target (authorized discovery within this host only): ${payload.target}`
: null,
- `Repository: ${cell.repository}`,
- `CVE seed: ${cell.cveId}`,
+ `Your CVE to hunt: ${cell.cveId}`,
+ cell.repositories.length > 0
+ ? `Repositories available as evidence (investigate across all of them): ${cell.repositories.join(', ')}`
+ : null,
`Model: ${payload.model}`,
'',
...feedSeedingLines(),
@@ -358,7 +311,7 @@ export function parseCellFinding(text: string): CellFinding | null {
// cells already saved (Tier 1 — no reducer agent), then persisted as its own
// document so a scheduled run leaves something behind and the aggregator view
// has a real source. The `report__` prefix keeps it clear of manifests
-// (`manifest__`) and cell findings (`<runId>__<repo>__<cve>`).
+// (`manifest__`) and cell findings (`<runId>__<cve>`).
export const SWARM_REPORT_PREFIX = 'report__'
export function runReportDocumentId(runId: string): string {
@@ -370,7 +323,6 @@ export function runReportDocumentId(runId: string): string {
export type ReportDisposition = CveDisposition | 'failed'
export type ReportCell = {
- readonly repository: string
readonly cveId: string
readonly disposition: ReportDisposition
readonly reasoning?: string
@@ -423,7 +375,6 @@ export function buildRunReport(
const sorted = [...cells].sort(
(a, b) =>
REPORT_ORDER[a.disposition] - REPORT_ORDER[b.disposition] ||
- a.repository.localeCompare(b.repository) ||
a.cveId.localeCompare(b.cveId),
)
return { ...meta, counts, cells: sorted }
@@ -458,7 +409,6 @@ export function parseRunReport(text: string): SwarmRunReport | null {
if (!entry || typeof entry !== 'object') return null
const e = entry as Record<string, unknown>
if (
- typeof e.repository !== 'string' ||
typeof e.cveId !== 'string' ||
typeof e.disposition !== 'string' ||
!REPORT_DISPOSITIONS.includes(e.disposition as ReportDisposition)
@@ -466,7 +416,6 @@ export function parseRunReport(text: string): SwarmRunReport | null {
return null
}
cells.push({
- repository: e.repository,
cveId: e.cveId,
disposition: e.disposition as ReportDisposition,
...(typeof e.reasoning === 'string' ? { reasoning: e.reasoning } : {}),
diff --git a/web/src/managed-agents/security/feeds.ts b/web/src/managed-agents/security/feeds.ts
index e98ac604..52c12288 100644
--- a/web/src/managed-agents/security/feeds.ts
+++ b/web/src/managed-agents/security/feeds.ts
@@ -54,9 +54,84 @@ export const PWN_WATCH: VulnerabilityFeed = {
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.
+// to pull the current feed slice for its angle, and the onboarding UI fetches it
+// directly to present a live, severity-sorted list to pick from (the endpoint
+// sends `access-control-allow-origin: *`, so the browser can call it).
export const CVE_NOW_ENTRIES_API = 'https://cve.now/api/v1/entries'
+// One entry from the cve.now entries API, as the swarm consumes it. The upstream
+// shape is wider; we read only the fields that drive severity ranking and the
+// picker label.
+export type FeedCve = {
+ readonly id: string
+ readonly title: string
+ // CVSS base score 0–10 when the entry carries one, else null.
+ readonly cvss: number | null
+ // Qualitative band as stated upstream: 'low' | 'medium' | 'high' | 'critical'
+ // (or null when unscored). Kept as the raw string; `severityRank` normalises.
+ readonly statedSeverity: string | null
+ // CISA Known-Exploited flag — the strongest "fix this now" signal there is.
+ readonly kev: boolean
+ // ISO timestamp the entry was first seen, newest-first in the feed.
+ readonly firstSeenAt: string | null
+}
+
+// The qualitative bands, worst first, as a lookup for ranking and display.
+const SEVERITY_BUCKET: Record<string, number> = {
+ critical: 3,
+ high: 2,
+ medium: 1,
+ low: 0,
+}
+
+// A single comparable score so the picker can sort worst-first with one key.
+// KEV dominates (a known-exploited CVE outranks anything not on the list),
+// then CVSS, then the stated band as a tiebreak when CVSS is missing. Higher is
+// more severe.
+export function severityRank(cve: FeedCve): number {
+ const kev = cve.kev ? 1000 : 0
+ const cvss = typeof cve.cvss === 'number' ? cve.cvss * 10 : 0
+ const bucket = cve.statedSeverity
+ ? (SEVERITY_BUCKET[cve.statedSeverity.toLowerCase()] ?? 0)
+ : 0
+ return kev + cvss + bucket
+}
+
+// Fetch the current cve.now feed slice and return it severity-sorted (worst
+// first), ready for the onboarding top-N picker. `limit` caps how many raw
+// entries we pull before ranking; the caller slices to the chosen N. Throws on a
+// non-OK response or a malformed body so the UI can show a retry.
+export async function fetchLiveCves(
+ limit = 50,
+ signal?: AbortSignal,
+): Promise<FeedCve[]> {
+ const url = `${CVE_NOW_ENTRIES_API}?limit=${encodeURIComponent(String(limit))}`
+ const res = await fetch(url, { signal, headers: { accept: 'application/json' } })
+ if (!res.ok) {
+ throw new Error(`cve.now feed responded ${res.status}`)
+ }
+ const body: unknown = await res.json()
+ const entries =
+ body && typeof body === 'object' && Array.isArray((body as { entries?: unknown }).entries)
+ ? ((body as { entries: unknown[] }).entries)
+ : []
+ const cves: FeedCve[] = []
+ for (const raw of entries) {
+ if (!raw || typeof raw !== 'object') continue
+ const e = raw as Record<string, unknown>
+ if (typeof e.id !== 'string' || e.id.length === 0) continue
+ cves.push({
+ id: e.id,
+ title: typeof e.title === 'string' ? e.title : e.id,
+ cvss: typeof e.cvss === 'number' ? e.cvss : null,
+ statedSeverity: typeof e.statedSeverity === 'string' ? e.statedSeverity : null,
+ kev: e.kev === true,
+ firstSeenAt: typeof e.firstSeenAt === 'string' ? e.firstSeenAt : null,
+ })
+ }
+ return cves.sort((a, b) => severityRank(b) - severityRank(a))
+}
+
// 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.
diff --git a/web/src/managed-agents/security/useSwarmRun.ts b/web/src/managed-agents/security/useSwarmRun.ts
index 7227272e..c036690d 100644
--- a/web/src/managed-agents/security/useSwarmRun.ts
+++ b/web/src/managed-agents/security/useSwarmRun.ts
@@ -131,8 +131,11 @@ export function statesFromReport(report: SwarmRunReport): {
states: CellState[]
counts: SwarmCounts
} {
+ // Repositories are shared across all cells (not stored per-cell in the report),
+ // so a run rebuilt from its report carries an empty repo list — the views key
+ // off the CVE, not the repos.
const states: CellState[] = report.cells.map((c) => ({
- cell: { repository: c.repository, cveId: c.cveId },
+ cell: { cveId: c.cveId, repositories: [] },
sessionId: c.sessionId ?? '',
launch: c.disposition === 'failed' ? 'failed' : 'started',
finding:
@@ -270,7 +273,6 @@ export function useSwarmRun({
? s.finding.disposition
: 'failed'
return {
- repository: s.cell.repository,
cveId: s.cell.cveId,
disposition,
sessionId: s.sessionId,