T09 · Insecure Skill Coding Practices
- Location
scripts/nexus_cli.py:164- Finding
Nexus credentials are disclosed to an arbitrary download origin
- Content
View full analysis
Vulnerability Details
File Location:
scripts/nexus_cli.py, lines 164–178
Vulnerability Type: Credential disclosure through unrestricted authenticated requests
Risk Level: HighComplete Code Snippet
python def cmd_download(cfg, args): auth = HTTPBasicAuth(cfg["user"], cfg["pass"]) try: resp = requests.get(args.url, auth=auth, stream=True, timeout=300) except requests.RequestException as exc: die(f"download failed: {exc}") if resp.status_code >= 400: die(f"download -> HTTP {resp.status_code}") dest = args.output or os.path.basename(args.url.split("?")[0]) or "download.bin" with open(dest, "wb") as fh: for chunk in resp.iter_content(chunk_size=8192): fh.write(chunk) out({"downloaded": dest, "bytes": os.path.getsize(dest)})Technical Analysis
The
downloadcommand accepts an unrestricted full URL inargs.url. It then creates an HTTP Basic Authentication object from the configured Nexus username and password or token and attaches that authentication to the request regardless of the URL's origin.No validation ensures that the supplied URL has the same scheme, hostname, and port as the configured
NEXUS_URL. Consequently, invoking the command with an external URL sends the Nexus authorization credentials to that external server. Anhttp://URL would additionally transmit the credentials without transport encryption.The affected trust boundary is between the trusted Nexus service configured by the user and an independently controlled HTTP origin. Credentials intended only for Nexus are disclosed to the selected download server.
Attack Path
- A Nexus account is configured through
NEXUS_USERandNEXUS_PASS, or through~/.devops-skills/nexus.json. - An attacker causes an external URL under their control to be used by the
downloadcommand, including through content that induces an implicitly invoked Agent request. - The CLI constructs `HTTPB ...[truncated 891 chars]
- A Nexus account is configured through
- Remediation
View remediation
Remediation Suggestions
- Parse both
NEXUS_URLand the requested download URL with a standards-compliant URL parser. - Require the download URL to use HTTPS.
- Before attaching credentials, require an exact match of scheme, normalized hostname, and effective port with
NEXUS_URL. - Do not attach Nexus credentials to cross-origin requests. If external unauthenticated downloads are intentionally supported, use a separate code path that omits
auth. - Reject URLs containing embedded user information.
- Consider accepting repository-relative asset paths rather than arbitrary full URLs and constructing the final URL from the trusted configured origin.
- Add tests proving that authentication is absent or the operation is rejected for cross-origin and plain-HTTP URLs.
- Parse both
