T09 · Insecure Skill Coding Practices
- Location
scripts/wacli.py:20- Finding
WhatsApp Authentication Token Stored Without Enforced Access Restrictions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/wacli.py:20-28
Vulnerability Type: Plaintext sensitive-data storage with insecure file permissions
Risk Level: MediumComplete Code Snippet:
python def save_config(self): os.makedirs(os.path.dirname(self.config_path), exist_ok=True) with open(self.config_path, "w") as f: json.dump(self.config, f, indent=2) def login(self, auth_token): """Authenticate with WhatsApp CLI service""" self.config["auth_token"] = auth_token self.save_config() print("Login successful")Technical Analysis
The
loginmethod stores the authentication token in the client configuration, andsave_configwrites that configuration as plaintext JSON to the default path~/.wacli/config.json. The code does not explicitly create the containing directory with mode0700or the configuration file with mode0600. Its effective permissions therefore depend on the process umask and any pre-existing directory or file permissions.Because
load_configlater trusts and reads this file, any local account or process that can read it can obtain the token. If another user can modify the file, that user could also replace configuration values used by the client. The present WhatsApp implementation is a mock, but the token becomes security-sensitive when the documented real backend is connected.Attack Path
- A user runs
wacli.py login <token>. - The supplied token is assigned to
self.config["auth_token"]. save_configwrites the token in plaintext to~/.wacli/config.json.- File accessibility is determined by the environment's umask or pre-existing permissions rather than an enforced owner-only policy.
- A local process or user with read access copies the token.
- Once a real WhatsApp provider is connected, the copied token may be presented to that provider to impersonate the legitimate client, subject to the prov ...[truncated 522 chars]
- A user runs
- Remediation
View remediation
Remediation Suggestions
- Prefer an operating-system credential manager or dedicated secret-management service instead of a plaintext JSON file.
- If file storage is unavoidable, create
~/.wacliwith mode0700and atomically create the configuration file with mode0600. - Before loading an existing configuration, verify that it is a regular file, is owned by the current user, and is not accessible by group or other users.
- Avoid following symbolic links when creating or replacing the file. Write to a securely created temporary file in the same directory, set its permissions, and atomically rename it.
- Separate sensitive credentials from non-secret settings such as the default phone number.
- Support token rotation and revocation, and document immediate revocation procedures for suspected exposure.
- Consider accepting the token through a protected environment variable or credential-helper interface rather than a command-line argument, since command-line arguments may be exposed through shell history or process inspection.
