Repository navigation
Release 2.27.0: video with sound, Lightning docs, fixes - #2139
Conversation
The shared hedged lookup asks the public resolvers when the host's fails, names the failed query in node's words, and each caller-named DNS tool declares the zone its example looks up. The MPP market rail note is prose.
|
@strix-security review |
Strix Security ReviewTo fix before merging (7)
PR summary: Release 2.27.0 adds video clips with sound and fixed-price clip routes, https picture inputs with per-hop robots checks, a connector credits-balance tool, a Lightning docs page, smaller 402 responses, a retrying DNS resolver that answers 503 instead of billing a failed lookup, and refreshed client/MCP packages. Review summaryRe-review of Release 2.27.0 (video with sound, URL picture inputs, Lightning docs, DNS resolver rewrite, connector and credits changes). The only commit since the previous review touches five test scripts, so this pass focused on re-checking the earlier findings against the current tree and on the release's new surfaces. All six previously reported gaps are still present at their original locations: the pool render context still accepts downloads for caller-named pages (Pool page context accepts downloads), caller-supplied Ruled out (9)
Review history (6)
Fixed the findings? re-run the review, or tag Review 6 on this PR · Reviewed by Strix |
|
@strix-security review |
|
@strix-security review |
| if (input._editRefs) return input._editRefs; | ||
| const raw = input.images !== undefined ? input.images : input.image; |
There was a problem hiding this comment.
🟡 MEDIUM: Caller JSON can set the internal reference list and skip all reference checks
TL;DR: A paying caller can send more than four unchecked reference pictures on a flat $0.02 edit. editReferences hands back the caller's own _editRefs before it counts or reads anything. Reading references from one place, so every one passes the same checks, fixes it.
Cause, impact and fix
Cause: editReferences returns input._editRefs ahead of the count test and decodeReference, and that field lives on the very object the caller's JSON body is spread into, so a JSON body can write a field meant for the multipart reader.
Impact: The four-reference limit, the 6 MB cap, the PNG/JPEG header read and the new canvas caps never run on that path, so unbounded picture data is fetched and billed to the operator.
Fix: Stop short-circuiting on _editRefs: feed it through the same list as image/images so every reference is counted and passed to decodeReference, and add a test that a JSON body with _editRefs is refused like image.
🟡 Caller-supplied `_editRefs` in a JSON body skips every reference-image check on POST /v1/images/edits
Severity: MEDIUM
TL;DR: editReferences() returns input._editRefs verbatim, so a JSON body sent to POST /v1/images/edits skips the reference count, byte, header and canvas checks the same function applies to image.
Impact: Any paying caller can attach an arbitrary number of unchecked references, up to the 34 MB body, instead of the one to four validated PNG/JPEG pictures the route documents and prices, with the extra reference data billed to the operator.
Root cause:
- An internal-only field is read from the same object the caller's JSON body is spread into, so a caller can supply a value the code assumes only the multipart reader writes.
editReferences()returnsinput._editRefsbefore theIMAGE_EDIT_MAX_REFStest and beforedecodeReference(), so the 4-reference limit, the 6 MB cap, the PNG/JPEG header read, the 256 px minimum and this PR's new 12000 px side / 64 MP canvas caps never run on that path.- The handler forwards whatever survives as
input_referencesto the provider, so the flat $0.02 price no longer bounds what gets billed; the short-circuit predates this PR, but the PR reworks this function and puts its new caps behind it, where a JSON body cannot reach them.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: Caller-supplied `_editRefs` in a JSON body skips every reference-image check on POST /v1/images/edits
Severity: MEDIUM
CWE: CWE-472
**TL;DR:** `editReferences()` returns `input._editRefs` verbatim, so a JSON body sent to `POST /v1/images/edits` skips the reference count, byte, header and canvas checks the same function applies to `image`.
**Impact:** Any paying caller can attach an arbitrary number of unchecked references, up to the 34 MB body, instead of the one to four validated PNG/JPEG pictures the route documents and prices, with the extra reference data billed to the operator.
**Root cause:**
- An internal-only field is read from the same object the caller's JSON body is spread into, so a caller can supply a value the code assumes only the multipart reader writes.
- `editReferences()` returns `input._editRefs` before the `IMAGE_EDIT_MAX_REFS` test and before `decodeReference()`, so the 4-reference limit, the 6 MB cap, the PNG/JPEG header read, the 256 px minimum and this PR's new 12000 px side / 64 MP canvas caps never run on that path.
- The handler forwards whatever survives as `input_references` to the provider, so the flat $0.02 price no longer bounds what gets billed; the short-circuit predates this PR, but the PR reworks this function and puts its new caps behind it, where a JSON body cannot reach them.
Location: src/tools/llm-images-fast-kit.js:503-504
Context: primary: route the internal field through the same checks as `image`
```
// Before:
if (input._editRefs) return input._editRefs;
const raw = input.images !== undefined ? input.images : input.image;
// After:
// The multipart reader's references are no more privileged than the
// caller's: a JSON body can set `_editRefs` too, so it goes through the
// same count and byte checks as `image`.
const raw = input._editRefs !== undefined ? input._editRefs : input.images !== undefined ? input.images : input.image;
```
How to fix:
Treat the multipart reader's references as no more privileged than the caller's: read `_editRefs` into the same list as `image`/`images` so every entry goes through the count test and `decodeReference()` (or keep the internal refs off the merged input object entirely and hand them to `validateImageTierRequest` as a separate argument). Add a regression check that a JSON body carrying `_editRefs` is refused exactly like `image` when it is over the count, the byte cap or the canvas caps.
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
| async function resolveEditReferences(refs) { | ||
| if (!refs.some((r) => typeof r !== "string")) return refs; | ||
| // An unconfigured server fetches nothing (the upstream call's own check answers the same 503 later). | ||
| if (!OPENROUTER_KEY()) throw bad("LLM gateway not configured (OPENROUTER_API_KEY unset)", 503); | ||
| return Promise.all(refs.map((r, i) => (typeof r === "string" ? r : readPicture(r, editPictureOptions(refs.length > 1 ? `image ${i + 1}` : "image")).then((p) => p.dataUrl)))); | ||
| } |
There was a problem hiding this comment.
🟡 MEDIUM: Fetched reference pictures are never charged to the route's memory budget
TL;DR: Any caller who can pay the edit price can hold many requests whose reference URLs are fetched into memory. The route's in-flight budget counts only the few-hundred-byte JSON body it declares. Reserving the picture payload up front fixes it.
Cause, impact and fix
Cause: The large-body gate sizes a request's share from the declared body length, while the edit route now fetches up to four 6 MB pictures after the parse and keeps each as an 8 MB base64 data URL, so none of that memory is accounted for.
Impact: Concurrent edit requests pin gigabytes of heap in the shared Node process, slowing or crashing image generation for every other buyer.
Fix: Reserve the largest reference payload, four pictures at the 6 MB cap plus their base64 copies, against the in-flight budget when the request is admitted rather than from Content-Length, and cap how many picture-fetching requests one client key may hold at once.
🟡 Reference pictures fetched from caller URLs are held outside the large-body memory budget on /v1/images/edits
Severity: MEDIUM
TL;DR: The edit route now fetches up to four 6 MB reference pictures from caller-supplied URLs and keeps each as an 8 MB base64 data URL, while the large-body gate reserves only the few-hundred-byte JSON body, so nothing bounds concurrent picture memory.
Impact: Any caller able to settle the $0.02 edit price can hold many of these requests at once and pin gigabytes of the shared Node process's heap, slowing or crashing the server for every other buyer.
Root cause:
- The in-flight memory budget is sized from the declared request-body length alone, so bytes the handler derives after the parse (decoded pictures and their base64 copies) are never accounted for by the gate that is meant to bound this route's memory.
- This PR makes /v1/images/edits accept https picture URLs and fetch them after the body is parsed, so the reserved size is the tiny JSON body and the per-address share and 256 MB global cap admit unlimited concurrent picture fetches.
- pictureFromBytes re-encodes every accepted picture into a base64 data-URL string the handler holds for the whole generation; the copies measured about 4x the wire body, the same amplification the connector route already compensates for with reserveFactor 4.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: Reference pictures fetched from caller URLs are held outside the large-body memory budget on /v1/images/edits
Severity: MEDIUM
CWE: CWE-400
**TL;DR:** The edit route now fetches up to four 6 MB reference pictures from caller-supplied URLs and keeps each as an 8 MB base64 data URL, while the large-body gate reserves only the few-hundred-byte JSON body, so nothing bounds concurrent picture memory.
**Impact:** Any caller able to settle the $0.02 edit price can hold many of these requests at once and pin gigabytes of the shared Node process's heap, slowing or crashing the server for every other buyer.
**Root cause:**
- The in-flight memory budget is sized from the declared request-body length alone, so bytes the handler derives after the parse (decoded pictures and their base64 copies) are never accounted for by the gate that is meant to bound this route's memory.
- This PR makes /v1/images/edits accept https picture URLs and fetch them after the body is parsed, so the reserved size is the tiny JSON body and the per-address share and 256 MB global cap admit unlimited concurrent picture fetches.
- pictureFromBytes re-encodes every accepted picture into a base64 data-URL string the handler holds for the whole generation; the copies measured about 4x the wire body, the same amplification the connector route already compensates for with reserveFactor 4.
Location: src/server.js:4498-4498
Context: Route table: the edit route reserves only its declared body, factor defaults to 1
```
["/api/html-frames", 12 * MB], ["/v1/images/edits", 34 * MB], ["/api/image-animate", 9 * MB], ["/api/image-animate-clip", 9 * MB],
```
Location: src/tools/llm-images-fast-kit.js:512-517
Context: URL references fetched all at once with no reservation against the in-flight budget
```
async function resolveEditReferences(refs) {
if (!refs.some((r) => typeof r !== "string")) return refs;
// An unconfigured server fetches nothing (the upstream call's own check answers the same 503 later).
if (!OPENROUTER_KEY()) throw bad("LLM gateway not configured (OPENROUTER_API_KEY unset)", 503);
return Promise.all(refs.map((r, i) => (typeof r === "string" ? r : readPicture(r, editPictureOptions(refs.length > 1 ? `image ${i + 1}` : "image")).then((p) => p.dataUrl))));
}
```
Location: src/tools/picture-input.js:109-109
Context: Each picture copied again into a base64 data-URL string the caller keeps
```
return { dataUrl: `data:image/${format};base64,${buf.toString("base64")}`, format, width, height, bytes: buf.length, digest: createHash("sha256").update(buf).digest("hex") };
```
How to fix:
Charge the picture bytes, not just the body bytes, against the in-flight budget on /v1/images/edits: give the route a reserve factor that covers the maximum reference payload (four pictures at the 6 MB cap, plus their base64 copies), and for URL references reserve that same amount up front (or after the fetch, before the data URLs are kept) rather than the declared Content-Length. Also cap how many picture-fetching requests one client key may hold at once.
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
|
@strix-security review |
| const LARGE_BODY_ROUTES = [ | ||
| ["/v1/audio/transcriptions", 26 * MB], ["/v1/pro/audio/transcriptions", 26 * MB], | ||
| ["/api/html-frames", 12 * MB], ["/v1/images/edits", 34 * MB], ["/api/image-animate", 9 * MB], | ||
| ["/api/html-frames", 12 * MB], ["/v1/images/edits", 34 * MB], ["/api/image-animate", 9 * MB], ["/api/image-animate-clip", 9 * MB], |
There was a problem hiding this comment.
🟡 MEDIUM: Pictures fetched from caller URLs are never charged to the in-flight body budget
TL;DR: A caller can name image URLs in the body instead of uploading bytes, and few bytes are then counted against the in-flight memory budget. Each such call holds megabytes of fetched pictures while the gate believes the host is nearly empty. A caller who runs many of them at once can exhaust the process memory that serves every other buyer. Reserving the fetched picture bytes against the same budget as the body fixes it.
Cause, impact and fix
Cause: The gate sizes a request from its declared Content-Length (Math.ceil(size * row.factor) in src/large-body-gate.js) and holds that reservation until the response ends. The URL-reference paths added here deliver their real payload after the parse: resolveEditReferences in src/tools/llm-images-fast-kit.js reads up to four 6 MB pictures at once for /v1/images/edits, the animate routes read up to ten, and readPicture in src/tools/image-describe-kit.js fetches up to 8 MB per picture, five at a time. None of those bytes are reserved against inFlight, so the 34 MB and 9 MB rows here bound nothing about them.
Impact: A paying caller holds tens of megabytes per in-flight call from a body of a few hundred bytes, and opens many such calls, pushing the shared process past its memory ceiling so other buyers' requests fail.
Fix: Let a handler reserve bytes against the same in-flight budget the parser draws on, and have every picture-by-URL path reserve its worst case (pictures x per-picture cap, base64-expanded) before the first fetch and release it when the request finishes. Alternatively cap URL references per call, or refuse them once the budget is past its high-water mark.
🟡 `/api/image-describe` fetches up to ten 8 MB caller-URL pictures outside the large-body in-flight budget
Severity: MEDIUM
TL;DR: The new POST /api/image-describe fetch of up to ten 8 MB caller-URL pictures (five at once) is charged to the process's large-body budget at the size of the JSON body that names them — a few hundred bytes — so dozens of cheap calls can park hundreds of MB the gate believes is empty.
Impact: Any caller with a funded wallet can run a handful of concurrent $0.10 describe calls, each serving 8 MB pictures from an origin they control, and hold hundreds of MB of buffers in the process that serves every other buyer — starving or OOM-killing the shared server for all of them.
Root cause:
- The in-flight budget only knows a body's declared length (
Math.ceil(size * row.factor)fromcontent-length), so a route whose real memory is fetched from caller URLs after the parse is accounted at the size of its JSON. readPicturefetches each URL with an 8 MB cap andimageDescriberuns five of those concurrently for up to ten pictures, holding the results as data URLs while the gate holds a ~1 KB reservation for the whole call.- Nothing else bounds it: paid routes are exempt from load shedding, in-flight cover only asks that the wallet's balance covers the runs, and the image pool's memory bound assumes 5 MB sources, which this route's 8 MB fetch exceeds.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: `/api/image-describe` fetches up to ten 8 MB caller-URL pictures outside the large-body in-flight budget
Severity: MEDIUM
CWE: CWE-770
**TL;DR:** The new `POST /api/image-describe` fetch of up to ten 8 MB caller-URL pictures (five at once) is charged to the process's large-body budget at the size of the JSON body that names them — a few hundred bytes — so dozens of cheap calls can park hundreds of MB the gate believes is empty.
**Impact:** Any caller with a funded wallet can run a handful of concurrent $0.10 describe calls, each serving 8 MB pictures from an origin they control, and hold hundreds of MB of buffers in the process that serves every other buyer — starving or OOM-killing the shared server for all of them.
**Root cause:**
- The in-flight budget only knows a body's declared length (`Math.ceil(size * row.factor)` from `content-length`), so a route whose real memory is fetched from caller URLs after the parse is accounted at the size of its JSON.
- `readPicture` fetches each URL with an 8 MB cap and `imageDescribe` runs five of those concurrently for up to ten pictures, holding the results as data URLs while the gate holds a ~1 KB reservation for the whole call.
- Nothing else bounds it: paid routes are exempt from load shedding, in-flight cover only asks that the wallet's balance covers the runs, and the image pool's memory bound assumes 5 MB sources, which this route's 8 MB fetch exceeds.
Location: src/tools/image-describe-kit.js:106-109
Context: caller-URL picture fetch, up to 8 MB each, never reserved against the in-flight budget
```
if (/^https?:\/\//i.test(v)) {
await steps.robots(v);
// Each redirect hop's own robots.txt decides before the hop is sent.
({ buffer } = await steps.fetch(v, { binary: true, maxBytes: IMAGE_MAX_BYTES, timeoutMs: FETCH_MS, headers: { Accept: "image/jpeg,image/png,image/webp,image/gif;q=0.8" }, beforeRedirect: (next) => steps.robots(next) }));
```
Location: src/tools/image-describe-kit.js:186-188
Context: five picture reads in flight per call, up to ten pictures
```
const read = await mapLimit(images, AT_ONCE, async (img, i) => {
try { return { image: named(img, i), dataUrl: await readPicture(img) }; } catch (e) { return { image: named(img, i), error: e }; }
});
```
Location: src/server.js:4491-4491
Context: route charged only for its 13 MB body limit (a few hundred declared bytes here)
```
const INLINE_IMAGE_ROUTES = ["/api/image-ocr", "/api/image-exif", "/api/image-dominant-color", "/api/image-crop", "/api/images-to-pdf", "/api/image-describe"];
```
How to fix:
Reserve the fetched picture payload up front against the same in-flight budget the parser draws on, rather than only the declared body: give the gate a way for a handler to reserve (and release) bytes for work it does after the parse, and have `/api/image-describe` reserve its picture count × per-picture cap (or the bytes actually streamed, where the response's `content-length` is known) before the first fetch, with a factor covering the retained data URL. Until that exists, bound the per-call footprint so one call cannot hold many large sources: fetch the pictures one at a time or under a per-call byte budget, and abort the fetches when the caller's connection closes.
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
|
@strix-security review |
|
@strix-security review |
| if (typeof source?.url !== "string") throw bad(`${label} names no picture`); | ||
| await assertRobotsAllow(source.url); | ||
| let buffer; | ||
| try { | ||
| // A redirect hop is sent only when its own robots.txt allows it. | ||
| ({ buffer } = await safeFetch(source.url, { binary: true, ...(Number(maxBytes) > 0 ? { maxBytes } : {}), timeoutMs, headers: { Accept: ACCEPT }, beforeRedirect: (next) => assertRobotsAllow(next) })); | ||
| } catch (e) { | ||
| if (e?.statusCode === 413) throw bad(`The picture at ${label} is over ${mb(maxBytes)}; send a smaller one`, 413); | ||
| throw e; | ||
| } | ||
| return pictureFromBytes(buffer, opts); |
There was a problem hiding this comment.
🟡 MEDIUM: URL-fetched pictures are held outside the in-flight memory budget
TL;DR: A buyer with a funded wallet can send a few hundred bytes of JSON that name picture URLs, and each call then holds tens of megabytes of fetched pictures in the shared process. The in-flight budget is sized from the declared body only, so those bytes are never charged and many concurrent calls can exhaust the memory other buyers need. Reserving the picture bytes on the same budget before the fetch, and releasing them when the data URL is dropped, closes the gap on every route that reads a picture by URL.
Cause, impact and fix
Cause: The in-flight budget is reserved from Content-Length before the body is parsed, but readPicture fetches a picture up to 6 MB from a URL the body names and returns it as an ~8 MB data URL that the handler holds through the upstream call, with nothing reserving those bytes.
Impact: A payer can run many small concurrent calls that each hold tens of megabytes outside the budget, so one address can drive the shared process into memory exhaustion and fail requests for every other buyer.
Fix: Reserve the bytes a URL picture can add (its byte cap plus base64 expansion) on the same in-flight budget before the fetch, release the reservation when the data URL is dropped, and answer 503 with Retry-After when it does not fit. Every route that reads pictures by URL takes the same reservation instead of relying on the body size alone.
🟡 New /api/image-animate-clip holds caller-URL pictures outside the in-flight body budget
Severity: MEDIUM
TL;DR: The new /api/image-animate-clip downloads a caller-named https picture (up to 6 MB) and holds it as an ~8 MB data URL, while the in-flight body budget charges only the few hundred bytes of JSON the request declared.
Impact: A funded buyer can run many concurrent animate calls whose caller-URL pictures the budget never counts, holding megabytes each of shared process memory and risking an out-of-memory failure for every other buyer on the instance.
Root cause:
- The in-flight budget is sized from the request's declared Content-Length before the body is parsed (
src/large-body-gate.js:270), so bytes a handler fetches afterwards are never charged against it. readPicturein the new shared helper (src/tools/picture-input.js:126) downloads up to 6 MB (ANIMATE_MAX_IMAGE_BYTES) from the caller's URL and encodes it as a base64 data URL.animateHandler(src/tools/llm-images-fast-kit.js:823) keeps that data URL inhelduntil the upstream submit returns;/api/image-animate-clip(:1344) is new in this release and reaches the same path as the older URL-capable/api/image-animate.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: New /api/image-animate-clip holds caller-URL pictures outside the in-flight body budget
Severity: MEDIUM
CWE: CWE-770
**TL;DR:** The new `/api/image-animate-clip` downloads a caller-named https picture (up to 6 MB) and holds it as an ~8 MB data URL, while the in-flight body budget charges only the few hundred bytes of JSON the request declared.
**Impact:** A funded buyer can run many concurrent animate calls whose caller-URL pictures the budget never counts, holding megabytes each of shared process memory and risking an out-of-memory failure for every other buyer on the instance.
**Root cause:**
- The in-flight budget is sized from the request's declared Content-Length before the body is parsed (`src/large-body-gate.js:270`), so bytes a handler fetches afterwards are never charged against it.
- `readPicture` in the new shared helper (`src/tools/picture-input.js:126`) downloads up to 6 MB (`ANIMATE_MAX_IMAGE_BYTES`) from the caller's URL and encodes it as a base64 data URL.
- `animateHandler` (`src/tools/llm-images-fast-kit.js:823`) keeps that data URL in `held` until the upstream submit returns; `/api/image-animate-clip` (`:1344`) is new in this release and reaches the same path as the older URL-capable `/api/image-animate`.
Location: src/tools/llm-images-fast-kit.js:823-826
Context: Handler keeps the fetched picture as an ~8 MB data URL the budget never counted
```
let picture = await animateImage(source);
const { width, height, digest } = picture;
const held = { url: picture.dataUrl };
picture = null;
```
Location: src/tools/picture-input.js:121-131
Context: URL read: up to 6 MB fetched and base64-encoded after the gate has already sized the request
```
if (typeof source?.url !== "string") throw bad(`${label} names no picture`);
await assertRobotsAllow(source.url);
let buffer;
try {
// A redirect hop is sent only when its own robots.txt allows it.
({ buffer } = await safeFetch(source.url, { binary: true, ...(Number(maxBytes) > 0 ? { maxBytes } : {}), timeoutMs, headers: { Accept: ACCEPT }, beforeRedirect: (next) => assertRobotsAllow(next) }));
} catch (e) {
if (e?.statusCode === 413) throw bad(`The picture at ${label} is over ${mb(maxBytes)}; send a smaller one`, 413);
throw e;
}
```
Location: src/server.js:4498-4498
Context: Route row only bounds the declared body; a URL-naming body reserves hundreds of bytes
```
["/api/html-frames", 12 * MB], ["/v1/images/edits", 34 * MB], ["/api/image-animate", 9 * MB], ["/api/image-animate-clip", 9 * MB],
```
Location: src/tools/llm-images-fast-kit.js:1344-1344
Context: New route reaching the same URL-capable handler
```
handler: (input, req) => animateHandler(defaultClipOnly(input, ANIMATE_PATH), req, { tier: "image-animate-clip", path: ANIMATE_CLIP_PATH }),
```
How to fix:
Charge the bytes a caller-named URL can add to the same in-flight budget the route already draws from. When the handler fetches a picture, raise a reservation for the request to the picture's size (its 6 MB cap plus base64 expansion) and release it when the data URL is dropped, refusing with the gate's 503 when the budget is full; alternatively bound the aggregate bytes fetched from caller URLs per instance and shed load on that bound. The same reservation belongs on every route that reads pictures by URL (`/v1/images/edits`, `/api/image-describe`).
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
|
@strix-security review |
| export function imagesOf(input) { | ||
| const list = []; | ||
| for (const [field, v] of [["imageUrl", input?.imageUrl], ["image", input?.image], ["imageUrls", input?.imageUrls], ["images", input?.images]]) { | ||
| for (const item of Array.isArray(v) ? v : [v]) if (item !== undefined && item !== null && item !== "") list.push({ field, value: item }); | ||
| } | ||
| return list; | ||
| } |
There was a problem hiding this comment.
🔵 LOW: Price quote walks the whole caller-named image list before the cap is checked
TL;DR: An unpaid caller can make the price quote walk a huge imageUrls array, allocating hundreds of megabytes while the request is priced. imagesOf builds an object for every entry and the ten-image cap is only checked afterwards. Bounding the list while it is built fixes it.
Cause, impact and fix
Cause: countOf runs on the unauthenticated 402 path through imagesOf, which materialises a {field, value} object per element of imageUrls/images and returns only when the array ends. MAX_IMAGES_PER_CALL is compared against the finished length, so a 13 MB body multiplies into far more memory than the gate reserved for it.
Impact: A few concurrent unauthenticated probes spend the shared in-flight memory that protects other buyers' calls, and the caller is never charged.
Fix: Give imagesOf a limit and return as soon as it is exceeded, and pass MAX_IMAGES_PER_CALL from both countOf and describeInput so neither walks a caller-sized array. Keep the refusal wording generic since the exact count is no longer computed.
🔵 Price function on POST /api/image-describe builds one wrapper object per caller-named image entry before the image cap is checked
Severity: LOW
TL;DR: countOf in src/tools/image-describe-kit.js prices an unpaid 402 through imagesOf, which builds a {field, value} object per element of the caller's imageUrls before the 10-image cap is checked.
Impact: Anyone, unpaid, can post a 13 MB imageUrls array and make the host allocate roughly 100-250 MB that the large-body budget never accounts for; a few concurrent probes spend the shared in-flight memory that protects every other buyer's calls.
Root cause:
- The price function runs on the unauthenticated 402 path, where any body the route's 13 MB parser accepts must stay cheap to inspect, but
imagesOfmaterialises the entire named list instead of stopping at the call's limit. imagesOfpushes a{field, value}object for every element ofimageUrls/imagesand only returns when the array ends;MAX_IMAGES_PER_CALLis compared to.lengthincountOf(line 86) and indescribeInput(line 95) after all of that work is done.POST /api/image-describeis a large-body route priced from its body (bodyQuotedin src/server.js), so the gate reserves only the declared 13 MB with no reserve factor (unlike/mcp's 4x), while the quote's own list multiplies that body 12-21x in memory.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: Price function on POST /api/image-describe builds one wrapper object per caller-named image entry before the image cap is checked
Severity: LOW
CWE: CWE-770
**TL;DR:** `countOf` in src/tools/image-describe-kit.js prices an unpaid 402 through `imagesOf`, which builds a `{field, value}` object per element of the caller's `imageUrls` before the 10-image cap is checked.
**Impact:** Anyone, unpaid, can post a 13 MB `imageUrls` array and make the host allocate roughly 100-250 MB that the large-body budget never accounts for; a few concurrent probes spend the shared in-flight memory that protects every other buyer's calls.
**Root cause:**
- The price function runs on the unauthenticated 402 path, where any body the route's 13 MB parser accepts must stay cheap to inspect, but `imagesOf` materialises the entire named list instead of stopping at the call's limit.
- `imagesOf` pushes a `{field, value}` object for every element of `imageUrls`/`images` and only returns when the array ends; `MAX_IMAGES_PER_CALL` is compared to `.length` in `countOf` (line 86) and in `describeInput` (line 95) after all of that work is done.
- `POST /api/image-describe` is a large-body route priced from its body (`bodyQuoted` in src/server.js), so the gate reserves only the declared 13 MB with no reserve factor (unlike `/mcp`'s 4x), while the quote's own list multiplies that body 12-21x in memory.
Location: src/tools/image-describe-kit.js:78-84
Context: build the list only up to a limit
```
// Before:
export function imagesOf(input) {
const list = [];
for (const [field, v] of [["imageUrl", input?.imageUrl], ["image", input?.image], ["imageUrls", input?.imageUrls], ["images", input?.images]]) {
for (const item of Array.isArray(v) ? v : [v]) if (item !== undefined && item !== null && item !== "") list.push({ field, value: item });
}
return list;
}
// After:
export function imagesOf(input, limit = Infinity) {
const list = [];
for (const [field, v] of [["imageUrl", input?.imageUrl], ["image", input?.image], ["imageUrls", input?.imageUrls], ["images", input?.images]]) {
for (const item of Array.isArray(v) ? v : [v]) {
if (item === undefined || item === null || item === "") continue;
list.push({ field, value: item });
if (list.length > limit) return list;
}
}
return list;
}
```
Location: src/tools/image-describe-kit.js:86-86
Context: the price function stops at the cap
```
// Before:
const countOf = (input) => { const n = imagesOf(input).length; return n >= 1 && n <= MAX_IMAGES_PER_CALL ? n : 1; };
// After:
const countOf = (input) => { const n = imagesOf(input, MAX_IMAGES_PER_CALL).length; return n >= 1 && n <= MAX_IMAGES_PER_CALL ? n : 1; };
```
Location: src/tools/image-describe-kit.js:93-95
Context: the handler's own read of the list, same bound
```
// Before:
const images = imagesOf(input);
if (!images.length) throw bad('Send "imageUrl" (one public image URL), "imageUrls" (several) or "image" (base64 or a data: URL)');
if (images.length > MAX_IMAGES_PER_CALL) throw bad(`Send at most ${MAX_IMAGES_PER_CALL} images a call (this body names ${images.length})`);
// After:
const images = imagesOf(input, MAX_IMAGES_PER_CALL);
if (!images.length) throw bad('Send "imageUrl" (one public image URL), "imageUrls" (several) or "image" (base64 or a data: URL)');
if (images.length > MAX_IMAGES_PER_CALL) throw bad(`Send at most ${MAX_IMAGES_PER_CALL} images a call (this body names more than ${MAX_IMAGES_PER_CALL})`);
```
How to fix:
Bound the list while it is being built rather than after: give `imagesOf` a limit and make it return as soon as more than that many entries exist, and have both `countOf` and `describeInput` pass `MAX_IMAGES_PER_CALL` so the price path never walks a caller-sized array. Keep the refusal wording generic ("names more than 10") now that the exact count is no longer computed. Consider a reserve factor for body-quoted large-body routes that reflects the measured parse-plus-quote cost, so the in-flight budget reflects the memory the request actually holds.
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
| return inSlot({ | ||
| viewport: { width: 1280, height: 800 }, |
There was a problem hiding this comment.
🟡 MEDIUM: Pool render context accepts downloads, letting a page write files to worker disk
TL;DR: Any caller who names a hostile page makes the shared render worker write an unbounded file to its own temp disk. The pool context leaves downloads enabled, so they bypass both the page's request route and the byte budget. Setting acceptDownloads: false on that context closes it.
Cause, impact and fix
Cause: withPage passes only viewport, user agent and serviceWorkers: "block" to the context factory, while renderHtmlFrames and openGuardedSessionPage in the same file both disable downloads and cancel them. A download is handed to the browser's download manager instead of going through page.route, so the per-resource and per-page byte caps never see it.
Impact: The three render slots are held while unchecked bytes land on disk that every other request on the worker also needs.
Fix: Add acceptDownloads: false to the in-slot context options in withPage and cancel any download that still arrives with page.on("download", (d) => d.cancel()), with a pool test that serves an attachment and asserts no file is written.
🟡 Pool page context accepts downloads: a caller-named page can write an unbounded file to the shared render worker's disk
Severity: MEDIUM
TL;DR: The pool context built in withPage omits acceptDownloads: false, so a hostile page's own a.click() saves an unbounded file to the worker's temp disk, unseen by the byte budget or the route guards.
Impact: Any caller who names a hostile URL (the new page-images route costs $0.01) makes the shared render worker write unchecked bytes to its own temp disk while other buyers' renders wait on the same three slots, degrading the disk every other request needs.
Root cause:
- The pool context is built on the assumption that Chromium's page-side network accounting bounds what one render can consume, but downloads are handed to the browser's download manager and written to disk, so the per-resource (25 MB) and per-page (50 MB) byte caps never see them. The context options here predate this PR; the diff exports
withPageand adds a caller that loads and clicks caller-named pages. withPagesets only viewport, user agent andserviceWorkers: "block", while the same file's other context factories (renderHtmlFramesandopenGuardedSessionPage) both setacceptDownloads: falseand cancel downloads, so this context is the odd one out.- The new
page-imagescaller's GET-only and main-frame-navigation locks live inpage.route, which is never invoked for a download: measured with this context's exact options, one page wrote six 20 MB files whileNetwork.dataReceivedstayed at 285 bytes.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: Pool page context accepts downloads: a caller-named page can write an unbounded file to the shared render worker's disk
Severity: MEDIUM
CWE: CWE-400
**TL;DR:** The pool context built in `withPage` omits `acceptDownloads: false`, so a hostile page's own `a.click()` saves an unbounded file to the worker's temp disk, unseen by the byte budget or the route guards.
**Impact:** Any caller who names a hostile URL (the new `page-images` route costs $0.01) makes the shared render worker write unchecked bytes to its own temp disk while other buyers' renders wait on the same three slots, degrading the disk every other request needs.
**Root cause:**
- The pool context is built on the assumption that Chromium's page-side network accounting bounds what one render can consume, but downloads are handed to the browser's download manager and written to disk, so the per-resource (25 MB) and per-page (50 MB) byte caps never see them. The context options here predate this PR; the diff exports `withPage` and adds a caller that loads and clicks caller-named pages.
- `withPage` sets only viewport, user agent and `serviceWorkers: "block"`, while the same file's other context factories (`renderHtmlFrames` and `openGuardedSessionPage`) both set `acceptDownloads: false` and cancel downloads, so this context is the odd one out.
- The new `page-images` caller's GET-only and main-frame-navigation locks live in `page.route`, which is never invoked for a download: measured with this context's exact options, one page wrote six 20 MB files while `Network.dataReceived` stayed at 285 bytes.
Location: src/tools/render.js:311-312
Context: pool context options that omit acceptDownloads
```
// Before:
return inSlot({
viewport: { width: 1280, height: 800 },
// After:
return inSlot({
// A page's own anchor/script download is written by the browser's download
// manager, not through context.route or the CDP byte budget.
acceptDownloads: false,
viewport: { width: 1280, height: 800 },
```
Location: src/tools/page-images.js:310-322
Context: the new caller's route handler never sees a download request
```
await page.route("**/*", (route) => {
const r = route.request();
const type = r.resourceType();
if (type === "media") return route.abort("blockedbyclient");
if (type === "image" && bytes > L.softBytes) { heldImages++; return route.abort("blockedbyclient"); }
if (locked && (!/^(?:GET|HEAD)$/.test(r.method()) || (r.isNavigationRequest() && r.frame() === page.mainFrame()))) {
// A visitor counter's own posts are refused too and change nothing here.
if (clicking && /^(?:xhr|fetch|document)$/.test(type) && new URL(r.url()).host === new URL(page.url()).host) refused++;
// A refused navigation answered "no content" leaves the page in place; an abort would replace it with an error page.
return type === "document" ? route.fulfill({ status: 204 }) : route.abort("blockedbyclient");
}
return route.fallback();
});
```
How to fix:
Add `acceptDownloads: false` to the in-slot context options in `withPage`, matching `renderHtmlFrames` and `openGuardedSessionPage`, and cancel any download that still arrives with `page.on("download", (d) => d.cancel())`. Keep the CDP byte budget as the second layer rather than the only one, and cover it with a pool test that serves an attachment from a fixture page and asserts no file is written.
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
|
@strix-security review |
| const records = await resolveHedged(name, recordType, { timeoutMs: LOOKUP_MS, signal: stop.signal }); | ||
| return { name, type: recordType, records }; |
There was a problem hiding this comment.
🔵 LOW: DNS lookups return the resolver's answer without checking it
TL;DR: An outside caller can learn addresses inside the operator's private DNS zone by publishing a CNAME in their own zone that points at an internal name. The name filter only judges the name that was asked for, and both lookup paths return the resolver's answer unchanged. Judging the returned records with the same internal-name and private-address rules fixes it.
Cause, impact and fix
Cause: dnsLookup and resolveType return resolveHedged(...)'s result directly, so the guard sits on the question and not on the answer: a CNAME followed by the deployment's own resolver brings back a record a direct query for the same name refuses with a 400.
Impact: Callers of the DNS routes can map the operator's internal services, and the existing error handling reports the refusal as a 502 rather than the client error it is.
Fix: Add one shared answer check used by dnsLookup, resolveType and the propagation path: refuse a CNAME, NS or MX target the name filter rejects and an A or AAAA value that is private, loopback or link-local, and answer that as a 400.
🔵 DNS tools return internal records for a caller-owned public name that CNAMEs into a private zone
Severity: LOW
TL;DR: dnsLookup (src/tools/dns.js:32) and resolveType (src/tools/network-kit.js:76) return the resolver's answer unchecked, so a CNAME from the caller's own zone into an internal name returns the record a direct query refuses.
Impact: An outside caller of /api/dns or /api/dns-lookup can read the addresses and existence of names on the deployment's private DNS zone, which the server otherwise refuses to resolve, exposing the operator's internal service map rather than other buyers' data.
Root cause:
- The internal-name guard is deliberately a pre-query check (dns-name-filter.js judges only the spelling the caller sends), so no step on either lookup path inspects what the resolver returned; the trust boundary sits on the question, not the answer.
- Returning the resolver's answer unchanged predates the PR, but the PR rewrote exactly these lines to route every caller-named lookup through the shared hedged read (src/tools/dns.js:32, src/tools/network-kit.js:76) and neither call site checks the answer for a refused zone or a private address.
- A CNAME the caller publishes in their own public zone is followed by the deployment resolver inside its own view, so the refused name comes back as an answer (verified against the real handlers with such a resolver: records ["10.9.9.9"]) while a direct query for that same name is a 400; a resolver that forwards foreign names upstream returns nothing, so the disclosure depends on that premise.
Prompt to fix with AI
This is a security vulnerability found during a code review.
Vulnerability: DNS tools return internal records for a caller-owned public name that CNAMEs into a private zone
Severity: LOW
CWE: CWE-441
**TL;DR:** dnsLookup (src/tools/dns.js:32) and resolveType (src/tools/network-kit.js:76) return the resolver's answer unchecked, so a CNAME from the caller's own zone into an internal name returns the record a direct query refuses.
**Impact:** An outside caller of /api/dns or /api/dns-lookup can read the addresses and existence of names on the deployment's private DNS zone, which the server otherwise refuses to resolve, exposing the operator's internal service map rather than other buyers' data.
**Root cause:**
- The internal-name guard is deliberately a pre-query check (dns-name-filter.js judges only the spelling the caller sends), so no step on either lookup path inspects what the resolver returned; the trust boundary sits on the question, not the answer.
- Returning the resolver's answer unchanged predates the PR, but the PR rewrote exactly these lines to route every caller-named lookup through the shared hedged read (src/tools/dns.js:32, src/tools/network-kit.js:76) and neither call site checks the answer for a refused zone or a private address.
- A CNAME the caller publishes in their own public zone is followed by the deployment resolver inside its own view, so the refused name comes back as an answer (verified against the real handlers with such a resolver: records ["10.9.9.9"]) while a direct query for that same name is a 400; a resolver that forwards foreign names upstream returns nothing, so the disclosure depends on that premise.
Location: src/tools/dns.js:32-33
Context: primary: the answer is returned unfiltered
```
// Before:
const records = await resolveHedged(name, recordType, { timeoutMs: LOOKUP_MS, signal: stop.signal });
return { name, type: recordType, records };
// After:
const records = await resolveHedged(name, recordType, { timeoutMs: LOOKUP_MS, signal: stop.signal });
// The filter judged the name asked for; the answer is judged too, so a
// CNAME from a public zone into a private one cannot hand back a record a
// direct query for the same name refuses.
const target = (r) => (recordType === "MX" ? r?.exchange || "" : typeof r === "string" ? r : "");
if (["A", "AAAA", "CNAME", "NS", "MX"].includes(recordType)
&& records.some((r) => isPrivateIp(target(r)) || internalNameReason(target(r)) !== null)) {
throw Object.assign(new Error("The answer names an internal record; this lookup is refused"), { statusCode: 400, internalAnswer: true });
}
return { name, type: recordType, records };
```
Location: src/tools/dns.js:1-2
Context: imports for the answer check
```
// Before:
import { assertQueryableName } from "./dns-name-filter.js";
import { resolveHedged, isResolverFailure, dnsUnavailableError } from "./dns-resolve.js";
// After:
import { assertQueryableName, internalNameReason } from "./dns-name-filter.js";
import { isPrivateIp } from "./fetch-guard.js";
import { resolveHedged, isResolverFailure, dnsUnavailableError } from "./dns-resolve.js";
```
Location: src/tools/dns.js:36-36
Context: keep the refusal a 400 instead of the 502 relabel
```
// Before:
if (e?.ceilingCut || ceilingPassed()) throw ceilingCutError();
// After:
if (e?.internalAnswer) throw e;
if (e?.ceilingCut || ceilingPassed()) throw ceilingCutError();
```
Location: src/tools/network-kit.js:76-77
Context: same unfiltered answer for dns-lookup, spf-check, dmarc-check, dkim-lookup and email-deliverability
```
const records = await resolveHedged(host, type, { timeoutMs });
return { records, error: null };
```
How to fix:
Judge the answer as well as the name, in one shared helper used by `dnsLookup`, `resolveType` and the propagation path: refuse (or drop) any CNAME/NS/MX target that `internalNameReason` refuses and any A/AAAA value that `isPrivateIp` classifies as private, link-local or loopback, and answer that refusal as a 400 instead of letting the existing catch relabel it a 502. For record types whose payload cannot be judged (TXT, PTR), send the caller-named lookup to the public resolvers only, since that leg never holds the deployment's private view.
Please fix this vulnerability. If you propose a fix, make it concise and minimal.React 👍 / 👎 to tune Strix for this repo. A repo collaborator (or the PR author) can resolve this thread to dismiss these findings.
Release 2.27.0.