The Challenge
The traditional approach to vulnerability remediation is manual and time-consuming:- Scan repositories for vulnerabilities
- Review each vulnerability and its impact
- Research the fix (usually a version upgrade)
- Update dependency files
- Test the changes
- Create pull requests
- Get reviews and merge
Automated Vulnerability Remediation with OpenHands
The OpenHands Software Agents SDK provides powerful capabilities for building autonomous AI agents capable of interacting with codebases. These agents can tackle one of the most tedious tasks in software maintenance: security vulnerability remediation. OpenHands assists with vulnerability remediation by:- Identifying vulnerabilities: Analyzing code for common security issues
- Understanding impact: Explaining the risk and exploitation potential
- Implementing fixes: Generating secure code to address vulnerabilities
- Validating remediation: Verifying fixes are effective and complete
Two Approaches to Vulnerability Fixing
1. Point to a GitHub Repository
Build a workflow where users can point to a GitHub repository, scan it for vulnerabilities, and have OpenHands AI agents automatically create pull requests with fixes—all with minimal human intervention.2. Upload Security Scanner Reports
Enable users to upload reports from security scanners such as Snyk (as well as other third-party security scanners) where OpenHands agents automatically detect the report format, identify the issues, and apply fixes. This solution goes beyond automation—it focuses on making security remediation accessible, fast, and scalable.Architecture Overview
A vulnerability remediation agent can be built as a web application that orchestrates agents using the OpenHands Software Agents SDK and OpenHands Cloud to perform security scans and automate remediation fixes. The key architectural components include:- Frontend: Communicates directly with the OpenHands Agent Server through the TypeScript Client
- WebSocket interface: Enables real-time status updates on agent actions and operations
- LLM flexibility: OpenHands supports multiple LLMs, minimizing dependency on any single provider
- Scalable execution: The Agent Server can be hosted locally, with self-hosted models, or integrated with OpenHands Cloud
Example: Vulnerability Fixer Application
An example implementation is available at github.com/OpenHands/vulnerability-fixer. This React web application demonstrates the full workflow:- User points to a repository or uploads a security scan report
- Agent analyzes the vulnerabilities
- Agent creates fixes and pull requests automatically
- User reviews and merges the changes
Security Scanning Integration
Use OpenHands to analyze security scanner output:Common Vulnerability Patterns
OpenHands can detect these common vulnerability patterns:| Vulnerability | Pattern | Example |
|---|---|---|
| SQL Injection | String concatenation in queries | query = "SELECT * FROM users WHERE id=" + user_id |
| XSS | Unescaped user input in HTML | <div>${user_comment}</div> |
| Path Traversal | Unvalidated file paths | open(user_supplied_path) |
| Command Injection | Shell commands with user input | os.system("ping " + hostname) |
| Hardcoded Secrets | Credentials in source code | password = "admin123" |
Automated Remediation
Applying Security Patches
Fix identified vulnerabilities:- SQL Injection
- XSS
- Command Injection
Code-Level Vulnerability Fixes
Fix application-level security issues:Security Testing
Test your fixes thoroughly:Automated Remediation Pipeline
Create an end-to-end automated pipeline:Building Your Own Vulnerability Fixer
The example application demonstrates that AI agents can effectively automate security maintenance at scale. Tasks that required hours of manual effort per vulnerability can now be completed in minutes with minimal human intervention. To build your own vulnerability remediation agent:- Use the OpenHands Software Agent SDK to create your agent
- Integrate with your security scanning tools (Snyk, Dependabot, CodeQL, etc.)
- Configure the agent to create pull requests automatically
- Set up human review workflows for critical fixes
Related Resources
- Vulnerability Fixer Example - Full implementation example
- OpenHands SDK Documentation - Build custom AI agents
- Dependency Upgrades - Updating vulnerable dependencies
- Prompting Best Practices - Write effective prompts

