OSCP Report Writing: Remediation Recommendations Writing
1. Why Remediation Matters
The Value of Remediation
Remediation recommendations are what transform a penetration test report from a problem list into a solution guide. Without remediation, your report tells the client what’s wrong but not how to fix it.
Remediation Writing Principles
| Principle | Description | Example |
|---|---|---|
| Specific | Provide exact steps, not vague advice | “Apply patch KB123456” not “Update the system” |
| Actionable | The reader should know exactly what to do | “Run: sudo apt update && sudo apt upgrade” |
| Prioritized | Order by urgency and effort | Immediate, short-term, long-term |
| Verifiable | Include how to verify the fix works | “Retest with sqlmap to confirm” |
| Proportional | Match remediation effort to risk level | Critical = immediate fix, Low = scheduled fix |
2. Remediation Structure
Three-Tier Remediation Framework
REMEDIATION
├── Immediate Actions (0-7 days)
│ ├── Apply hotfix/patch
│ ├── Enable compensating control
│ └── Restrict access
├── Short-term Actions (7-30 days)
│ ├── Code remediation
│ ├── Configuration hardening
│ └── Security training
└── Long-term Actions (30-90+ days)
├── Architecture review
├── Security program development
└── Automated testing implementation
Remediation Template
#### Remediation
**Immediate Actions (0-7 days):**
1. [Specific immediate action with exact steps]
2. [Specific immediate action with exact steps]
3. [Specific immediate action with exact steps]
**Short-term Actions (7-30 days):**
1. [Specific short-term action with exact steps]
2. [Specific short-term action with exact steps]
**Long-term Actions (30-90 days):**
1. [Specific long-term action with exact steps]
2. [Specific long-term action with exact steps]
**Verification:**
1. [How to verify the fix works]
2. [How to confirm no new issues introduced]
3. Remediation by Vulnerability Type
SQL Injection Remediation
#### Remediation
**Immediate Actions (0-7 days):**
1. Deploy a Web Application Firewall (WAF) rule to block SQL injection patterns
- Example: ModSecurity rule SQLi Detection
- Rule: SecRule ARGS "@detectSQLi" "id:1001,deny,status:403"
2. Restrict database user permissions to minimum required
- Revoke DROP, ALTER, and CREATE permissions from the application database user
- Grant only SELECT, INSERT, UPDATE, DELETE as needed
**Short-term Actions (7-30 days):**
1. Refactor all database queries to use parameterized queries / prepared statements
- Python example:
```python
# VULNERABLE
cursor.execute(f"SELECT * FROM users WHERE username = '{username}'")
# FIXED
cursor.execute("SELECT * FROM users WHERE username = %s", (username,))
```
- PHP example:
```php
// VULNERABLE
$query = "SELECT * FROM users WHERE username = '$username'";
// FIXED
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ?");
$stmt->bind_param("s", $username);
```
2. Implement input validation and sanitization for all user inputs
3. Enable database query logging for audit purposes
**Long-term Actions (30-90 days):**
1. Implement automated security testing in the CI/CD pipeline
- Add OWASP ZAP or Burp Suite automated scanning
- Integrate SAST tools (SonarQube, Checkmarx)
2. Conduct security awareness training for the development team
3. Establish a regular code review process with security focus
**Verification:**
1. Retest the vulnerability using sqlmap:
```bash
sqlmap -u "http://target/login" --data="username=admin&password=test" --batch
- Confirm the application no longer returns SQL error messages
- Verify parameterized queries are used in the codebase
### Weak Passwords / Default Credentials Remediation
```markdown
#### Remediation
**Immediate Actions (0-7 days):**
1. Change all default credentials immediately
- Admin panel: Change default admin/admin to a strong password
- Database: Change default root/password to a strong password
- Services: Change default service account passwords
2. Force password reset for all user accounts
3. Enable account lockout after 5 failed login attempts
**Short-term Actions (7-30 days):**
1. Implement a strong password policy:
- Minimum 12 characters
- Require uppercase, lowercase, numbers, and special characters
- Prevent password reuse (last 10 passwords)
- Maximum password age of 90 days
2. Implement Multi-Factor Authentication (MFA) for all administrative accounts
3. Implement rate limiting on login endpoints
**Long-term Actions (30-90 days):**
1. Deploy a Password Manager organization-wide
2. Implement Single Sign-On (SSO) with MFA
3. Conduct regular password audits
**Verification:**
1. Attempt brute force attack to confirm lockout is working
2. Verify password policy is enforced
3. Confirm MFA is required for administrative access
Outdated Software / Known CVE Remediation
#### Remediation
**Immediate Actions (0-7 days):**
1. Apply the security patch for [component] version [X.X.X]
- Example: Upgrade Apache Struts from 2.5.30 to 2.5.33
- Command: sudo apt update && sudo apt install libapache2-mod-struts
2. If patching is not immediately possible, implement compensating controls:
- Deploy WAF rule for the specific CVE
- Restrict access to the vulnerable component
- Disable the vulnerable feature if possible
**Short-term Actions (7-30 days):**
1. Implement a patch management process:
- Weekly vulnerability scanning
- Monthly patch review and deployment
- Emergency patching for Critical vulnerabilities within 48 hours
2. Establish a software bill of materials (SBOM) for all applications
**Long-term Actions (30-90 days):**
1. Implement automated vulnerability scanning in the CI/CD pipeline
2. Establish a regular penetration testing program
3. Develop a vulnerability management program
**Verification:**
1. Verify the updated version is running:
```bash
apache2 -v
# Expected: Server version: Apache/2.4.58 (Ubuntu)
- Retest the vulnerability to confirm it is patched
- Run vulnerability scanner to confirm no new issues
### Privilege Escalation Remediation (Linux)
```markdown
#### Remediation
**Immediate Actions (0-7 days):**
1. Apply the kernel security patch
- Command: sudo apt update && sudo apt upgrade linux-image-generic
- Reboot required: Yes
2. Remove unnecessary SUID binaries:
```bash
find / -perm -4000 -type f 2>/dev/null
# Remove SUID bit from unnecessary binaries
sudo chmod u-s /path/to/unnecessary/suid/binary
Short-term Actions (7-30 days):
- Implement the principle of least privilege:
- Review and restrict sudo permissions
- Remove unnecessary group memberships
- Implement role-based access control (RBAC)
- Harden the system configuration:
- Disable unnecessary services
- Implement AppArmor/SELinux profiles
- Restrict kernel parameters
Long-term Actions (30-90 days):
- Implement automated privilege escalation detection
- Establish a regular system hardening process
- Conduct regular privilege audits
Verification:
- Verify kernel version is updated:
uname -r # Expected: Updated kernel version - Run LinPEAS to confirm no privilege escalation vectors remain
- Attempt the original privilege escalation method to confirm it is patched
### Privilege Escalation Remediation (Windows)
```markdown
#### Remediation
**Immediate Actions (0-7 days):**
1. Apply Windows security updates:
- Open Windows Update and install all pending updates
- Command: wuauclt /detectnow
2. Fix the specific vulnerability:
- If AlwaysInstallElevated is enabled, disable it:
```powershell
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer" -Name "AlwaysInstallElevated" -Value 0
Set-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Installer" -Name "AlwaysInstallElevated" -Value 0
```
**Short-term Actions (7-30 days):**
1. Implement least privilege for service accounts
2. Review and restrict scheduled task permissions
3. Implement Application Whitelisting (AppLocker/WDAC)
**Long-term Actions (30-90 days):**
1. Implement automated Windows patch management (WSUS/SCCM)
2. Establish a regular Windows hardening process
3. Conduct regular privilege audits
**Verification:**
1. Verify Windows updates are installed:
```powershell
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5
- Run WinPEAS to confirm no privilege escalation vectors remain
- Attempt the original privilege escalation method to confirm it is patched
### Information Disclosure Remediation
```markdown
#### Remediation
**Immediate Actions (0-7 days):**
1. Disable verbose error messages in production:
- Apache: Edit httpd.conf, set "ServerTokens Prod" and "ServerSignature Off"
- IIS: Disable custom error pages in production
- PHP: Set "display_errors = Off" in php.ini
2. Remove or restrict access to debug endpoints
3. Remove version information from HTTP response headers
**Short-term Actions (7-30 days):**
1. Implement proper error handling across all applications
2. Configure custom error pages that don't reveal technical details
3. Implement a centralized logging system
**Long-term Actions (30-90 days):**
1. Implement automated information disclosure scanning
2. Establish a regular configuration review process
**Verification:**
1. Verify error messages are no longer verbose:
```bash
curl -I http://target/nonexistent-page
# Should return generic 404 without technical details
- Confirm version information is removed from headers
## 4. Writing Effective Remediation
### Bad vs. Good Recommendations
| Bad Recommendation | Good Recommendation |
|---|---|
| "Fix the SQL injection" | "Replace string concatenation with parameterized queries using prepared statements. Example: `cursor.execute(\"SELECT * FROM users WHERE username = %s\", (username,))`" |
| "Update the software" | "Upgrade Apache Struts from 2.5.30 to 2.5.33 or later to address CVE-2024-1234. Command: `sudo apt update && sudo apt install libapache2-mod-struts`" |
| "Improve security" | "Implement Content-Security-Policy header with the following directive: `default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'`" |
| "Use strong passwords" | "Enforce minimum 12-character passwords with complexity requirements (uppercase, lowercase, numbers, special characters) and implement MFA for all administrative accounts" |
| "Patch the system" | "Apply Ubuntu security update USN-6543-1 by running: `sudo apt update && sudo apt upgrade`" |
| "Fix the vulnerability" | "Implement input validation to reject special characters in user input. Use allowlist validation for expected input patterns" |
| "Secure the server" | "Disable unnecessary services: `sudo systemctl disable telnet sshv1 ftp`. Implement firewall rules to restrict access to required ports only" |
### Defense in Depth
Recommend multiple layers of protection:
Layer 1: Prevention (parameterized queries, input validation) Layer 2: Detection (WAF, intrusion detection, logging) Layer 3: Mitigation (least privilege, network segmentation) Layer 4: Response (incident response plan, backup and recovery)
### Root Cause vs. Symptom
Address the underlying issue, not just the symptom:
| Symptom Fix | Root Cause Fix |
|---|---|
| Block the specific exploit payload | Implement parameterized queries |
| Change the default password | Implement password policy and MFA |
| Patch the specific CVE | Implement patch management process |
| Remove the specific file | Implement proper access controls |
## 5. Remediation Prioritization
### Priority Matrix
| Severity | Immediate Action | Timeline |
|---|---|---|
| **Critical** | Apply patch, enable WAF, restrict access | 0-7 days |
| **High** | Apply patch, implement control | 7-30 days |
| **Medium** | Schedule fix, implement control | 30-90 days |
| **Low** | Plan fix, monitor | 90+ days |
| **Informational** | Review, consider | As scheduled |
### Effort vs. Impact Matrix
| Effort \ Impact | Low Impact | Medium Impact | High Impact |
|---|---|---|---|
| **Low Effort** | Do early | Do first | Do immediately |
| **Medium Effort** | Schedule | Do soon | Do first |
| **High Effort** | Plan | Plan | Plan and prioritize |
## 6. Key Takeaways
1. **Be specific.** Provide exact commands, configurations, and code examples.
2. **Be actionable.** The reader should know exactly what to do.
3. **Be prioritized.** Order remediation by urgency and effort.
4. **Be verifiable.** Include steps to verify the fix works.
5. **Defense in depth.** Recommend multiple layers of protection.
6. **Root cause.** Address the underlying issue, not just the symptom.
7. **For OSCP:** Include remediation for each finding. Be specific and actionable.
## 7. Further Reading
- OWASP Remediation Guidelines: https://owasp.org/www-project-web-security-testing-guide/
- CIS Controls: https://www.cisecurity.org/controls
- NIST SP 800-53 Security Controls
- SANS 25 Critical Security Controls