T09 · Insecure Skill Coding Practices
- Location
scripts/calendar.sh:18- Finding
Insecure Persistent Logging and Log-Record Injection
- Content
View full analysis
> "$LOGFILE" } ``` ```python # Safe output: replace newlines in string values (one field per line) def safe(s): return s.replace('\n', ' ').replace('\r', '') ``` ```bash log_action "create-event" "$calendar" "$summary" ``` ### Technical Analysis The script persistently records calendar names and event summaries in `logs/calendar.log`. These fields can contain sensitive personal or business information. The log directory and file are created without explicit restrictive permissions, so their effective access permissions depend on the invoking process's umask and existing filesystem state. The log uses tab-separated fields, but the sanitizer only removes carriage returns and replaces newlines. It does not remove or encode tab characters, despite comments indicating that tabs are handled. An attacker-controlled event summary or calendar name containing tabs can therefore insert additional apparent fields and corrupt the audit-record structure. The redirection operator also follows symbolic links. If an attacker can control the configured log location or prepare entries within a writable log directory, the process may append content to a symlink target accessible to the invoking user. Additionally, the full input JSON is temporarily placed in the `CALENDAR_JSON` environment variable: ```bash validated=$(CALENDAR_JSON="$json" python3 << 'PYEOF' ``` This JSON can include private event descriptions. Depending on operating-system ...[truncated 1687 chars]- Remediation
View remediation
