VibeRune
Commands/security

/security:fix

Apply Security Fixes

/security:fix

Claude Code

Agent: security-auditor Skills: security-testing

/security:fix - Apply Security Fixes

Apply recommended security fixes with user approval.

Usage

/security:fix [finding-id]
/security:fix                    # Interactive fix selection
/security:fix SEC-001            # Fix specific finding
/security:fix --dry-run          # Preview fixes without applying

⚠️ CRITICAL SAFETY REQUIREMENTS

NEVER auto-fix without explicit user confirmation.

Before applying ANY fix:

  1. Display the vulnerability details
  2. Show the proposed fix
  3. Explain potential side effects
  4. ASK USER: "Apply this security fix? (yes/no)"
  5. Only proceed if user confirms

Execution Steps

1. Load Findings

# Read from most recent security scan/audit report
# Parse findings with severity and remediation

2. Present Fix Options

## Security Fix: SEC-001

**Severity**: Critical
**Category**: Hardcoded Secret
**Location**: src/config/api.ts:15

**Current Code**:
```typescript
const API_KEY = "sk-live-abc123..."; // REDACTED

Proposed Fix:

const API_KEY = process.env.API_KEY;

Side Effects:

  • Requires API_KEY in environment variables
  • May break local development without .env file

Apply this fix? (yes/no):


### 3. Apply Fix (After Confirmation)
```bash
# Use Edit tool to apply the change
# Verify syntax after edit
# Run tests if available

4. Verify Fix

# Re-scan the fixed file
# Confirm vulnerability no longer detected

Agent Configuration

agent: security-auditor
skills:
  - security-testing
confirmation: required  # ALWAYS require confirmation

Fix Categories

Secret Removal

// Before
const SECRET = "hardcoded-value";

// After
const SECRET = process.env.SECRET;

Additional Steps:

  1. Add to .env.example
  2. Update deployment documentation
  3. Rotate the exposed secret

SQL Injection Fix

// Before
db.query(`SELECT * FROM users WHERE id = ${userId}`);

// After
db.query('SELECT * FROM users WHERE id = $1', [userId]);

XSS Fix

// Before
element.innerHTML = userInput;

// After
element.textContent = userInput;
// Or use DOMPurify for HTML content
element.innerHTML = DOMPurify.sanitize(userInput);

Dependency Update

# Preview
npm audit fix --dry-run

# Apply (with user confirmation)
npm audit fix

# Force major updates (requires explicit approval)
npm audit fix --force

Output Template

## Security Fix Applied

### Fix Details
- **Finding ID**: SEC-001
- **Severity**: Critical
- **File**: src/config/api.ts
- **Line**: 15

### Changes Made
- Removed hardcoded API key
- Added environment variable reference

### Verification
- [x] Fix applied successfully
- [x] Syntax valid
- [x] Re-scan confirms fix

### Follow-up Required
1. Add API_KEY to .env.example
2. Update deployment docs
3. **IMPORTANT: Rotate the exposed secret immediately**

### Next Steps
- Run `/security:scan` to verify no new issues
- Update any affected documentation

Severity-Based Workflow

SeverityUser Interaction
CriticalMust confirm each fix individually
HighMust confirm each fix individually
MediumCan batch confirm after review
LowCan batch confirm after review

Rollback

If fix causes issues:

# Git rollback
git checkout -- <file>

# Or restore from stash
git stash pop

On this page