T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/service_layer/db_bridge.py:618- Finding
Arbitrary SQL execution bypasses table-level access controls
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This database skill is mostly purpose-aligned, but it has serious credential, cloud-audit, and SQL-control weaknesses that users should review before installing.
Install only after treating this as an administrative database tool with production-impacting authority. Use a least-privilege database account, keep read_only enabled unless writes are intended, enable require_explicit_credential_approval, do not run config or CRUD commands where output is logged, verify cloud_audit_url before use, and rotate any cloud API key or database password that may have been printed or stored by this version.
scripts/service_layer/db_bridge.py:618Arbitrary SQL execution bypasses table-level access controls
scripts/service_layer/main.py:256The config command discloses the complete cloud API key
scripts/controller_layer/sql_linker.py:585Configurable cloud endpoint can receive API credentials and sensitive audit metadata without origin validation
scripts/controller_layer/sql_linker.py:479Database passwords are protected with weak custom encryption and a locally stored six-character key
scripts/service_layer/main.py:84Database values and query parameters are logged to standard output without redaction
This code chunk’s primary purpose is audit logging, not a general SQL CLI. While it is compatible with MySQL/PostgreSQL/SQLite, that support is limited to creating and writing/querying an audit table based on an already-established connection. The declared description promises a much broader tool: CRUD operations, config generation, credential handling, cloud audit synchronization, and approval gating. None of those headline capabilities appear in this code. The chunk also does not use outbound network access, environment read/write, or file read/write despite those being declared. Over-declared permissions alone are not a mismatch, but the absence of the core declared capabilities makes the description materially inaccurate for this code chunk.
The skill uses 'env' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.
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.
| Error | Cause | Solution |
| -------------------------------------------------------- | --------------------------- | -------------------------------------------------------------------------------------- |
| `Silent credential access requires explicit approval...` | Gate enabled, no approval | Re-run with `--approve` (CLI) or call `db.explicit_credential_approval(True)` (Python) |
| `cloud_api_key is not configured` | Missing in config | Get from portal and fill in |
| `Cloud unreachable: Network error...` | Cannot reach cloud | Check network; verify URL ends with `/api/audit/logs` |
| `Password not found` | Env variable not set | Run `set_env.ps1` / `set_env.sh` |
The skill performs remote API-key introspection and fetches dbpw_key material from a cloud service before resolving database credentials, which creates an unnecessary dependency on a third-party endpoint for secret retrieval and identity validation. In this skill context, that is more dangerous because the tool already has outbound network, file, and environment permissions, so a compromised or malicious cloud service could influence local credential access, exfiltrate operational metadata, or deny database access.
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.
# set_env.sh - Encrypted MySQL password setup (reads dbpw_key from config)
# Run: eval "$(./set_env.sh)" to apply in current session
#
# Security Notice: This script does NOT automatically modify ~/.bashrc or ~/.zshrc.
# You must manually add the export line to your shell config if you want persistence.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
The bridge exposes a require_cloud_api_key() path for cloud audit sync but does not provide a strong user-facing warning at the point of use that database activity may be transmitted to a remote endpoint configured in bootstrap defaults. In this skill context, outbound network permission plus preconfigured cloud audit infrastructure increases risk of unintended metadata or query audit exfiltration, especially if operators assume the tool is local-only.
The function docstring says Execute SELECT query, and the CLI parser help similarly describes the subcommand as a SELECT query interface. However, the code immediately warns that the command accepts arbitrary SQL and then passes the raw SQL to db.query(sql, params), so the inline documentation contradicts the actual capability.
The config command prints file paths, table metadata, and the full audit configuration without any approval gate or warning. In this skill's context, the audit config may contain sensitive operational details such as remote endpoints, identifiers, and policy data that materially aid reconnaissance or expose internal integration details to anyone invoking the command.
The document consistently mandates bilingual Chinese and English sections as the presentation format, rather than stating language support as optional or user-selectable. This can violate a language/locale policy when a skill implicitly enforces a specific locale pair without asking the user which language they prefer.
The documentation explicitly states that the query command accepts arbitrary SQL and is not limited to SELECT. In a skill with database access, credential handling, file access, and outbound networking, allowing unrestricted SQL substantially increases the risk of destructive modification, privilege abuse, and sensitive data exposure, especially if operators assume 'query' is read-only.
>
> 3. **Bootstrap File Creation**: `bootstrap` command creates config files in `.sql_linker/` directory. `set_env.ps1/sh` generate encrypted credentials for OS environment variables (user-scope). User must manually add export line to shell config for persistence.
>
> 4. **Arbitrary SQL**: The `query` command accepts any SQL text (not limited to SELECT). Use parameterized queries to prevent injection.
### 中文
The file includes a user-facing status message in Chinese and English (只读模式禁止插入 / Read-only mode: insert blocked) rather than consistently honoring the user's preferred locale. Under the natural-language policy rule, forcing a specific language or bilingual output without a documented opt-in can violate locale policy expectations.
This printed message combines Chinese and English (只读模式禁止更新 / Read-only mode: update blocked) without any visible locale selection mechanism. That creates a natural-language policy concern because the skill is choosing output language behavior on behalf of the user.
The delete-blocked message is hard-coded in both Chinese and English, with no indication that the user requested bilingual output. This is a locale-policy issue because the skill does not offer a language choice or justify the forced mixed-language presentation.
The docstring and inline comment say the method updates audit_config.json only if the username field is empty and should not replace user-set values. However, in the non-empty case the code assigns self._username = current, and elsewhere cloud sync paths still treat cloud-derived agent data as authoritative for synchronization behavior, making the documentation overstate the non-overwrite guarantee.
The comment says the script does not automatically modify ~/.bashrc or ~/.zshrc, framing persistence as out of scope for the script itself. However, later output explicitly tells the user to add an export line to those files, which creates persistent credential storage behavior that the comment downplays in the documented intent.
The file includes user-facing natural-language text in both Chinese and English, such as the bootstrap docstring and printed dry-run message, without indicating that the user can choose a preferred language. This can violate a language/locale policy when a specific language experience is imposed without opt-in.
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.
def cmd_query(args):
"""Execute SELECT query."""
print("[Security] ⚠️ The query command accepts arbitrary SQL (not limited to SELECT).")
print(" Use parameterized queries (--params) to prevent injection attacks.")
print("")
db = DBBridge(user_label="cli", session_id="query", approved=getattr(args, 'approve', False))
The docstring and parser help frame this command as requiring no connection, which can imply a local-only status check. In reality, fetch_api_key_info() performs remote cloud introspection and the handler explicitly treats network unreachability as an error, so the documentation misstates the operational dependency.
No suspicious patterns detected.