T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:77- Finding
Unrestricted API Endpoint Can Disclose Identity Documents and API Credentials
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a real SCNet OCR wrapper, but it can upload sensitive identity documents or other local files to a configurable external endpoint with limited privacy disclosure and weak scoping.
Review before installing. Use it only if you are comfortable sending ID-card or document images to SCNet's cloud OCR service. Keep SCNET_API_BASE pointed at the intended SCNet HTTPS endpoint, do not pass unrelated sensitive files, and rotate the API key if the config file or endpoint may have been altered.
scripts/main.py:77Unrestricted API Endpoint Can Disclose Identity Documents and API Credentials
scripts/main.py:89Missing Input Validation Allows Arbitrary Local Files to Be Uploaded
This skill handles highly sensitive personal identity documents, yet the documentation does not clearly and prominently warn that local image files and extracted identity data are sent to a third-party OCR service. That creates a significant privacy and compliance risk because users may unknowingly transmit PII such as ID numbers, names, birth dates, and addresses off-device.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 获取技能根目录(脚本所在目录的上一级)
SKILL_ROOT = Path(__file__).parent.parent.absolute()
ENV_FILE = SKILL_ROOT / "config" / ".env"
# --- 新增:重试配置 ---
MAX_RETRIES = 3 # 最大重试次数
RETRY_BACKOFF_FACTOR = 2 # 退避因子,每次重试等待时间翻倍
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# --------------------
def load_config():
"""从 .env 文件加载配置,若文件不存在则抛出友好错误"""
if not ENV_FILE.exists():
error_msg = (
"\n===============================================\n"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# --------------------
def load_config():
"""从 .env 文件加载配置,若文件不存在则抛出友好错误"""
if not ENV_FILE.exists():
error_msg = (
"\n===============================================\n"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# --------------------
def load_config():
"""从 .env 文件加载配置,若文件不存在则抛出友好错误"""
if not ENV_FILE.exists():
error_msg = (
"\n===============================================\n"
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
The skill declares capabilities that imply local file access, network access, and shell execution, but it does not define an explicit tool scope such as permissions or allowed-tools. In an agent setting, that ambiguity can enable broader-than-expected execution and data access, especially because the skill processes local files and sends content to a remote API.
The metadata presents this as a personal ID OCR skill, but the body advertises broader OCR use cases such as bank cards, invoices, and generic text extraction. That mismatch can cause users or orchestrators to invoke the skill on more sensitive or unintended documents than expected, expanding data exposure and undermining consent boundaries.
The documentation identifies a remote API endpoint, confirming that local document content will be transmitted externally for processing. In the context of ID-card OCR, this is security-relevant because the transmitted data is highly sensitive personal information, and external transfer materially increases privacy, compliance, and breach exposure.
SCNET_API_KEY=your_scnet_api_key_here
SCNET_API_BASE=https://api.scnet.cn/api/llm/v1
2. 添加:`SCNET_API_KEY=你的密钥`
3. 设置文件权限为 600(仅所有者可读写)
The usage examples encourage invoice and generic text OCR even though the declared input limits ocrType to ID_CARD. This inconsistency can lead to unintended execution on unrelated local files and transmission of data the user did not expect this skill to handle.
The trigger guidance is broad enough to match general OCR requests, not just personal ID recognition. In an agent environment, overly broad invocation criteria can cause accidental activation on arbitrary files, increasing the chance of sensitive document exfiltration to the external OCR provider.
The configuration section again specifies the remote API base, reinforcing that this skill depends on sending data to an external service. Because the skill processes identity documents, this external transmission is a meaningful security concern unless clearly disclosed and tightly scoped.
| 变量名 | 默认值 | 说明 |
|--------|--------|------|
| SCNET_API_KEY | 必需 | Scnet API 密钥 |
| SCNET_API_BASE | https://api.scnet.cn/api/llm/v1 | API 基础地址(一般无需修改) |
### 输出
The skill sends uploaded identity-document images and extracted OCR content to an external third-party API endpoint, which constitutes external transmission of highly sensitive personal data. In this skill context, the data includes government ID images and fields such as name, address, birth date, and ID number, making any unintended sharing, retention, or compromise significantly more dangerous than a generic external API call.
# Sugon-Scnet OCR API 文档摘要
## 接口地址
`POST https://api.scnet.cn/api/llm/v1/ocr/recognize`
## 请求头
- `Content-Type: multipart/form-data`
The module docstring presents the skill name, inputs, and outputs only in Chinese, and the command-line help and runtime messages throughout the file are likewise Chinese-only. This creates a language policy concern because the skill effectively enforces a specific language without any opt-in or alternative locale support.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
" b) 配置文件:\n"
f" mkdir -p {SKILL_ROOT}/config\n"
f" echo 'SCNET_API_KEY=你的密钥' > {ENV_FILE}\n"
f" chmod 600 {ENV_FILE}\n"
"\n配置完成后重新运行。"
)
sys.exit(error_msg)
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
" b) 配置文件:\n"
f" mkdir -p {SKILL_ROOT}/config\n"
f" echo 'SCNET_API_KEY=你的密钥' > {ENV_FILE}\n"
f" chmod 600 {ENV_FILE}\n"
"\n配置完成后重新运行。"
)
sys.exit(error_msg)
This skill sends uploaded identity-document images and extracted PII to an external third-party OCR API at api.scnet.cn. Because the skill processes highly sensitive national ID data, external transmission materially increases privacy, compliance, and data-handling risk, especially if users are not explicitly informed and the endpoint/operator is not tightly controlled.
)
sys.exit(error_msg)
config.setdefault('SCNET_API_BASE', 'https://api.scnet.cn/api/llm/v1')
return config
def recognize_with_retry(ocr_type, file_path, config, retry_count=0):
The natural-language description is written only in Chinese and is narrowly scoped to Chinese national ID cards, but the manifest does not explicitly document this locale constraint as a region-specific limitation or offer language choice. This can violate language/locale policy expectations when users are not informed of or opting into the locale-specific behavior.
The natural-language instructions and examples are presented only in Chinese, which effectively imposes a specific language on users. The file does not indicate that this is region-specific or provide an alternative language option.
该文档全文仅以中文呈现,未说明这是面向特定中文用户群体或区域场景的受限文档,也未提供其他语言选项。根据语言/地区策略,若技能或说明材料隐含强制特定语言而无用户选择或合理限定,可构成自然语言层面的策略问题。
This manifest describes the skill's OCR capability but does not state when the skill should or should not be invoked, nor provide any trigger phrases or exclusion conditions. For manifest files, missing specificity around invocation scope can lead to overly broad matching by orchestrators or assistants.