T09 · Insecure Skill Coding Practices
- Location
scripts/login.sh:6- Finding
OAuth Tokens May Be Transmitted over Unencrypted HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/login.sh:6-16,35-38
Vulnerability Type: Acceptance of plaintext transport for sensitive OAuth traffic
Risk Level: HighVulnerable Code
bash BASE="${ERXES_BASE_URL%/}" CLIENT="${ERXES_CLIENT_ID:-erxes-local}" if [ -z "$BASE" ]; then echo "ERXES_BASE_URL is required" >&2 exit 1 fi # Extract subdomain from a gateway URL like https://demo.next.erxes.io/gateway -> demo SUB=$(echo "$BASE" | sed -E 's|https?://([^./]+).*|\1|') RESP=$(curl -sf -X POST "$BASE/oauth/device/code" \ -H "Content-Type: application/json" \ -H "erxes-subdomain: $SUB" \ -d "{\"client_id\":\"$CLIENT\"}")bash TOK=$(curl -s -X POST "$BASE/oauth/token" \ -H "Content-Type: application/json" \ -H "erxes-subdomain: $SUB" \ -d "{\"grant_type\":\"urn:ietf:params:oauth:grant-type:device_code\",\"device_code\":\"$DC\",\"client_id\":\"$CLIENT\"}")The associated instructions explicitly permit arbitrary URL forms, and the login reference includes loopback HTTP:
text Accept the URL in whatever form the user gives and normalize it to ERXES_BASE_URL=<url>.bash ERXES_BASE_URL=http://localhost:4000 ERXES_CLIENT_ID=my-client bash scripts/login.shTechnical Analysis
The script does not validate the URL scheme before sending OAuth Device Flow requests. Because
curlacceptshttp://endpoints, a non-loopback server can receive both the device-code request and token polling requests over unencrypted transport.The token response is expected to contain an access token and a refresh token. When a remote HTTP endpoint is used, an on-path attacker can observe or modify this authentication exchange. HTTPS certificate validation by
curldoes not mitigate the issue because no TLS connection exists in the HTTP case.Loopback HTTP may be appropriate for local development, but the current implementation does not distinguish loopback addresses from arbitrary remote hosts.
Attack Path
...[truncated 1245 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse
ERXES_BASE_URLwith a proper URL parser before making any request. - Require
https://for all non-loopback hosts. - Permit
http://only when the normalized hostname is exactly an approved loopback address, such aslocalhost,127.0.0.1, or[::1]. - Reject unsupported schemes, embedded credentials, malformed hosts, and ambiguous URL forms.
- Keep TLS certificate verification enabled and do not add
curl -kor equivalent bypasses. - Consider an explicit development-only flag before allowing loopback HTTP.
- Document the transport restriction consistently in
SKILL.mdanderxes-app-token-auth.md. - Add tests confirming that remote HTTP URLs are rejected while valid HTTPS and explicitly approved loopback-development URLs are accepted.
- Parse
