Back to skill

Security audit

CodeAlive Context Engine

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real CodeAlive search and Q&A helper, but it needs Review because its API key handling can expose the key or send it to an untrusted endpoint.

Install only if you trust CodeAlive with the indexed repositories and queries you plan to use. Prefer hidden interactive setup, avoid pasting API keys into chat or command lines, do not set CODEALIVE_BASE_URL unless it is a trusted HTTPS CodeAlive endpoint, and rotate any key that was already pasted into a transcript, shell history, or logs.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/lib/api_client.py:121
Finding
API Credential Can Be Transmitted to an Arbitrary Configurable Origin<![CDATA[ ## Vulnerability Details **File Location**: `scripts/lib/api_client.py:121-164`; `setup.py:138-145`; `setup.py:179` **Vulnerability Type**: Unvalidated credential destination and possible cleartext credential transmission **Risk Level**: High ### Vulnerable Code `scripts/lib/api_client.py:121-164`: ```python self.base_url = base_url or os.getenv("CODEALIVE_BASE_URL", "https://app.codealive.ai") self.timeout = 60 def _make_request( self, method: str, endpoint: str, params: Optional[Dict[str, Any]] = None, body: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """ Make an HTTP request to the CodeAlive API. Args: method: HTTP method (GET, POST, etc.) endpoint: API endpoint path params: URL query parameters body: Request body for POST requests Returns: Parsed JSON response """ url = f"{self.base_url}{endpoint}" # Add query parameters if params: query_string = urllib.parse.urlencode(params, doseq=True) url = f"{url}?{query_string}" # Prepare request headers = { "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json" } data = None if body: data = json.dumps(body).encode("utf-8") request = urllib.request.Request(url, data=data, headers=headers, method=method) # Make request try: with urllib.request.urlopen(request, timeout=self.timeout) as response: ``` `setup.py:138-145` and `setup.py:179`: ```python def verify_key(api_key: str, base_url: str = DEFAULT_BASE_URL) -> tuple[bool, str]: """Test the API key by fetching data sources. Returns (success, message).""" url = f"{base_url}/api/datasources/alive" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json", } req = urllib.request.Request(url, headers=headers, method="GET") try: with urllib.request.urlopen(req, timeout=15) as re ...[truncated 2603 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Parse the base URL with `urllib.parse.urlparse` before using it. 2. Require the `https` scheme and reject cleartext HTTP. 3. Pin the default credential to `app.codealive.ai`. 4. If private instances must be supported, require an explicit trusted-host allowlist or an interactive confirmation that clearly identifies the destination. 5. Reject URLs containing user information, fragments, unexpected ports, malformed hosts, or unsupported schemes. 6. Associate stored credentials with a specific API origin rather than using one generic credential-store entry for every configured host. 7. Refuse to forward the `Authorization` header across redirects to a different origin. Prefer disabling automatic cross-origin redirects for authenticated requests. 8. Avoid revealing full custom URLs in errors if they may contain sensitive components. 9. Add tests covering HTTP URLs, attacker-controlled hosts, cross-origin redirects, malformed URLs, and default-host operation. A safe validation pattern should resemble: ```python from urllib.parse import urlparse parsed = urlparse(self.base_url) if parsed.scheme != "https": raise ValueError("CODEALIVE_BASE_URL must use HTTPS") trusted_hosts = {"app.codealive.ai"} if parsed.hostname not in trusted_hosts: raise ValueError("Untrusted CodeAlive API host") ``` For supported private instances, the trusted hostname should come from a separately protected configuration and the credential should be scoped to that hostname. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
setup.py:110
Finding
API Key Exposure Through Process Arguments and Plaintext Terminal Output<![CDATA[ ## Vulnerability Details **File Location**: `setup.py:110-123`; `setup.py:225-247`; `SKILL.md:18-21` **Vulnerability Type**: Sensitive credential disclosure through command lines, logs, and transcripts **Risk Level**: Medium ### Vulnerable Code `setup.py:110-123`: ```python r = subprocess.run( ["security", "add-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME, "-w", api_key], capture_output=True, text=True, timeout=5, ) return r.returncode == 0 elif system == "Linux": r = subprocess.run( ["secret-tool", "store", "--label=CodeAlive API Key", "service", SERVICE_NAME], input=api_key, capture_output=True, text=True, timeout=10, ) return r.returncode == 0 elif system == "Windows": r = subprocess.run( ["cmdkey", f"/generic:{SERVICE_NAME}", "/user:codealive", f"/pass:{api_key}"], capture_output=True, text=True, timeout=10, ) ``` `setup.py:225-247`: ```python if env_mode: shell = os.getenv("SHELL", "") profile = "~/.zshrc" if "zsh" in shell else "~/.bashrc" print(f" Add this to your {profile}:") print(f' export CODEALIVE_API_KEY="{api_key}"') print() print(f" Then reload: source {profile}") else: stored = store_key(api_key) if stored: store_name = {"Darwin": "macOS Keychain", "Linux": "secret-tool", "Windows": "Credential Manager"}.get(system, "credential store") print(f" Saved to {store_name}.") else: # Fallback: suggest env var print(f" Could not save to OS credential store.") shell = os.getenv("SHELL", "") profile = "~/.zshrc" if "zsh" in shell else "~/.bashrc" print(f" Add this to your {profile} instead:") print(f' export CODEALIVE_API_KEY="{api_key}"') ``` `SKILL.md:18-21`: ```bash python setup.py --key THE_KEY ``` ### Technical Analysis The setup workflow exposes the API key through multiple observable channels: - On macOS, the key is ...[truncated 2297 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `setup.py --key THE_KEY` from Agent-facing documentation and discourage supplying secrets through chat. 2. Accept credentials through hidden interactive input or protected standard input only. 3. Never print the complete API key, including in fallback and `--env` modes. 4. Replace printed export commands with generic instructions such as: ```text Set CODEALIVE_API_KEY manually in a trusted terminal. ``` 5. Redact any displayed credential to a small non-sensitive prefix or suffix if identification is necessary. 6. Use native credential-store APIs that do not place secrets in child-process arguments. 7. Where native APIs are unavailable, pass secret material through standard input or another protected IPC mechanism. 8. Ensure error messages, exception objects, and debug logs never include the key. 9. Warn users that environment variables may be inherited by child processes and may be unsuitable for high-security environments. 10. Add automated tests that capture stdout, stderr, and invoked command arguments and assert that the raw API key never appears. 11. Recommend immediate key rotation if a key has already been entered into an Agent conversation, shell command, or retained log. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The skill’s top-level description emphasizes code search and Q&A, but the content also instructs users to configure API keys, use OS credential stores, and perform authenticated remote operations. Omitting these operational and secret-handling behaviors from the primary description can mislead users and agents about the trust boundary, making it easier to expose credentials or send sensitive code context to a remote service without informed consent.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The skill’s top-level description emphasizes code search and Q&A, but the content also instructs users to configure API keys, use OS credential stores, and perform authenticated remote operations. Omitting these operational and secret-handling behaviors from the primary description can mislead users and agents about the trust boundary, making it easier to expose credentials or send sensitive code context to a remote service without informed consent.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill’s top-level description emphasizes code search and Q&A, but the content also instructs users to configure API keys, use OS credential stores, and perform authenticated remote operations. Omitting these operational and secret-handling behaviors from the primary description can mislead users and agents about the trust boundary, making it easier to expose credentials or send sensitive code context to a remote service without informed consent.

Credential Access

High
Category
Privilege Escalation
Content
"""Client for interacting with the CodeAlive API."""

    @staticmethod
    def _get_key_from_keychain() -> Optional[str]:
        """Try to read the API key from OS credential store."""
        import platform
        system = platform.system()
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
"""Client for interacting with the CodeAlive API."""

    @staticmethod
    def _get_key_from_keychain() -> Optional[str]:
        """Try to read the API key from OS credential store."""
        import platform
        system = platform.system()
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Direct flow: os.getenv (credential/environment) → subprocess.run (code execution)

High
Category
Data Flow
Content
try:
            if system == "Darwin":
                import subprocess
                result = subprocess.run(
                    ["security", "find-generic-password", "-a", os.getenv("USER", ""), "-s", "codealive-api-key", "-w"],
                    capture_output=True, text=True, timeout=5
                )
Confidence
80% confidence
Finding
Data flows directly from a source (env vars, files, network) to a sink (network output, exec, file write) without intermediate validation.

Credential Access

High
Category
Privilege Escalation
Content
api_key: CodeAlive API key. Resolution order:
                     1. Explicit api_key parameter
                     2. CODEALIVE_API_KEY environment variable
                     3. macOS Keychain (service: codealive-api-key)
            base_url: Base URL for the API. Defaults to https://app.codealive.ai
        """
        self.api_key = api_key or os.getenv("CODEALIVE_API_KEY") or self._get_key_from_keychain()
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
api_key: CodeAlive API key. Resolution order:
                     1. Explicit api_key parameter
                     2. CODEALIVE_API_KEY environment variable
                     3. macOS Keychain (service: codealive-api-key)
            base_url: Base URL for the API. Defaults to https://app.codealive.ai
        """
        self.api_key = api_key or os.getenv("CODEALIVE_API_KEY") or self._get_key_from_keychain()
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Direct flow: os.getenv (credential/environment) → subprocess.run (code execution)

High
Category
Data Flow
Content
system = platform.system()
    try:
        if system == "Darwin":
            r = subprocess.run(
                ["security", "find-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME, "-w"],
                capture_output=True, text=True, timeout=5,
            )
Confidence
80% confidence
Finding
Data flows directly from a source (env vars, files, network) to a sink (network output, exec, file write) without intermediate validation.

Direct flow: os.getenv (credential/environment) → subprocess.run (code execution)

High
Category
Data Flow
Content
try:
        if system == "Darwin":
            # Delete existing entry first (ignore errors if it doesn't exist)
            subprocess.run(
                ["security", "delete-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME],
                capture_output=True, timeout=5,
            )
Confidence
80% confidence
Finding
Data flows directly from a source (env vars, files, network) to a sink (network output, exec, file write) without intermediate validation.

Direct flow: os.getenv (credential/environment) → subprocess.run (code execution)

High
Category
Data Flow
Content
["security", "delete-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME],
                capture_output=True, timeout=5,
            )
            r = subprocess.run(
                ["security", "add-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME, "-w", api_key],
                capture_output=True, text=True, timeout=5,
            )
Confidence
80% confidence
Finding
Data flows directly from a source (env vars, files, network) to a sink (network output, exec, file write) without intermediate validation.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill documents shell commands, environment-variable use, credential-store interaction, and remote API access, but it does not declare any explicit tool scope such as allowed-tools or permissions. That creates an avoidable trust gap: an agent may invoke shell/network-capable actions without clear least-privilege boundaries, increasing the chance of unintended secret handling or data exfiltration during normal use.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill encourages semantic search, chat, fetch, and MCP-backed operations against indexed repositories, but it does not prominently warn that user queries and potentially codebase content may be transmitted to a remote CodeAlive service. In a code-analysis context, this is significant because source code, identifiers, architecture details, or proprietary snippets may be sensitive; users may disclose them under the assumption the skill is purely local.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
This script forwards user-provided queries and selected data source identifiers to external API methods (`client.search` and `client.chat`) without any explicit notice, confirmation, or data-sensitivity guardrails. In a code exploration tool, those inputs may contain proprietary project names, internal architecture details, incident descriptions, or sensitive code context, creating a real risk of unintended external disclosure.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
try:
            if system == "Darwin":
                import subprocess
                result = subprocess.run(
                    ["security", "find-generic-password", "-a", os.getenv("USER", ""), "-s", "codealive-api-key", "-w"],
                    capture_output=True, text=True, timeout=5
                )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
return result.stdout.strip()
            elif system == "Linux":
                import subprocess
                result = subprocess.run(
                    ["secret-tool", "lookup", "service", "codealive-api-key"],
                    capture_output=True, text=True, timeout=5
                )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The client sends user queries, repository/workspace names, and artifact identifiers to a remote service, and other methods can retrieve and transmit full code artifacts. In a code-search skill, this is expected, but it is still a real privacy and data-exposure risk if users are not clearly informed that potentially sensitive codebase metadata or contents are leaving the local environment.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
system = platform.system()
    try:
        if system == "Darwin":
            r = subprocess.run(
                ["security", "find-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME, "-w"],
                capture_output=True, text=True, timeout=5,
            )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
if r.returncode == 0 and r.stdout.strip():
                return r.stdout.strip()
        elif system == "Linux":
            r = subprocess.run(
                ["secret-tool", "lookup", "service", SERVICE_NAME],
                capture_output=True, text=True, timeout=5,
            )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
try:
        if system == "Darwin":
            # Delete existing entry first (ignore errors if it doesn't exist)
            subprocess.run(
                ["security", "delete-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME],
                capture_output=True, timeout=5,
            )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
["security", "delete-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME],
                capture_output=True, timeout=5,
            )
            r = subprocess.run(
                ["security", "add-generic-password", "-a", os.getenv("USER", ""), "-s", SERVICE_NAME, "-w", api_key],
                capture_output=True, text=True, timeout=5,
            )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
)
            return r.returncode == 0
        elif system == "Linux":
            r = subprocess.run(
                ["secret-tool", "store", "--label=CodeAlive API Key", "service", SERVICE_NAME],
                input=api_key, capture_output=True, text=True, timeout=10,
            )
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
)
            return r.returncode == 0
        elif system == "Windows":
            r = subprocess.run(
                ["cmdkey", f"/generic:{SERVICE_NAME}", "/user:codealive", f"/pass:{api_key}"],
                capture_output=True, text=True, timeout=10,
            )
Confidence
83% confidence
Finding
On Windows, the API key is passed directly on the `cmdkey` command line as `/pass:{api_key}`. Command-line arguments can often be observed by other local processes, shell history tooling, EDR products, or diagnostic logs, which can expose the secret during setup.

Context-Inappropriate Capability

Low
Confidence
82% confidence
Finding
The manifest describes semantic code search and codebase Q&A, but does not mention local credential discovery from environment variables, macOS Keychain, Linux secret-tool, or Windows Credential Manager. While authentication to the remote CodeAlive service is expected, implementing OS-specific secret-store access is an additional local capability not justified by the stated purpose alone.

Intent-Code Divergence

Low
Confidence
93% confidence
Finding
The docstring says API key resolution uses the explicit parameter, environment variable, and 'macOS Keychain', but the implementation calls _get_key_from_keychain(), which also reads Linux secret-tool and Windows Credential Manager. This is not merely missing detail elsewhere; the stated resolution order actively understates what local credential sources are accessed.

Static analysis

No suspicious patterns detected.