T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:86- Finding
Unrestricted OCR Endpoint Enables Credential and Local File Disclosure
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This OCR skill appears functional, but it needs review because it can upload local documents and its API token to a configurable external endpoint with limited safeguards.
Review before installing. Use this only for documents you are comfortable sending to Scnet, keep the API key local and protected, leave SCNET_API_BASE at the official HTTPS endpoint unless you fully trust the replacement, and avoid letting the agent invoke it automatically on arbitrary file paths.
scripts/main.py:86Unrestricted OCR Endpoint Enables Credential and Local File Disclosure
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 # 最大重试次数
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"
This changelog is entirely written in Chinese, with no indication that the skill offers users a language choice or that the locale restriction is required for a region-specific purpose. Under the policy, forcing a specific language without user opt-in is a natural-language policy concern.
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 documentation declares capabilities that imply reading local files, making outbound network requests, and invoking Python from the shell, but it does not declare any explicit tool scope or allowed-tools boundary. This weakens policy enforcement and increases the chance the agent can invoke broader-than-intended capabilities when auto-triggered.
The top-level description says the skill should be used whenever a user needs OCR or certificate recognition, which is broad enough to cause over-triggering. In this skill's context, accidental triggering matters because it can read a local file and send its contents to a third-party OCR provider without a tightly scoped user intent check.
The documentation describes OCR processing of local files but does not clearly warn that the file contents will be transmitted to a third-party Scnet API. In the context of certificate OCR, the files may contain business registration data or other sensitive identifiers, so missing consent and privacy disclosure materially increases data exposure risk.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
SCNET_API_KEY=your_scnet_api_key_here
SCNET_API_BASE=https://api.scnet.cn/api/llm/v1
2. 添加:`SCNET_API_KEY=你的密钥`
3. 设置文件权限为 600(仅所有者可读写)
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
SCNET_API_KEY=your_scnet_api_key_here
SCNET_API_BASE=https://api.scnet.cn/api/llm/v1
2. 添加:`SCNET_API_KEY=你的密钥`
3. 设置文件权限为 600(仅所有者可读写)
Stating that the AI will 'automatically trigger based on keywords' without enumerating the keywords or contextual constraints creates unsafe ambiguity. Because the skill transmits local image/PDF content to an external service, vague auto-triggering can lead to unintended disclosure of sensitive documents.
The skill is designed to upload user-provided files to an external OCR service at api.scnet.cn, which constitutes third-party transmission of potentially sensitive documents. Because the documented inputs include business certificates and images/PDFs/archives, the transmitted data may contain regulated or confidential information, making this a real data-exposure risk even if the integration is functionally intended.
# Sugon-Scnet OCR API 文档摘要
## 接口地址
`POST https://api.scnet.cn/api/llm/v1/ocr/recognize`
## 请求头
- `Content-Type: multipart/form-data`
The script's user-facing description and all runtime messages are exclusively in Chinese, with no indication that the user can choose another language or locale. This can violate language/locale policy when skills are expected to avoid forcing a specific language without explicit opt-in or documented regional limitation.
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)
The skill transmits user-supplied files to an external OCR service at api.scnet.cn, which is a real data exfiltration boundary. In context, this is core to the skill's function, but it is still security-relevant because sensitive documents may be uploaded off-host without explicit validation, consent, or data-classification checks.
)
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 body documentation says the skill invokes '1 种识别能力' and lists only '统一社会信用代码证书', while the manifest description and tags also claim general image text OCR and '发票识别'. This is an active inconsistency in the skill's own documentation about what the skill is intended to do.
The manifest description is written only in Chinese and gives no indication that the skill is region-specific or that users may choose another language. Under the policy, language/locale constraints should be opt-in or explicitly justified.