T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:78- Finding
Unrestricted OCR API endpoint permits disclosure of the API credential and selected local file
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This OCR skill is mostly coherent and disclosed, but it can send a user-selected sensitive document and API token to a configurable network endpoint without validating that the endpoint is Scnet.
Review before installing. Only use this with bill-of-lading files you are authorized to upload to Scnet, and do not place regulated or confidential documents through it unless your organization approves that vendor. Keep SCNET_API_BASE fixed to the documented https://api.scnet.cn/api/llm/v1 endpoint or add endpoint validation before use, because a changed value could send both the document and API key elsewhere.
scripts/main.py:78Unrestricted OCR API endpoint permits disclosure of the API credential and selected local file
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 documentation declares capabilities to read local files, invoke Python from the shell, and transmit data over the network, but it does not define an explicit tool scope such as permissions or allowed-tools. This creates a governance gap: an agent/runtime may permit broader execution than users expect, increasing the chance of unintended file access or exfiltration when the skill is invoked.
The manifest description at L003 forces a specific language presentation, and the rest of the skill documentation is likewise Chinese-only. Under the policy, language constraints should either be optional for the user or clearly justified as region-specific; neither is stated here.
The skill explicitly uploads user-selected local bill-of-lading files to an external OCR service at api.scnet.cn. Because these documents may contain commercial or personal data, this creates a real data-exfiltration/privacy risk if users misunderstand the workflow, provide sensitive files, or if the external service is not approved for the data involved.
## 前置配置
> **⚠️ 数据外传警告**:本技能调用 Scnet 在线 OCR 服务,你需要将待识别的本地文件上传至 `https://api.scnet.cn/api/llm/v1/ocr/recognize`。提单中可能包含商业敏感信息或个人数据,请确保你有权将该文件内容外传,并建议仅使用可信来源文件。
> **⚠️ 重要**:使用前需要申请 Scnet API Token
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(仅所有者可读写)
The documentation explicitly states that uploaded local files are sent to an external OCR service at api.scnet.cn. Because the skill processes bills of lading and related shipping documents, this can expose commercially sensitive and potentially personal data to a third-party service, creating a real data exfiltration and compliance risk even if it is part of the intended design.
> **⚠️ 数据外传警告**:调用本接口会将你上传的本地文件发送至 Scnet 外部 OCR 服务(`https://api.scnet.cn`)。提单等单据可能包含收发货人、航次、货量、联系方式等商业或个人信息,请确认你有权外传该文件内容,并仅上传可信来源文件。
## 接口地址
`POST https://api.scnet.cn/api/llm/v1/ocr/recognize`
## 请求头
- `Content-Type: multipart/form-data`
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 sends user-supplied document files and an API token to an external third-party endpoint at api.scnet.cn for OCR processing. In the context of bills of lading, the uploaded documents can contain commercially sensitive shipping, consignee, cargo, and carrier data, so this creates a real data exfiltration and privacy/compliance risk if users are unaware or if the remote service is untrusted or compromised.
)
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 description only says the skill extracts core bill-of-lading information, but does not define clear invocation boundaries, supported document types, or exclusion conditions. In an agentic system, this can cause overbroad routing of arbitrary documents containing text or logistics terms, increasing the chance of unnecessary file access, OCR on unrelated sensitive files, and unintended network transmission to the external OCR service.
The skill description is written to operate in Chinese without stating that this is optional, locale-driven, or selected by the user. This can bias agent behavior toward Chinese-language handling or responses in contexts where the user did not request it, leading to misrouting, incorrect extraction assumptions, or user-confusing behavior rather than direct code execution risk.
The changelog content is entirely in Chinese, beginning with the title and continuing through the release notes, with no indication that the language is optional or that the skill is region-specific. Under the policy rule for natural-language violations, this can be treated as forcing a specific language without user opt-in.
The file’s user-facing natural-language content is entirely in Chinese and does not indicate any option to use another language or locale. Under the stated policy, forcing a specific language without user opt-in can be a policy violation unless the locale constraint is clearly documented and justified.