T09 · Insecure Skill Coding Practices
- Location
scripts/toupiaoya/cli.py:15- Finding
Authenticated API requests can be redirected to arbitrary endpoints
- Content
View full analysis
Vulnerability Details
File Location:
scripts/toupiaoya/cli.py:15-23,scripts/toupiaoya/commands/project_cmd.py:218-242,scripts/toupiaoya/create.py:23-24, 62-63,scripts/toupiaoya/http.py:24-36,scripts/toupiaoya/project_api.py:101-111, 125-140, 151-166, 237-245, 256-266, 277-292, andscripts/toupiaoya/constants.py:16-18
Vulnerability Type: Credential disclosure through an unvalidated authenticated endpoint override
Risk Level: HighVulnerable Code
The top-level CLI permits an unrestricted API base URL:
python parser.add_argument( "--base-url", default=DEFAULT_BASE_URL, help=( "API root address (environment variable TOUPIAOYA_API_BASE or EQXIU_AIGC_API_BASE; " f"default is {DEFAULT_BASE_URL!r})" ), )The project creation handler automatically reads the persistent token and combines it with the caller-controlled base URL:
python def _run_create(args: argparse.Namespace, parser: argparse.ArgumentParser) -> None: _ = parser cfg = load_config() token_cli = getattr(args, "access_token", None) token = (token_cli or "").strip() or token_from_config(cfg) if not token: print( "Notice: X-Openclaw-Token is not configured; run `login` or provide --access-token.", file=sys.stderr, ) creator = ToupiaoyaCreator(base_url=args.base_url) group_list = parse_group_list(args.groupList) single_vote = not getattr(args, "multi", False) result = creator.execute( brief_title=args.briefTitle, brief_desc=args.briefDesc, detail_title=args.detailTitle, detail_desc=args.detailDesc, vote_type=args.voteType, time_start=args.timeStart, time_end=args.timeEnd, group_list=group_list, template_id=args.templateId, single_vote=single_vote, sponsor=args.sponsor, access_to ...[truncated 5196 chars]- Remediation
View remediation
Remediation Suggestions
- Remove public endpoint overrides from production-facing CLI commands unless they are essential.
- Parse every authenticated destination with
urllib.parse.urlparseand require:- The
httpsscheme. - No embedded username or password.
- An exact approved hostname.
- An expected port, normally 443.
- The
- Maintain an explicit allowlist of authenticated service origins, such as the required Toupiaoya API hosts. Do not use suffix-only checks that could accept names such as
toupiaoya.com.attacker.example. - Implement destination validation centrally in
scripts/toupiaoya/http.pybefore addingX-Openclaw-Token. - Disable redirects for authenticated requests or manually follow only same-origin HTTPS redirects.
- If custom development endpoints must remain available:
- Require an explicit opt-in flag.
- Never automatically load the persistent production token for a custom endpoint.
- Require a separately supplied development token.
- Display the exact destination and request explicit user confirmation.
- Validate environment-derived endpoints during startup and fail closed if they are not approved.
- Add tests proving that credentials are not sent to HTTP URLs, unapproved hosts, deceptive subdomains, alternate ports, or cross-origin redirects.
