T09 · Insecure Skill Coding Practices
Error
- Location
- twitter_api/demo_langchain_tools.py:31
- Finding
- Hardcoded Twitter/X Session Credentials in an Executable Demo## Vulnerability Details **File Location**: `twitter_api/demo_langchain_tools.py:31-33, 151-156, 169-190` **Vulnerability Type**: Hardcoded session credentials **Risk Level**: Critical ### Vulnerable Code The credential values are redacted below to avoid further disclosure: ```python # Twitter credentials AUTH_TOKEN = "[REDACTED COMMITTED AUTH TOKEN]" CT0 = "[REDACTED COMMITTED CSRF TOKEN]" USERNAME = "Jordyn_Luv" ``` ```python # Get all Twitter tools tools = get_twitter_tools( auth_token=AUTH_TOKEN, ct0=CT0, config=tool_config ) ``` ```python try: # Post a new tweet tweet_id = await demo_post_tweet(post_tweet_tool) if tweet_id: # Like our own tweet await demo_like_tweet(like_tweet_tool, tweet_id) # Reply to our own tweet reply_id = await demo_reply_to_tweet(reply_to_tweet_tool, tweet_id) # Like the reply if reply_id: await demo_like_tweet(like_tweet_tool, reply_id) # Fetch mentions mention_ids = await demo_fetch_mentions(fetch_mentions_tool) # Like a mention if any exists if mention_ids: random_mention_id = mention_ids[0] await demo_like_tweet(like_tweet_tool, random_mention_id) ``` ### Technical Analysis The executable demo contains fixed values with the structure and context of real Twitter/X `auth_token` and `ct0` session credentials. These are not example placeholders. The credentials are passed directly to `get_twitter_tools()`, which constructs authenticated tools capable of posting tweets, replying, liking, retweeting, and reading account mentions. An `auth_token` is a bearer-equivalent browser session credential. The accompanying `ct0` value supplies the CSRF token expected by authenticated X web endpoints. Possession of both can enable session replay without knowing the account password, subject to session v ...[truncated 1500 chars]
- Remediation
- ## Remediation Suggestions 1. Immediately revoke all Twitter/X sessions associated with the exposed credentials. 2. Rotate credentials and review the affected account for unauthorized activity. 3. Remove the values from the current source and purge them from all Git history, forks, build artifacts, logs, and published packages. 4. Load credentials only from protected environment variables or a dedicated secret manager: ```python import os AUTH_TOKEN = os.environ["TWITTER_AUTH_TOKEN"] CT0 = os.environ["TWITTER_CT0"] ``` 5. Ensure `.env` and other local secret files are excluded through `.gitignore`. 6. Replace executable demos with mocked credentials and mocked network calls by default. 7. Add pre-commit and CI secret scanning to reject session tokens before they enter repository history. 8. Require an explicit confirmation flag before any demo performs account mutations.
