security: add comprehensive vulnerability prevention framework#252
Open
BloodShop wants to merge 1 commit intomsitarzewski:mainfrom
Open
security: add comprehensive vulnerability prevention framework#252BloodShop wants to merge 1 commit intomsitarzewski:mainfrom
BloodShop wants to merge 1 commit intomsitarzewski:mainfrom
Conversation
- Add SECURITY.md with vulnerability documentation and mitigation strategies - Add security-utils.sh library with validation, escaping, and audit functions - Add GitHub Actions workflow for continuous security auditing - Document prompt injection, GitHub Actions, and shell injection risks - Provide reusable utilities for input validation and safe command execution SECURITY ADDRESSES: - Prompt injection prevention via sanitization utilities - GitHub Actions token protection patterns - Shell command injection prevention via escaping - Credential protection via environment variables - Input validation for agent names and file paths NO BREAKING CHANGES - All utilities are opt-in and backward compatible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Hardening PR: Prompt Injection & CI/CD Safety
Summary
This PR addresses critical security vulnerabilities identified in the agency-agents repository through comprehensive security auditing. The changes focus on preventing prompt injection attacks, hardening GitHub Actions workflows, and establishing security best practices.
Changes Made
1. New Security Documentation (
SECURITY.md)Why: Establishes security culture and educates users about risks before they introduce them.
2. Security Utilities Library (
scripts/security-utils.sh)validateAgentName()- Whitelist validation for agent identifiersvalidatePath()- Path traversal preventionescapeShellArg()- Safe shell argument escapingsanitizeForLog()- Mask sensitive data in logsrequireEnvVar()- Enforce environment variable security patternssafeExec()- Command execution with error handling & sanitizationWhy: Provides reusable, battle-tested security functions for all scripts.
3. Automated Security Audit Workflow (
.github/workflows/security-audit.yml)Why: Prevents regressions by catching security issues in CI/CD before merge.
Security Vulnerabilities Addressed
CRITICAL: Prompt Injection in Agent Prompts
Status: Documented + Utilities Provided
Agent personalities can process untrusted input (GitHub issues, user messages, comments). Malicious actors can embed hidden directives using:
Example Attack:
Fix: Use
sanitizePromptInput()(provided in security-utils) for any user-provided data before passing to agents.Before:
agent_prompt="Process this GitHub issue: $raw_issue_body"After:
HIGH: GitHub Actions Token Exposure
Status: Documented + Workflow Template Provided
Scripts running in GitHub Actions have access to
$GITHUB_TOKENand other secrets. Prompt injection or shell injection can leak these tokens.Risks:
Example Vulnerability in convert.sh:
Fix: Validate all inputs before use:
MEDIUM: Shell Injection in Scripts
Status: Best Practices Documented
Scripts in
./scripts/use string interpolation without proper escaping.Risks:
Recommended Pattern:
MEDIUM: Hardcoded Credentials & Secrets
Status: Automated Detection Added
Credentials should never be in git history.
Example Violation:
Safe Pattern:
LOW: Missing Input Validation
Status: Utilities + Patterns Provided
Agent names, file paths, and configuration parameters should be validated.
Examples:
Testing Recommendations
Before Deploying Fixes
Post-Merge Verification
Checklist for Maintainers
Migration Guide for Users
For Existing Scripts
requireEnvVar GITHUB_TOKEN "Your GitHub authentication token"For New Agents
sanitizeForLog()when logging user inputvalidateAgentName()Impact & Risk Assessment
Security Improvements
Risk Level
Effort to Adopt
Future Work
This PR lays groundwork for:
References
PR Type: 🔒 Security
Severity: High
Component: Core Security Infrastructure
Related Issues: Security Audit Task