T09 · Insecure Skill Coding Practices
- Location
scripts/_auth.py:67- Finding
Credential file is created without restrictive filesystem permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/_auth.py, lines 67-71
Vulnerability Type: Insecure storage of sensitive credentials
Risk Level: MediumVulnerable Code
python def write_config(data): CONFIG_DIR.mkdir(parents=True, exist_ok=True) with open(CONFIG_FILE, "w", encoding="utf-8") as f: json.dump(data, f, indent=2, ensure_ascii=False)Technical Analysis
The credential file contains sensitive values including
app_id,secret_key, and the persistedaccess_token. Although the documentation recommends directory mode0700and file mode0600, the implementation does not enforce either restriction.mkdir()andopen()therefore create the directory and file using permissions derived from the process umask. Under a permissive umask, other local users may be able to read the credentials. Rewriting an existing credential file also does not correct insecure pre-existing permissions.The credential storage path is configurable through environment variables. The write operation additionally performs no check that the destination is a regular file rather than a symbolic link.
Attack Path
- The Skill reads a valid
app_idandsecret_keyand determines that its access token must be refreshed. - The refreshed token is passed to
write_config(). - The function creates or rewrites
credentials.jsonwithout explicitly setting restrictive permissions. - On a system with permissive file permissions, another local user or process reads the file.
- The attacker reuses the application credentials or access token to issue authenticated Chanjing API requests.
Impact Assessment
Successful exploitation exposes Chanjing API credentials to another local security principal. The attacker may obtain the same API privileges as the victim account, including inspecting digital-human resources, creating jobs, uploading content, and deleting digital-human records wh ...[truncated 226 chars]
- The Skill reads a valid
- Remediation
View remediation
Remediation Suggestions
- Create the credential directory with mode
0700and explicitly enforce that mode on existing directories. - Create credential files with mode
0600, independent of the process umask. - Write updates to a securely created temporary file in the same directory, flush and synchronize it, set mode
0600, and atomically replace the destination. - Reject symbolic links and verify that the destination is a regular file owned by the expected user before reading or replacing it.
- Correct insecure permissions on existing credential files before storing refreshed tokens.
- Avoid printing credential values or access tokens in error output and ensure
credentials.jsonremains excluded from version control.
- Create the credential directory with mode
