T09 · Insecure Skill Coding Practices
- Location
resume_parser.py:116- Finding
Unrestricted API Endpoint Override Can Disclose Resume Data and API Credentials
- Content
View full analysis
Vulnerability Details
File Location:
resume_parser.py, lines 116–122, 137–138, 186–192, and 212–213
Vulnerability Type: Arbitrary outbound endpoint configuration leading to sensitive-data disclosure
Risk Level: HighVulnerable Code
python parser.add_argument( "--base-url", type=str, default="", help="SoMark API base URL(覆盖 SOMARK_BASE_URL 环境变量)," "例如 https://somark.cn/api/v1(中国大陆)或 https://somark.ai/api/v1(海外)", )python data.add_field("api_key", api_key) data.add_field("file", file_path.read_bytes(), filename=file_path.name) for output_format in output_formats: data.add_field("output_formats", output_format) data.add_field("element_formats", json.dumps(element_formats, ensure_ascii=False)) data.add_field("feature_config", json.dumps(feature_config, ensure_ascii=False)) async with session.post(async_url, data=data) as resp:python base_url = (args.base_url or os.environ.get("SOMARK_BASE_URL", "https://somark.cn/api/v1")).rstrip("/") if not base_url: print("错误:SoMark API base URL 不能为空") raise SystemExit(1) async_url = f"{base_url}/parse/async" check_url = f"{base_url}/parse/async_check"python task_id = await submit_task( session, file_path, api_key, output_formats, element_formats, feature_config, async_url, )Technical Analysis
The parser permits its API base URL to be supplied through either the
--base-urlcommand-line argument or theSOMARK_BASE_URLenvironment variable. It does not enforce HTTPS, validate the destination hostname against an allowlist, or require confirmation when a nonstandard endpoint is selected.The constructed endpoint is then passed to
aiohttp.ClientSession.post. The multipart request includes both the complete resume file andSOMARK_API_KEY. Consequently, anyone able to influence the process arguments or environment can ...[truncated 2223 chars]- Remediation
View remediation
Remediation Suggestions
-
Allowlist trusted endpoints. Accept only the documented canonical origins by default:
https://somark.cn/api/v1https://somark.ai/api/v1
-
Enforce transport security. Reject URLs whose scheme is not
https. Parse the URL with a URL parser rather than relying on string-prefix checks, and reject embedded credentials, unexpected ports, fragments, and malformed hostnames. -
Restrict custom endpoints. If private deployments must be supported, require a separate explicit option such as
--allow-custom-endpoint, display the exact hostname receiving the document, and require informed confirmation before transmitting credentials or files. -
Reduce environment-based redirection risk. Do not silently prioritize an inherited
SOMARK_BASE_URL. Either remove this override or validate it using the same strict policy as command-line input. -
Improve credential handling. Where supported by the API, transmit the API key through an authorization header rather than a multipart form field. This reduces the likelihood that generic request-body logging captures the credential.
-
Warn before data transmission. Clearly state which endpoint will receive the resume and obtain confirmation, especially because the file contains personal data.
-
Add security tests. Verify that HTTP URLs, lookalike domains, URLs with user-information components, redirects to untrusted hosts, and unapproved custom domains are rejected. Redirect handling should also be disabled or constrained so an approved endpoint cannot redirect sensitive POST data to another origin.
-
