T09 · Insecure Skill Coding Practices
- Location
scripts/ledger_common.py:73- Finding
Sensitive financial data is stored without explicit private file permissions
- Content
View full analysis
Path: raw = data_dir or os.environ.get("POCKETBOOK_DATA_DIR") resolved = Path(raw).expanduser() if raw else DEFAULT_DATA_DIR resolved.mkdir(parents=True, exist_ok=True) return resolved ``` ```python def write_json_atomically(path: str | Path, payload: Any) -> None: resolved = Path(path) temp_path = resolved.with_name(resolved.name + ".tmp") with open(temp_path, "w", encoding="utf-8", newline="\n") as handle: json.dump(payload, handle, ensure_ascii=False, indent=2, sort_keys=True) handle.write("\n") handle.flush() os.fsync(handle.fileno()) os.replace(temp_path, resolved) ``` ```python def append_event_to_path(path: str | Path, event: dict[str, Any]) -> None: resolved = Path(path) line = json.dumps(event, ensure_ascii=False, sort_keys=True) + "\n" with open(resolved, "a", encoding="utf-8", newline="\n") as handle: handle.write(line) handle.flush() os.fsync(handle.fileno()) ``` ```python with open(output_path, "w", encoding="utf-8", newline="\n") as handle: handle.write(content) ``` ### Technical Analysis The data directory and files are created using ordinary `mkdir()` and `open()` operations without explicitly enforcing private modes such as `0700` for the directory and `0600` for files. Their effective permissions therefore depend on the process umask. Existing files also retain their previous permissions. The files contain sensitive personal-finance information, including transaction amounts, accounts, payment methods, merchants, notes, profile aliases, and original user utterances. On a multi-user system with a permissive umask or pr ...[truncated 1221 chars]- Remediation
View remediation
