T09 · Insecure Skill Coding Practices
- Location
scripts/lexiang_upload.py:175- Finding
Insecure Creation of a Predictable Temporary Credential File
- Content
View full analysis
.tmp`. It writes the plaintext MCP token using `Path.write_text()` before applying mode `0600`. When the temporary file does not already exist, its initial permissions are determined by the process umask. Under a common umask of `0022`, it may initially be created with mode `0644`. This creates a window between `write_text()` and `chmod()` during which another local account with sufficient directory and file access could read the token. The routine also does not use exclusive creation or no-follow semantics. If an attacker can modify the selected credential directory, the attacker can pre-create the predictable temporary path as a symbolic link. `Path.write_text()` follows symbolic links, allowing the linked file to be truncated and overwritten with credential data, provided the uploader process already has permission to write to that target. The subsequent `chmod()` also follows the link. The default credentials directory is normally user-owned, which reduces practical exposure. However, the application explicitly supports arbitrary destinations through `--credential-file` and `LEXIANG_UPLOAD_CREDENTIALS`. A user may therefore select a shared, group-writable, or otherwise attacker-controlled directory. ### Attack Path #### Credential disclosure through the creation window 1. The victim selects a c ...[truncated 2113 chars]- Remediation
View remediation
