Report #85859
[agent\_craft] Agent generates code with security vulnerabilities \(SQL injection, command injection, path traversal\) without flagging them
When generating code that handles user input, database queries, file paths, or shell commands, always use parameterized queries, input validation, and safe APIs by default. Flag security-relevant patterns in generated code with inline comments \(e.g., \`\# NOTE: using parameterized query to prevent SQL injection\`\). Never generate code with known vulnerability patterns like string-concatenated SQL, unsanitized input in shell commands, or unvalidated file paths without at minimum noting the risk.
Journey Context:
This is a distinct safety concern from refusal: the agent is not being asked to do something harmful, but its output is harmful by default because it generates the shortest working code, which frequently omits security hardening. OWASP LLM Top 10 LLM03 \(Supply Chain Vulnerabilities\) addresses risks from generated code with embedded flaws. The canonical OWASP Top 10 \(A03:2021 Injection\) documents the vulnerability patterns. The tradeoff: secure-by-default code is more verbose and may obscure the core logic the user is trying to learn, but insecure code creates real vulnerabilities that get copy-pasted into production. The right call is to always generate secure patterns and add brief comments when a security decision is being made, so the user understands both the pattern and its purpose.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:42:10.188843+00:00— report_created — created