T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/lk.py:145
- Finding
- LinkedIn Session Cookies Stored in Plaintext Without Enforced Access Controls<![CDATA[ ## Vulnerability Details **File Location**: `scripts/lk.py:145-158` **Vulnerability Type**: Plaintext credential storage with unsafe default file permissions **Risk Level**: High ### Vulnerable Code ```python li_at = input("Enter li_at cookie value: ").strip() jsessionid = input("Enter JSESSIONID cookie value: ").strip() # Save to config config_dir = os.path.expanduser('~/.clawdbot/linkedin-monitor') os.makedirs(config_dir, exist_ok=True) config_path = os.path.join(config_dir, 'credentials.json') with open(config_path, 'w') as f: json.dump({ 'li_at': li_at, 'jsessionid': jsessionid.strip('"'), 'updated_at': datetime.now().isoformat() }, f, indent=2) ``` ### Technical Analysis The Skill stores the LinkedIn `li_at` and `JSESSIONID` authentication cookies directly in `~/.clawdbot/linkedin-monitor/credentials.json`. These cookies are reusable authentication credentials capable of granting access to the user's LinkedIn session. The file is created with Python's default `open()` behavior. Neither the containing directory nor the credential file is assigned an explicit restrictive permission mode. Their effective permissions therefore depend on the process umask. Under a permissive or commonly used umask, other local users or processes may be able to read the credential file. The credentials are also stored without encryption, operating-system keychain integration, ownership validation, permission validation, or expiration management. Related private information may also be written to `state/drafts.json` by `scripts/state.sh:82-100`, including inbound messages and drafted replies, without explicit permission hardening. ### Attack Path 1. The user runs the interactive authentication setup. 2. The Skill writes valid LinkedIn session cookies to `~/.clawdbot/linkedin-monitor/credentials.json`. 3. The resulting permissions are inherited from the current umask rather than being explicitly restricted. 4. A malicious local ...[truncated 1014 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Store authentication cookies in an operating-system credential manager, such as macOS Keychain, Windows Credential Manager, or a Linux Secret Service provider. 2. If file storage is unavoidable: - Create `~/.clawdbot/linkedin-monitor` with mode `0700`. - Create the credential file atomically with mode `0600`. - Verify that the file is owned by the current user. - Refuse to use the file if group or other permissions are present. 3. Set a restrictive umask, such as `0o077`, before creating any directory or file containing credentials or private message data. 4. Apply the same permission controls to state, draft, configuration, and log files that may contain private LinkedIn information. 5. Avoid writing temporary copies of sensitive files outside a protected directory. 6. Provide a command that securely deletes stored credentials and instructs the user to revoke the LinkedIn session. 7. Prefer short-lived authentication mechanisms where available and document that these cookies provide account-level access. ]]>
