T09 · Insecure Skill Coding Practices
- Location
scripts/generator.py:44- Finding
Arbitrary API Endpoint Can Receive Sensitive Source-Code Contents
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generator.py:44-45, 125-129, 189-197; also present inscripts/critic.py:111-115, 192-214andscripts/ralph-loop.sh:10, 120-131
Vulnerability Type: Unrestricted transmission of user-provided files and source code to a configurable network endpoint
Risk Level: MediumVulnerable Code
scripts/generator.py:44-45allows the destination to be supplied through an argument or environment variable without restricting it to a local LM Studio instance:python def __init__(self, api_url: str = None, model: str = None): self.api_url = api_url or os.getenv("LMSTUDIO_URL", self.DEFAULT_API_URL)scripts/generator.py:125-129transmits the generated prompt, includinginput_content, to that endpoint:python response = self.session.post( f"{self.api_url}/chat/completions", json=payload, timeout=300 )scripts/generator.py:189-197reads the complete user-selected file and passes it into the network-backed generation operation:python input_content = "" if args.file: try: with open(args.file, 'r', encoding='utf-8') as f: input_content = f.read() except Exception as e: print(f"Error reading file: {e}", file=sys.stderr) sys.exit(1) gen = Generator(api_url=args.api_url, model=args.model)The same trust model is used by the critic.
scripts/critic.py:111-115accepts an unrestricted destination:python def __init__(self, api_url: str = None, model: str = None): self.api_url = api_url or os.getenv("LMSTUDIO_URL", self.DEFAULT_API_URL) self.model = model or os.getenv("LMSTUDIO_MODEL_CRITIC") self.session = requests.Session() self.session.headers.update({"Content-Type": "application/json"})scripts/critic.py:206-214sends the reviewed code in the request payload:python messages = [ {"role": "system", "content": self.SYSTEM_PROMPT}, {"role": "user", "content": user_prompt} ] payload = { ...[truncated 3688 chars]- Remediation
View remediation
Remediation Suggestions
-
Enforce the local-only default trust boundary
- Parse the configured URL with a standard URL parser.
- Permit only
localhost,127.0.0.0/8, and::1by default. - Reject malformed URLs, embedded credentials, unexpected schemes, and non-loopback hosts.
-
Require explicit authorization for remote endpoints
- Add a clearly named option such as
--allow-remote-api. - Display the destination hostname and warn that complete source contents will be transmitted.
- Require interactive confirmation unless running under an explicitly configured noninteractive policy.
- Add a clearly named option such as
-
Require transport security
- Require HTTPS for every non-loopback destination.
- Preserve TLS certificate validation.
- Do not provide an option that silently disables certificate verification.
-
Use endpoint allowlisting
- Support an administrator-controlled list of approved model-service hosts.
- Resolve hostnames and validate resulting addresses to reduce hostname-based bypasses.
- Revalidate redirects or disable redirects for API requests.
-
Minimize transmitted data
- Warn users before sending file contents.
- Add optional scanning and redaction for credentials, private keys, tokens, and environment values.
- Avoid transmitting unrelated file content or metadata.
- Consider chunking or selecting only the relevant code region.
-
Improve documentation
- State prominently that supplied source files and prompts are sent to the configured API.
- Explain the security implications of changing
LMSTUDIO_URLor using--api-url. - Clarify that remote LM Studio-compatible services have access to all submitted content.
-
Harden all affected components consistently
- Apply the same URL validation to
Generator,Critic, andralph-loop.sh. - Centralize endpoint validation rather than implementing independent checks in each component.
- Add tests proving that loopback URLs ar ...[truncated 64 chars]
- Apply the same URL validation to
-
