This document outlines all security vulnerabilities that have been identified and fixed in the IP Reputation Checker application.
Severity: HIGH
CWE: CWE-79, CWE-80
Issue: User input was directly interpolated into HTML using innerHTML without sanitization.
Before:
resultDiv.innerHTML = `<h3>Results for IP: ${ip}</h3>...`; // VULNERABLEAfter:
const title = document.createElement('h3');
title.textContent = `Results for IP: ${ip}`; // SAFE
resultDiv.appendChild(title);Impact: Prevents attackers from injecting arbitrary JavaScript code through the IP input field.
Severity: CRITICAL
CWE: CWE-798 (Use of Hard-Coded Credentials)
Issue: API keys were exposed in source code.
Before:
const abuseKey = "2e0272c72bbd67cb0180ad31a66d51966785338cc41e7434560c723b5e66622215525ca13c9896eb";
const virusKey = "bd159d67bed1d755c5ba6485660cb16dfd47d31235c092c50265804df800776b";After:
const abuseKey = process.env.ABUSEIPDB_API_KEY;
const virusKey = process.env.VIRUSTOTAL_API_KEY;Files Added:
.env- Contains actual API keys (DO NOT COMMIT).env.example- Template for environment variables.gitignore- Prevents .env from being committed
Impact: API keys are no longer exposed in version control.
Severity: HIGH
Headers Added via Helmet:
| Header | Value | Purpose |
|---|---|---|
Content-Security-Policy |
Restrictive | Prevents unauthorized script execution |
X-Content-Type-Options |
nosniff | Prevents MIME sniffing attacks |
X-Frame-Options |
DENY | Prevents clickjacking (XSS variant) |
X-XSS-Protection |
1; mode=block | Legacy XSS protection |
Strict-Transport-Security |
max-age=31536000 | Enforces HTTPS |
Referrer-Policy |
strict-origin-when-cross-origin | Limits referrer information |
Impact: Provides defense-in-depth against various attack vectors.
Severity: MEDIUM
CWE: CWE-770 (Allocation of Resources Without Limits)
Issue: API endpoints were vulnerable to brute force and DoS attacks.
Implemented:
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // 100 requests per window
});
const apiLimiter = rateLimit({
windowMs: 1 * 60 * 1000, // 1 minute
max: 10, // 10 requests per minute
});Impact: Protects against brute force and DoS attacks.
Severity: MEDIUM
CWE: CWE-346 (Origin Validation Error)
Before:
app.use(cors()); // Allows requests from ANY originAfter:
const corsOptions = {
origin: ["http://localhost:3000", "http://localhost:5000"],
credentials: true,
optionsSuccessStatus: 200,
};
app.use(cors(corsOptions));Impact: Restricts API access to trusted origins only.
Severity: MEDIUM
Added Validations:
Server-side:
- IPv4 and IPv6 format validation
- IP address length validation (max 45 characters)
- Proper URL encoding of parameters
- API key existence check
Client-side:
- IP address format validation (IPv4/IPv6)
- Length validation
- User-friendly error messages
Impact: Prevents malformed requests and reduces attack surface.
Severity: MEDIUM
CWE: CWE-209 (Information Exposure Through an Error Message)
Issue: Error messages exposed internal system details.
Before:
res.status(500).json({
error: "Error fetching data from AbuseIPDB",
details: error.message // Exposes internal error
});After:
const sanitizeError = (error) => {
return { error: "An error occurred while processing your request. Please try again." };
};
res.status(500).json(sanitizeError(error));Impact: Prevents information leakage to potential attackers.
Severity: MEDIUM
CWE: CWE-754 (Improper Exception Handling)
Added:
const response = await fetch(url, {
timeout: 5000 // 5 second timeout
});Impact: Prevents hanging requests and resource exhaustion.
npm installcp .env.example .envEdit .env and add your actual API keys:
ABUSEIPDB_API_KEY=your_key_here
VIRUSTOTAL_API_KEY=your_key_here
PORT=3000
NODE_ENV=production
npm startNODE_ENV=production npm start- Navigate to http://localhost:3000/abuse.html
- In the IP input field, enter:
"><img src=x onerror=alert('XSS')> - Click "Check IP"
- ✅ Expected: The text is displayed as plain text, no alert appears
- Enter invalid IP:
999.999.999.999 - ✅ Expected: Error message "Invalid IP address format"
- Send 11 API requests within 1 minute
- ✅ Expected: 11th request receives 429 Too Many Requests error
curl -I http://localhost:3000✅ Expected: See all security headers in response
- Set
NODE_ENV=production - Use HTTPS (configure reverse proxy or use environment variable)
- Store
.envfile securely (outside version control) - Rotate API keys regularly
- Implement additional authentication if needed
- Use a Web Application Firewall (WAF)
- Regular security audits and penetration testing
helmet- Security headersexpress-rate-limit- Rate limitingdotenv- Environment variable managementcors- CORS management
- ✅
server.js- Added security middleware and validation - ✅
package.json- Added security dependencies - ✅
public/abuse.html- XSS prevention + input validation - ✅
public/virus.html- XSS prevention + input validation - ✅
abuse.html- XSS prevention + input validation - ✅
virus.html- XSS prevention + input validation - ✅
.env.example- Environment variable template - ✅
.env- Environment variables - ✅
.gitignore- Prevent accidental commits of sensitive files
Release: 2.0.1 (bugfix)
Last Updated: April 17, 2026
Status: All vulnerabilities patched and tested