T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- falcon.sh:282
- Finding
- Reusable Twitter Session Cookie Disclosed to a Third-Party API## Vulnerability Details **File Location**: `falcon.sh:7`, `falcon.sh:79-110`, and `falcon.sh:282-365` **Vulnerability Type**: Sensitive credential delegation to a third-party service **Risk Level**: High ### Vulnerable Code ```bash BASE_URL="https://api.twexapi.io" ``` ```bash api_post() { need TWEXAPI_KEY local path="$1" local body="$2" local hdr_file body_file hdr_file=$(_mktemp) body_file=$(_mktemp) printf 'Authorization: Bearer %s\n' "$TWEXAPI_KEY" > "$hdr_file" printf 'Content-Type: application/json\n' >> "$hdr_file" printf '%s' "$body" > "$body_file" curl -sS --fail-with-body \ -X POST \ -H @"$hdr_file" \ -d @"$body_file" \ "${BASE_URL}${path}" | jq . } api_delete() { need TWEXAPI_KEY local path="$1" local body="$2" local hdr_file body_file hdr_file=$(_mktemp) body_file=$(_mktemp) printf 'Authorization: Bearer %s\n' "$TWEXAPI_KEY" > "$hdr_file" printf 'Content-Type: application/json\n' >> "$hdr_file" printf '%s' "$body" > "$body_file" curl -sS --fail-with-body \ -X DELETE \ -H @"$hdr_file" \ -d @"$body_file" \ "${BASE_URL}${path}" | jq . } ``` ```bash cmd_tweet() { [[ $# -ge 1 ]] || die "usage: falcon tweet <text>" require_cookie local json json=$(jq -n --arg text "$1" --arg cookie "$TWITTER_COOKIE" \ '{tweet_content: $text, cookie: $cookie}') api_post "/twitter/tweets/create" "$json" } ``` The same cookie-forwarding pattern is used by the reply, quote, like, unlike, retweet, bookmark, follow, and unfollow commands in `falcon.sh:288-365`. ### Technical Analysis The write and engagement commands embed the complete `TWITTER_COOKIE` value in a JSON request body and transmit it to `https://api.twexapi.io`. A Twitter authentication cookie is a reusable session credential and may provide broader account authority than the individual operation requested by the use ...[truncated 1770 chars]
- Remediation
- ## Remediation Suggestions 1. Replace session-cookie delegation with the official Twitter/X OAuth flow using narrowly scoped access tokens. 2. Request only the permissions required for the selected operation and avoid transmitting a reusable browser session credential. 3. If TwexAPI must remain involved, use short-lived, action-specific delegated tokens that cannot be replayed for unrelated account operations. 4. Require explicit confirmation immediately before every write or engagement request, including a clear warning that an external service will receive authentication material. 5. Define and document credential retention, logging, encryption, incident response, and deletion policies for the external API. 6. Provide clear session-revocation instructions and advise users to rotate or revoke credentials after suspected exposure. 7. Prevent request and error logging from recording cookie-bearing JSON bodies at every layer.
