T09 · Insecure Skill Coding Practices
- Location
scripts/jenkins.mjs:28- Finding
Jenkins credentials may be transmitted over plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/jenkins.mjs, lines 28-47
Vulnerability Type: Transmission of sensitive credentials over a potentially unencrypted connection
Risk Level: HighVulnerable Code
js const JENKINS_URL = process.env.JENKINS_URL?.replace(/\/$/, ""); const JENKINS_USER = process.env.JENKINS_USER; const JENKINS_API_TOKEN = process.env.JENKINS_API_TOKEN; if (!JENKINS_URL || !JENKINS_USER || !JENKINS_API_TOKEN) { console.error("Missing required environment variables: JENKINS_URL, JENKINS_USER, JENKINS_API_TOKEN"); process.exit(2); } const auth = Buffer.from(`${JENKINS_USER}:${JENKINS_API_TOKEN}`).toString("base64"); const headers = { "Authorization": `Basic ${auth}`, "Content-Type": "application/json", "Accept": "application/json", }; async function request(path, { method = "GET", body = undefined, crumb = false } = {}) { const url = `${JENKINS_URL}${path}`; const res = await fetch(url, {Technical Analysis
The application accepts
JENKINS_URLwithout parsing the URL or requiring the HTTPS protocol. It then places the Jenkins username and API token in an HTTP Basic Authentication header on every request.Basic Authentication uses Base64 encoding, which provides no encryption. If
JENKINS_URLis configured with anhttp://endpoint, the authorization header and its credentials can be observed by any party capable of intercepting the network connection. The documentation describes an HTTPS example but does not enforce HTTPS in code.Attack Path
- A user or deployment configuration sets
JENKINS_URLto anhttp://Jenkins endpoint. - The script combines
JENKINS_USERandJENKINS_API_TOKENand Base64-encodes them. - The resulting value is sent in the
Authorization: Basicheader over the unencrypted connection. - An attacker positioned on the same network, an intermediate proxy, or another network-monitoring componen ...[truncated 868 chars]
- A user or deployment configuration sets
- Remediation
View remediation
Remediation Suggestions
- Parse the configured endpoint with
new URL(JENKINS_URL)and reject malformed URLs. - Require the
https:protocol before creating or sending an authorization header. - If unencrypted HTTP is necessary for local development, require an explicit insecure-mode option and restrict it to loopback addresses such as
127.0.0.1orlocalhost. - Do not treat the HTTPS example in documentation as an adequate control; enforce the requirement at runtime.
- Ensure TLS certificate validation remains enabled. Do not introduce options that disable certificate verification.
- Use a narrowly scoped Jenkins service account and token so that credential compromise has limited impact.
- Rotate any API token that may previously have been sent to a Jenkins endpoint over HTTP.
- Parse the configured endpoint with
