T09 · Insecure Skill Coding Practices
- Location
scripts/release-digest.sh:28- Finding
Unsanitized Repository Metadata Can Manipulate Agent-Generated Release Digests
- Content
View full analysis
Vulnerability Details
File Location:
scripts/release-digest.sh, lines 28-31
Vulnerability Type: Improper neutralization of untrusted repository content
Risk Level: MediumVulnerable Code
bash printf '### Commits\n\n' git log --no-merges --reverse --format='- %s (%an) `%h`' "$range" 2>/dev/null || true printf '\n### Files changed\n\n' git diff --stat "$range" 2>/dev/null || trueThe output-handling instruction in
SKILL.md, lines 39-41, further directs the agent to return this generated content:markdown 3. Hand the printed Markdown back to the caller. Never paste secrets, tokens, or private filenames that the commit log may surface — redact before replying.Technical Analysis
The script inserts Git commit subjects (
%s), author names (%an), and changed file paths directly into Markdown without escaping Markdown syntax or removing terminal control characters. These values can be controlled by anyone capable of introducing commits or filenames into the audited repository.Although command arguments are quoted and no shell command injection is present, the generated document crosses a trust boundary: repository-controlled text is returned to an AI agent and subsequently presented to a user. A malicious value may contain instruction-like text, deceptive links, Markdown formatting, backticks, bidirectional text characters, or ANSI terminal escape sequences.
The instruction in
SKILL.mdrequires secret and private-filename redaction but does not require the agent to treat repository-derived content strictly as untrusted data. Consequently, crafted repository metadata could be interpreted as instructions by an agent or could manipulate the appearance of the rendered response.Attack Path
- An attacker obtains permission to contribute a commit or create a tracked filename in the target repository.
- The attacker creates a commit subject, author name, or filename containing malicious Markdown, terminal contro ...[truncated 1187 chars]
- Remediation
View remediation
Remediation Suggestions
- Treat every commit subject, author name, and filename as untrusted data.
- Strip C0/C1 control characters, ANSI escape sequences, and unsafe bidirectional formatting characters before producing output.
- Escape Markdown metacharacters in repository-derived values, including backticks, brackets, parentheses, angle brackets, and backslashes.
- Use NUL-delimited Git output where possible so unusual filenames and record boundaries can be processed safely.
- Avoid passing raw
git diff --statoutput directly to the response. Parse structured Git output and render each field through a dedicated sanitizer. - Update
SKILL.mdto state explicitly that repository content is data only and must never be followed as instructions. - Consider wrapping untrusted values in a clearly labeled, inert representation rather than interpolating them directly into normal prose.
- Add regression tests covering ANSI escapes, multiline metadata, Markdown links, backticks, bidirectional characters, and unusual filenames.
