T09 · Insecure Skill Coding Practices
- Location
scripts/remove_watermark.py:24- Finding
Arbitrary API Base URL Allows Credential and Task-Data Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
scripts/remove_watermark.py, lines 24-32, 52, and 65-66
Vulnerability Type: Unrestricted credential forwarding to a user-controlled endpoint
Risk Level: HighVulnerable Code
python def post_json(url: str, api_key: str, payload: dict, timeout: int, user_agent: str) -> dict: body = json.dumps(payload).encode("utf-8") request = urllib.request.Request( url, data=body, headers={ "Content-Type": "application/json", "Authorization": f"Bearer {api_key}", "User-Agent": user_agent, "Accept": "application/json, text/plain, */*", "Origin": DEFAULT_BASE_URL, "Referer": f"{DEFAULT_BASE_URL}/", }, method="POST", )python parser.add_argument("--base-url", default=DEFAULT_BASE_URL, help="API base URL")python submit_url = args.base_url.rstrip("/") + SUBMIT_PATH status_url = args.base_url.rstrip("/") + STATUS_PATHTechnical Analysis
The script permits callers to override the API origin using
--base-url. The supplied value is not restricted by scheme or hostname. Every request to the resulting URL includes the production API key in theAuthorizationheader.Consequently, a caller can redirect requests to an arbitrary server and receive:
- The
NOWATERMARK_API_KEYbearer credential. - The submitted image URL.
- Existing or newly returned request IDs.
- Subsequent polling traffic.
This behavior exceeds the minimum privileges required for the declared functionality. The Skill documentation identifies
https://nowatermark.infoas the intended external service; sending its credential to an arbitrary origin is unnecessary. Allowing a plaintexthttp://base URL would also expose the credential and payload to network interception.Attack Path
- An attacker influences the command invocati ...[truncated 1276 chars]
- The
- Remediation
View remediation
Remediation Suggestions
- Remove the
--base-urloption from production use and always send authenticated requests to the fixedhttps://nowatermark.infoorigin. - If endpoint overrides are required for development, place them behind an explicit test-only mode that does not use production credentials.
- Enforce an exact allowlist of approved HTTPS origins. Validate the parsed scheme, normalized hostname, and port rather than relying on string prefixes.
- Reject plaintext HTTP and URLs containing embedded credentials.
- Ensure redirects cannot forward the
Authorizationheader to a different origin. Disable redirects or validate every redirect destination before following it. - Use separate, limited-scope development credentials for testing custom endpoints.
- Document the only approved data recipient and fail closed when origin validation fails.
- Remove the
