Back to skill

Security audit

Api Push Frontend

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent, but it uploads potentially sensitive internal API definitions to a fixed external service, stores raw response history inside the skill tree, and includes an unused shell-execution helper.

Install only if the destination service is approved for your organization and you are comfortable sending API metadata there. Review and redact API definitions first, especially admin, user-management, role, delete, password, token, internal URL, and credential-related fields. Treat the saved push history as sensitive and remove or relocate it if it may be loaded by agents or committed to source control.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • 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

Warning
Location
scripts/push_api_to_frontend.py:29
Finding
Latent Arbitrary Command Execution Through an Unsafe Shell Helper<![CDATA[ ## Vulnerability Details **File Location**: `scripts/push_api_to_frontend.py`, lines 29–45 **Vulnerability Type**: Shell command injection primitive **Risk Level**: Medium ### Vulnerable Code ```python def run_command(cmd, capture=True): """执行 shell 命令""" import subprocess try: result = subprocess.run( cmd, shell=True, capture_output=capture, text=True, timeout=60 ) return result.returncode, result.stdout, result.stderr except subprocess.TimeoutExpired: return -1, "", "Command timed out" except Exception as e: return -1, "", str(e) ``` ### Technical Analysis The helper passes an arbitrary string directly to `subprocess.run()` with `shell=True`. Consequently, the operating system shell interprets separators, substitutions, redirections, and other shell syntax contained in `cmd`. If an attacker-controlled value ever reaches this function, payloads containing shell metacharacters could execute additional commands. The helper is not called by the current project, so there is no presently reachable command-injection path through the documented workflow. Nevertheless, it is an unnecessary high-risk primitive that exceeds the capabilities required to upload API definitions and creates a latent vulnerability if reused during future maintenance. ### Attack Path The prerequisite for exploitation is that this currently unused helper becomes connected to an input source: 1. A future code change passes a command containing a filename, API field, interactive value, or other attacker-controlled text to `run_command()`. 2. The attacker supplies shell syntax in that value. 3. `subprocess.run()` invokes the operating system shell because `shell=True`. 4. The shell interprets the injected syntax as commands rather than treating it as a literal argument. 5. Those commands execute with the same operating-system identity and permissions as the S ...[truncated 634 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `run_command()` because the current API-upload workflow does not use or require local command execution. 2. If process execution is later required, provide the executable and arguments as a fixed list and retain the default `shell=False` behavior: ```python subprocess.run( ["fixed-program", "--fixed-option", validated_value], shell=False, capture_output=True, text=True, timeout=60, check=False, ) ``` 3. Allowlist executable names and accepted argument formats. 4. Do not construct command strings by concatenating or interpolating user-controlled values. 5. Run any required child process with minimal filesystem and network privileges. 6. Add a static-analysis rule that rejects `shell=True` unless a reviewed exception is documented. ]]>

T02 · Agent Memory Poisoning

Warning
Location
scripts/push_api_to_frontend.py:173
Finding
Persistent Agent-Context Poisoning Through Untrusted Server Responses<![CDATA[ ## Vulnerability Details **File Location**: `scripts/push_api_to_frontend.py`, lines 173–207 **Vulnerability Type**: Persistent storage of attacker-controlled remote content in an Agent-readable reference file **Risk Level**: Medium ### Vulnerable Code ```python def save_push_history(prd_id, api_definitions, result, success): """保存推送历史""" history_file = Path(__file__).parent.parent / "api-push-frontend" / "references" / "push-history.md" history_file.parent.mkdir(parents=True, exist_ok=True) timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") status = "✅ 成功" if success else "❌ 失败" api_count = len(api_definitions) # 读取现有历史 existing_content = "" if history_file.exists(): with open(history_file, 'r', encoding='utf-8') as f: existing_content = f.read() # 添加新记录 new_record = f""" ## {timestamp} - **时间**: {timestamp} - **prdId**: {prd_id} - **接口数量**: {api_count} - **状态**: {status} - **响应**: ```json {json.dumps(result, ensure_ascii=False, indent=2)} ``` --- """ # 写入文件(新记录在前) with open(history_file, 'w', encoding='utf-8') as f: f.write(f"# API 推送历史记录\n\n{new_record}{existing_content.replace('# API 推送历史记录\\n\\n', '')}") print(f"📝 推送历史已保存到:{history_file}") ``` ### Technical Analysis The function writes the complete remote API response into `api-push-frontend/references/push-history.md` without an allowlist, size restriction, content neutralization, or trust-boundary marker. Although `json.dumps()` serializes the response as JSON, it does not neutralize Markdown fence delimiters or instruction-like text. A response string containing backticks can terminate the intended fenced block and inject ordinary Markdown. More broadly, even content that remains inside the block can be consumed as contextual text by an AI Agent. The destination is especially sensitive because it is under a `references` directory within the Skill package. Future Agent s ...[truncated 1914 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not store raw server responses in a Skill `references` directory. 2. Move operational logs to a dedicated runtime data or log directory that is not automatically loaded as Agent instructions. 3. Persist only an allowlisted response summary, such as status code, upload identifier, API count, and timestamp. 4. Enforce strict maximum response and history-file sizes. 5. Treat every remote response field as untrusted data and clearly label it as non-instructional content. 6. If raw diagnostic content must be retained, use a structured data format such as JSON rather than Markdown and keep it outside Agent context. 7. Prevent Markdown fence breakout by encoding or escaping untrusted content before presentation. 8. Apply restrictive filesystem permissions and avoid committing generated history to source control. 9. Add retention and redaction controls for credentials, tokens, personal information, internal URLs, and other sensitive fields. 10. Before an Agent consumes historical records, parse only the required structured fields rather than loading the complete file into its instruction context. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (17)

Ae1

High
Category
analysis-evasion
Content
python3 scripts/push_api_to_frontend.py --prdId "PRD-2026-001" --file ./api-definitions.json
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Tool Parameter Abuse

High
Category
Tool Misuse
Content
"""执行 shell 命令"""
    import subprocess
    try:
        result = subprocess.run(
            cmd,
            shell=True,
            capture_output=capture,
Confidence
98% confidence
Finding
Using shell=True with subprocess.run is a classic command-injection sink because shell metacharacters are interpreted by the shell rather than treated as data. In an agent skill context, where tools may eventually be composed with model-generated or user-provided values, this is especially dangerous because seemingly harmless strings can become executable commands.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill describes capabilities that imply shell execution, network access, and reading/writing local files, but it does not declare any explicit tool scope or permission boundaries. This increases the risk of over-privileged execution because an agent could invoke broader tools than the user expects when pushing API data or writing history logs.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The skill instructs users to transmit backend API definitions to an external platform, which may include sensitive internal endpoints, parameters, schemas, and authentication-related details, but it provides no warning, approval gate, or data-classification check. In this context, the lack of safeguards is more dangerous because the stated purpose is exfiltration of internal interface metadata to a remote service.

Vague Triggers

Medium
Confidence
88% confidence
Finding
The natural-language invocation model is too open-ended: 'directly tell me your requirement, I guide you to complete the push' does not define clear boundaries for when the skill should activate or what approvals are needed. This can cause accidental triggering and unintended uploads of sensitive API documentation, especially when combined with network and file capabilities.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The push history shows this skill synchronizing a broad set of system-management APIs, including configuration, environment, product, project, menu, role, user, and user-role administration endpoints, which exceeds the narrow purpose suggested by the skill description of pushing backend API definitions to a frontend platform. This creates scope-expansion risk: a frontend-facing sync process can unintentionally expose or operationalize sensitive administrative capabilities in downstream systems, increasing attack surface and enabling misuse if the synced definitions are later consumed by less-trusted users or tooling.

Missing User Warnings

Medium
Confidence
85% confidence
Finding
This markdown history records sensitive API metadata, including credential-related fields and destructive operations such as delete endpoints, without any warning, minimization, or handling guidance. Even though this file is documentation, it can still leak operational knowledge about privileged capabilities and encourage unsafe propagation of high-impact interfaces to consumers who may not understand the security implications.

Context-Inappropriate Capability

Medium
Confidence
93% confidence
Finding
The recorded synced definitions include sensitive account and access-management fields such as accessAccount, accessPassword, and user/password parameters, which are not justified by a simple frontend API-push function. Publishing or propagating these schemas can normalize handling of credential-bearing interfaces in broader tooling, and may lead to credential exposure, insecure client integration, or unauthorized administrative actions if surfaced in frontend platforms.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The document instructs users to upload API definitions to an external HTTPS endpoint but provides no warning about the sensitivity of the transmitted content, tenant boundaries, or approval requirements. API definitions often contain internal paths, parameter schemas, authentication expectations, and business logic details, so normalizing blind transmission to a remote service can cause unreviewed disclosure of internal system metadata.

External Transmission

Medium
Category
Data Exfiltration
Content
}
```

### cURL 示例

```bash
curl -X POST "https://jffe.techgp.cn/md/api/uploadV4" \
Confidence
94% confidence
Finding
The cURL example provides a ready-to-run command that posts API definitions to an external service, making exfiltration of internal interface details easy to perform. Because the skill’s purpose is pushing backend API definitions to a remote frontend platform, the surrounding context makes the external transmission more security-relevant, not less, especially if users treat all API schemas as safe by default.

External Transmission

Medium
Category
Data Exfiltration
Content
### JavaScript 示例

```javascript
fetch('https://jffe.techgp.cn/md/api/uploadV4', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
Confidence
95% confidence
Finding
The JavaScript example sends API definition content from a client context to an external endpoint. Even though it is illustrative documentation, it operationalizes outbound transfer of potentially sensitive design information and may be copied into real workflows without safeguards such as auth, origin restrictions, or content review.

External Transmission

Medium
Category
Data Exfiltration
Content
]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```
Confidence
95% confidence
Finding
The Python example performs a live POST of structured API definition data to an external domain. In the context of this skill, that encourages direct transmission of potentially sensitive internal API metadata without any mention of authentication, environment restrictions, consent, or redaction, which increases the risk of unintended data disclosure.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
The module docstring, CLI description, help text, and interactive prompts are written in Chinese only, which imposes a specific language on users. The policy allows locale constraints only when users are given a choice or the restriction is clearly justified, neither of which is present here.

Context-Inappropriate Capability

Medium
Confidence
96% confidence
Finding
Including shell-command execution capability in a script whose stated purpose is only to parse API definitions and upload them to a frontend platform violates least functionality. Unrelated execution primitives are dangerous because they expand the attack surface and can be repurposed for arbitrary command execution if the code is later wired to user-controlled inputs or copied into other automation contexts.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
"""执行 shell 命令"""
    import subprocess
    try:
        result = subprocess.run(
            cmd,
            shell=True,
            capture_output=capture,
Confidence
97% confidence
Finding
The script defines a generic shell execution helper using subprocess.run(..., shell=True), which can execute arbitrary shell commands if the cmd argument is influenced by external input. Even though this helper is not used elsewhere in the file, retaining dormant command-execution capability in a data-push utility materially increases the risk of later abuse, unsafe reuse, or accidental exposure through future changes.

Missing User Warnings

Low
Confidence
83% confidence
Finding
This is a markdown file, so SQP-2 applies to missing warnings in documentation. The document provides a concrete DELETE interface example for deleting orders, but it does not include any warning about destructive effects, recovery limitations, or recommended confirmation safeguards, which are relevant when documenting behaviors that can affect user data or system integrity.

Natural-Language Policy Violations

Low
Confidence
79% confidence
Finding
The best-practices section directs users to use English or a single naming language, which constitutes a natural-language locale/language constraint. Because the document does not present this as an optional preference or justify it as a region-specific requirement, it may violate the language-choice policy.

Static analysis

No suspicious patterns detected.