T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:78- Finding
Unrestricted OCR API Base Can Expose Credentials and Sensitive Documents
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill does degree-certificate OCR as advertised, but it uploads sensitive documents with an API key to a configurable remote endpoint without strong scoping or privacy guidance.
Install only if you are comfortable sending degree-certificate files to Scnet or the configured API base. Keep SCNET_API_BASE at the documented HTTPS Scnet endpoint unless you intentionally trust another server, protect config/.env, and avoid uploading certificates containing personal data without consent.
scripts/main.py:78Unrestricted OCR API Base Can Expose Credentials and Sensitive Documents
SKILL.md:66Unpinned Third-Party Dependency Installation
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"
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 clearly requires reading a local file path, invoking Python/shell, and sending data to a remote OCR API, but the manifest does not declare any explicit tool scope or permissions. This creates an authorization and transparency gap: an agent may invoke broader capabilities than a user expects, especially because local documents are being transmitted off-host.
The manifest description is entirely in Chinese and presents the skill as operating in Chinese without any indication that users may choose another language or that the Chinese-only scope is required for a region-specific compliance reason. Under the policy, language or locale constraints should either be optional for the user or clearly justified.
The skill is designed to send user-provided certificate images and extracted OCR content to an external API endpoint. Because degree certificates contain sensitive personal data, this external transmission creates a real privacy and data-handling risk unless it is explicitly disclosed and consented to.
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 configuration section reinforces that all OCR requests are sent to a remote base URL, meaning sensitive document images and extracted text leave the local environment. In the context of academic certificates, this is material because the data commonly includes names, institutions, degree details, and dates.
| 变量名 | 默认值 | 说明 |
|--------|--------|------|
| SCNET_API_KEY | 必需 | Scnet API 密钥 |
| SCNET_API_BASE | https://api.scnet.cn/api/llm/v1 | API 基础地址(一般无需修改) |
### 输出
The skill sends uploaded OCR documents to an external endpoint, which is a real data-exposure risk because degree certificates and related identity records are sensitive personal information. The skill context makes this more dangerous: the feature's core purpose is processing official documents, so external transmission can expose names, issuing institutions, dates, and potentially other embedded PII to a third-party service.
# Sugon-Scnet OCR API 文档摘要
## 接口地址
`POST https://api.scnet.cn/api/llm/v1/ocr/recognize`
## 请求头
- `Content-Type: multipart/form-data`
The documentation instructs users to upload highly sensitive identity and certificate images, but it does not warn about privacy, data handling, retention, third-party processing, or compliance requirements. In this skill context, the omission is more dangerous because degree certificates and OCR outputs contain personal data that may be transmitted to an external service without informed consent or proper safeguards.
This Python file contains natural-language descriptions and runtime messages entirely in Chinese, including the module docstring and CLI usage/help text. Under the stated policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly documented and justified, which is not present here.
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 uploads user-supplied certificate files to an external OCR service at api.scnet.cn, which constitutes transmission of potentially sensitive personal data off-host. In the context of degree certificates, the uploaded content can include PII such as names, institutions, degree types, and dates, so external transfer materially increases privacy and compliance risk even if the destination is the intended OCR provider.
)
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 manifest description is written entirely in Chinese and provides no indication that the skill supports other languages or that the Chinese-only locale is an intentional, justified constraint. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation.
The changelog is entirely written in Chinese, beginning with the heading '变更日志' and the entry '新增学位证书识别'. This indicates a language-specific presentation without any visible user choice, opt-in, or documented regional justification, which can violate language/locale policy requirements.
The manifest description and main body consistently describe a skill for 学位证书识别 only, but the declared tags include broader categories such as '发票识别' and generic '文字提取'. This creates a semantic mismatch in how the skill is presented, suggesting capabilities beyond the narrowly described degree-certificate OCR purpose.
The file content, headings, parameter descriptions, and notes are all presented in Chinese, which effectively forces a specific language for users of this skill documentation. There is no indication that this is a region-specific or Chinese-only skill, nor any user opt-in or alternate language option.