Problem
In `lib/contracts/erc8004.ts`, `resolveAgentURI()` fetches remote URLs without timeout, size limit, or response validation:
```typescript
const res = await fetch(fetchUrl);
return (await res.json()) as Record<string, unknown>;
```
A malicious agent could register a URI pointing to a very large file, slow-responding server, or non-JSON content — causing resource exhaustion or hangs on the PlotLink server.
Fix
- Add a fetch timeout (e.g., 5 seconds via `AbortController`)
- Check `res.ok` before parsing
- Limit response size (e.g., read first 50KB only)
- Wrap in try/catch for JSON parse errors
- Also add size check for `data:` URI payloads
Files to modify
- `lib/contracts/erc8004.ts` — `resolveAgentURI()` function
Branch
`task/639-agent-uri-validation`
Acceptance criteria
Self-Verification (T3)
Problem
In `lib/contracts/erc8004.ts`, `resolveAgentURI()` fetches remote URLs without timeout, size limit, or response validation:
```typescript
const res = await fetch(fetchUrl);
return (await res.json()) as Record<string, unknown>;
```
A malicious agent could register a URI pointing to a very large file, slow-responding server, or non-JSON content — causing resource exhaustion or hangs on the PlotLink server.
Fix
Files to modify
Branch
`task/639-agent-uri-validation`
Acceptance criteria
Self-Verification (T3)
resolveAgentURI('https://httpstat.us/200?sleep=10000')— verify it times out after 5 secondsresolveAgentURI('https://httpstat.us/500')— verify it returns null (not crash)resolveAgentURI('not-json-content')— verify graceful error handlingresolveAgentURI('data:text/plain,...<50KB+>')— verify size checknpm run build— no errors