T09 · Insecure Skill Coding Practices
- Location
scripts/store.py:25- Finding
Personal Birth Data Stored in Plaintext Without Enforced File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/main.py:67-74;scripts/store.py:25-29
Vulnerability Type: Plaintext sensitive-data storage with insufficient access-control hardening
Risk Level: MediumVulnerable Code
python # scripts/main.py:67-74 users[name] = { "birth": {"year": int(year), "month": int(month), "day": int(day), "hour": int(hour), "minute": int(minute), "gender": gender}, "bazi": fate_dict, "fetched_at": now_iso(), } save_users(users)python # scripts/store.py:25-29 def save_users(data): ensure_dir() with open(USERS_FILE, "w", encoding="utf-8") as f: json.dump(data, f, ensure_ascii=False, indent=2)Technical Analysis
The application persistently records names, exact birth dates and times, gender, and derived BaZi profiles in the predictable
data/users.jsonfile. The data is serialized as human-readable plaintext.The application does not explicitly set owner-only permissions on the data directory or file. Instead, the resulting permissions depend on the runtime environment's process umask and any preexisting filesystem permissions. In an environment with a permissive umask or shared project directory, other local accounts or processes may be able to read this personal information.
The same storage design is also used for active identities in
data/active.json, although the complete sensitive birth profile is stored inusers.json. No encryption, field minimization, retention control, or permission validation is implemented.Attack Path
- A user or agent invokes the documented
addcommand and supplies a person's name, exact birth date, birth time, and gender. cmd_add()constructs a record containing those identifiers and the derived profile.save_users()writes the complete record as plaintext to the predictabledata/users.jsonpath.- File access permissions are inherited from the process umask rather than being explicitly restricted ...[truncated 1111 chars]
- A user or agent invokes the documented
- Remediation
View remediation
Remediation Suggestions
-
Enforce owner-only filesystem permissions
- Create the data directory with mode
0700. - Create data files with mode
0600usingos.open()with explicit flags and permissions. - Validate and correct permissions on preexisting files before reading or writing them.
- Create the data directory with mode
-
Use atomic, permission-preserving writes
- Write to a temporary file in the protected data directory.
- Flush and synchronize the file before replacing the destination with
os.replace(). - Ensure the temporary file is also created with mode
0600. - This also reduces the risk of corruption from interrupted writes.
-
Minimize retained data
- Store only fields required for later calculations and reports.
- Avoid retaining redundant copies of names, birth details, and derived data.
- Allow operation without persistent storage when users need only a one-time calculation.
-
Provide privacy controls
- Obtain clear consent before storing information about another person.
- Add commands to enumerate, export, and permanently erase stored profiles.
- Document retention behavior and warn that backups or repository history may preserve deleted records.
-
Consider encryption where the threat model requires it
- Encrypt sensitive records at rest with a key held outside the project directory.
- Do not hardcode the encryption key in the Skill.
- Note that encryption complements but does not replace restrictive filesystem permissions.
-
Prevent accidental publication
- Add
data/users.json,data/active.json, temporary files, and backups to.gitignore. - Include a startup check that warns when sensitive data files are tracked by version control or are readable by group/other users.
- Add
-
