T05 · Unauthorized Access and Privilege Escalation
- Location
falcon.sh:282- Finding
Reusable Twitter Session Cookie Disclosed to a Third-Party API
- Content
View full analysis
Vulnerability Details
File Location:
falcon.sh:7,falcon.sh:79-110, andfalcon.sh:282-365
Vulnerability Type: Sensitive credential delegation to a third-party service
Risk Level: HighVulnerable 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_COOKIEvalue in a JSON request body and transmit it tohttps://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
View remediation
Remediation Suggestions
- Replace session-cookie delegation with the official Twitter/X OAuth flow using narrowly scoped access tokens.
- Request only the permissions required for the selected operation and avoid transmitting a reusable browser session credential.
- If TwexAPI must remain involved, use short-lived, action-specific delegated tokens that cannot be replayed for unrelated account operations.
- Require explicit confirmation immediately before every write or engagement request, including a clear warning that an external service will receive authentication material.
- Define and document credential retention, logging, encryption, incident response, and deletion policies for the external API.
- Provide clear session-revocation instructions and advise users to rotate or revoke credentials after suspected exposure.
- Prevent request and error logging from recording cookie-bearing JSON bodies at every layer.
