Back to skill

Security audit

Agent Audit Log

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent audit-log tooling, but its initialization script can silently erase the current day's audit log if run again.

Install only if you are comfortable reviewing or fixing the initializer first. The skill's logging guidance is reasonable, but rerunning `scripts/init_audit.sh` against an existing audit directory can erase today's raw audit events; replace that truncation with a non-destructive create-if-missing behavior before relying on it.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/init_audit.sh:8
Finding

Audit Log Truncation During Reinitialization

Content
View full analysis

Vulnerability Details

File Location: scripts/init_audit.sh, lines 8 and 17
Vulnerability Type: Unconditional file truncation resulting in audit-record destruction
Risk Level: Medium

Vulnerable Code

bash
JSONL="$AUDIT_DIR/$TODAY.jsonl"
bash
: > "$JSONL"

Technical Analysis

The script computes the current daily audit-log path and then unconditionally redirects an empty command into that file. In POSIX-compatible shells, : > "$JSONL" creates the file if it does not exist but truncates it to zero bytes if it already exists.

Unlike the index and summary files initialized later in the script, this operation does not first check whether the daily log already exists. Consequently, every subsequent invocation on the same day erases all events previously written to that day's JSONL file. This contradicts the project's stated purpose of maintaining a reliable operational audit trail.

No privilege escalation is involved. Exploitation requires the ability to run the initialization script against a root directory containing an existing audit structure.

Attack Path

  1. Audit events are written to ROOT/logs/audit/YYYY-MM-DD.jsonl.

  2. An operator, scheduled workflow, or actor with script-execution access invokes:

    bash
    scripts/init_audit.sh ROOT
    
  3. The script resolves JSONL to the existing current-day log.

  4. Line 17 executes : > "$JSONL".

  5. The existing file is silently reduced to zero bytes, destroying all audit events recorded in it.

Impact Assessment

The issue permits deletion of the current day's audit records within any writable root directory supplied to the script. It does not grant additional system privileges, network access, or access to otherwise protected files.

The security impact is loss of audit integrity and availability. Relevant evidence may be erased, reducing traceability and potentially concealing earlier administrative, publication, configuration, or credential-related acti ...[truncated 117 chars]

Remediation
View remediation

Remediation Suggestions

Preserve an existing daily log and create it only when absent. The simplest safe implementation is:

bash
touch "$JSONL"

Alternatively, follow the conditional initialization pattern already used for the other files:

bash
[ -f "$JSONL" ] || : > "$JSONL"

Additional hardening should include:

  1. Document that initialization is idempotent and must never remove existing audit data.
  2. Add a regression test that writes an event, reruns the script, and verifies that the event remains intact.
  3. Consider refusing to operate on symbolic-link log files if the script may run in directories writable by untrusted users.
  4. If intentional reset behavior is needed, expose it through an explicit option such as --reset, display a warning, and create a backup before truncation.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (1)

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

This markdown file includes an example of changing a repository's visibility from private to public, which can materially affect confidentiality and system exposure. The example is presented as a neutral success case without any warning, caution, or note about disclosure risk.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.