T09 · Insecure Skill Coding Practices
- Location
kb-search.sh:21- Finding
Bearer Token Transmitted Over Plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
kb-search.sh, lines 21–24, 34, and 62–63
Vulnerability Type: Plaintext transmission of authentication credentials
Risk Level: MediumTechnical Analysis
The helper defaults to an unencrypted HTTP endpoint and adds
JISHUDB_TOKENas a bearer token without enforcing HTTPS:bash # JISHUDB_URL base URL of the KB service (default http://host.docker.internal:18089) # JISHUDB_DEFAULT_KB kb id used when none is given (optional) # JISHUDB_TOKEN bearer token if the KB has auth enabled (optional) set -uo pipefail BASE="${JISHUDB_URL:-http://host.docker.internal:18089}"; BASE="${BASE%/}" AUTH=(); [ -n "${JISHUDB_TOKEN:-}" ] && AUTH=(-H "authorization: Bearer ${JISHUDB_TOKEN}")The token-bearing header is then supplied to both supported API operations:
bash resp=$(curl -sS --max-time 15 "${AUTH[@]}" "$BASE/api/kb") \ || die "cannot reach KB at $BASE — is the 知识库 (JishuDB) app running in the panel?"bash resp=$(curl -sS --max-time 40 "${AUTH[@]}" -H 'content-type: application/json' \ -X POST "$BASE/api/kb/$KB/search" -d "$payload") \ || die "cannot reach KB at $BASE — is the 知识库 app running?"When
JISHUDB_TOKENis configured while the default endpoint—or any other plaintext HTTP endpoint—is used, the bearer credential crosses the process/container network boundary without transport encryption. The script performs no URL-scheme validation and does not reject this combination.Attack Path
- The environment supplies a valid
JISHUDB_TOKEN. JISHUDB_URLis unset, causing the helper to usehttp://host.docker.internal:18089, or it is explicitly set to another HTTP endpoint.- The agent invokes either the
listorsearchoperation. curlsends the bearer token in the plaintextAuthorizationheader.- An attacker capable of observing or manipulating the relevant container-to-host or n ...[truncated 919 chars]
- The environment supplies a valid
- Remediation
View remediation
Remediation Suggestions
- Require an
https://endpoint wheneverJISHUDB_TOKENis present, and terminate execution if a token would be transmitted over plaintext HTTP. - Validate the normalized
JISHUDB_URLscheme before constructing or sending authentication headers. - Replace the authenticated plaintext default with a trusted HTTPS endpoint.
- If local plaintext communication is operationally unavoidable, use a protected Unix-domain socket or another authenticated and encrypted local transport rather than ordinary HTTP.
- Configure
curlto verify TLS certificates using the deployment's trusted CA material; do not disable certificate validation. - Keep any explicit plaintext mode restricted to unauthenticated loopback-only deployments and clearly warn that bearer credentials must not be used in that mode.
- Require an
