T09 · Insecure Skill Coding Practices
- Location
scripts/redmine.js:186- Finding
Redmine API Key May Be Disclosed Through Insufficient Origin Validation and Redirect Handling
- Content
View full analysis
Vulnerability Details
File Location:
scripts/redmine.js, lines 81, 143–147, and 186–210
Vulnerability Type: Authenticated request credential disclosure
Risk Level: HighThe Skill sends the sensitive
REDMINE_API_KEYin the customX-Redmine-API-Keyheader. Attachment URLs are checked by hostname only, rather than by their complete origin, and authenticated Redmine requests use the default automatic redirect behavior.Relevant authenticated requests include:
js const response = await fetch(url, { headers });js const response = await fetch(url, { method: "PUT", headers, body: JSON.stringify({ issue: issuePayload, }), });The vulnerable attachment validation and request are:
js // SSRF guard: ensure the attachment URL belongs to the same Redmine host. // Redmine's own attachments are always served from the same origin; a // mismatched host indicates a tampered or externally-hosted attachment URL. if (baseUrl) { let attachmentHost, redmineHost; try { attachmentHost = new URL(contentUrl).hostname; redmineHost = new URL(baseUrl).hostname; } catch { throw new Error(`Attachment ${attachment?.id || "unknown"} has an unparseable content_url`); } if (attachmentHost !== redmineHost) { throw new Error( `Attachment ${attachment?.id || "unknown"} content_url host "${attachmentHost}" does not match Redmine host "${redmineHost}"` ); } } // Enforce HTTPS to prevent credential leakage on redirect or misconfiguration. validateHttpsUrl(contentUrl, `attachment ${attachment?.id || "unknown"} content_url`); const headers = {}; if (apiKey) { headers["X-Redmine-API-Key"] = apiKey; } const response = await fetch(contentUrl, { headers });Technical Analysis
A URL origin consists of its scheme, hostname, and effective port. The attachment chec ...[truncated 2584 chars]
- Remediation
View remediation
Remediation Suggestions
-
Validate the complete origin rather than only the hostname:
js const attachmentUrl = new URL(contentUrl); const configuredRedmineUrl = new URL(baseUrl); if (attachmentUrl.origin !== configuredRedmineUrl.origin) { throw new Error("Attachment URL does not match the configured Redmine origin"); } -
Disable automatic redirects for all requests carrying the Redmine API key:
js const response = await fetch(url, { headers, redirect: "manual", });Apply the same policy to issue retrieval, issue updates, and attachment downloads.
-
If redirects are operationally required, implement controlled redirect handling:
- Limit the number of redirects.
- Resolve each
Locationvalue safely. - Require HTTPS on every hop.
- Compare every destination's complete origin with the configured Redmine origin.
- Attach
X-Redmine-API-Keyonly after the destination passes validation. - Reject redirects to URLs containing embedded credentials.
-
Parse and normalize
REDMINE_BASE_URLonce, then use its validated origin to construct all Redmine API and attachment requests. -
Use a dedicated least-privilege Redmine API account whose permissions are limited to the projects and operations required by this Skill. Rotate the API key if exposure is suspected.
-
Add regression tests covering alternate ports, cross-origin redirects, same-origin redirects, malformed URLs, embedded URL credentials, and HTTPS-to-HTTP redirects.
-
