T09 · Insecure Skill Coding Practices
- Location
scripts/video_background_remove.js:88- Finding
Unrestricted JSON Fields Are Transmitted to an External API
- Content
View full analysis
Vulnerability Details
File Location:
scripts/video_background_remove.js, lines 88–94, 183–202, and 467–468
Vulnerability Type: Missing input allowlisting leading to unintended external data transmission
Risk Level: MediumVulnerable Code
js function buildPayload(spec, input) { const payload = { ...spec.defaults, ...(input || {}) }; if (typeof spec.preparePayload === "function") spec.preparePayload(payload); if (payload.rect_vo_list != null) payload.rect_vo_list = normalizeRectList(payload.rect_vo_list); return payload; }js async function httpJson(method, url, body, apiKey) { const headers = { "Content-Type": "application/json" }; if (apiKey) headers.Authorization = `Bearer ${apiKey}`; const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), 30000); try { const res = await fetch(url, { method, headers, body: body != null ? JSON.stringify(body) : undefined, signal: controller.signal, });js const payload = buildPayload(spec, parseJsonInput(args.json)); const validationErrors = validatePayload(spec, payload);Technical Analysis
The documented request schema allows only
video_urland the optionalbackground_color. However,buildPayloadcopies every property from the user-provided JSON object into the outbound payload.validatePayloadverifies required, URL, rectangle, and enumerated fields, but it does not reject undeclared properties. Consequently, arbitrary additional fields survive validation and are serialized into the POST request sent to the fixed external endpoint athttps://api.weryai.com/v1/generation/video-background-remove.The network request and transmission of the WeryAI API key and video URL are necessary for the declared remote background-removal functionality. The transmission of arbitrary undeclared fields is not necessary and exceeds the Skill's declared minimum data scope.
Attack Path
- A ...[truncated 1374 chars]
- Remediation
View remediation
Remediation Suggestions
-
Build the request body from an explicit allowlist rather than spreading all input properties:
js function buildPayload(spec, input = {}) { return { video_url: input.video_url, background_color: input.background_color ?? spec.defaults.background_color, }; } -
Reject unknown fields before making a network request:
js const allowedFields = new Set(["video_url", "background_color"]); const unknownFields = Object.keys(input || {}).filter( (field) => !allowedFields.has(field) ); if (unknownFields.length > 0) { throw new Error(`Unknown fields: ${unknownFields.join(", ")}`); } -
Apply the same schema validation to dry-run and live execution so their accepted inputs remain consistent.
-
Add automated tests confirming that undeclared fields are rejected and never appear in
requestPreviewor outbound request bodies. -
Preserve the fixed HTTPS API origin and the existing restriction to
WERYAI_API_KEY; do not add configurable network destinations or generic environment-variable forwarding.
-
