Secured Access Portal
Authenticate to access privileged security auditing instruments.
Client Token Telemetry
Simulates the mandatory server-side verification with Google's endpoint:
https://www.google.com/recaptcha/api/siteverify
{
"audit_status": "ready",
"instructions": "Solve the reCAPTCHA on the left or click 'Trigger Verification Query' to inspect the payload."
}
// 1. Never trust the frontend: Always verify g-recaptcha-response on the backend!
const express = require('express');
const app = express();
app.use(express.json());
const RECAPTCHA_SECRET = '6LdFkP4tAAAAAPxS7_NM-CS-DomhIIiIKQPJQbT1';
const ALLOWED_HOSTNAME = 'security.wiperspace.com';
app.post('/api/login', async (req, res) => {
const { username, password, recaptchaToken } = req.body;
if (!recaptchaToken) {
return res.status(400).json({ success: false, error: 'reCAPTCHA token missing.' });
}
// 2. Query Google's verification endpoint
const verifyParams = new URLSearchParams({
secret: RECAPTCHA_SECRET,
response: recaptchaToken,
remoteip: req.socket.remoteAddress // optional client IP
});
try {
const googleRes = await fetch('https://www.google.com/recaptcha/api/siteverify', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: verifyParams.toString()
});
const data = await googleRes.json();
// 3. CRITICAL AUDIT: Check data.success AND data.hostname to stop bypasses!
if (!data.success) {
return res.status(403).json({ success: false, error: 'reCAPTCHA validation failed', codes: data['error-codes'] });
}
if (data.hostname !== ALLOWED_HOSTNAME && process.env.NODE_ENV === 'production') {
return res.status(403).json({ success: false, error: 'Hostname mismatch exploit detected!' });
}
// 4. Proceed to verify user password safely
return res.json({ success: true, message: 'Authenticated successfully!' });
} catch (err) {
return res.status(500).json({ success: false, error: 'CAPTCHA service unavailable' });
}
});
Client-Side Only Validation Vulnerability
Checking grecaptcha.getResponse().length > 0 in frontend JS without validating on the backend is trivial to bypass. Attackers can strip the JS check or curl the endpoint directly.
api/siteverify and abort if success !== true.
Missing Hostname Verification
An attacker can create their own reCAPTCHA key for their own malicious domain, solve it legitimately, and forward the token to your server.
Fix: Check thatdata.hostname === 'security.wiperspace.com' in the JSON verification response.
Token Replay Attack Window
Google automatically invalidates a token once verified with siteverify. If backend code caches tokens or fails to verify immediately, replay attacks become possible.
Fail-Closed Architecture
If Google's API experiences a network timeout, deciding whether to allow the request (fail-open) or block it (fail-closed) determines resilience against DDoS.
Fix: Implement secondary rate-limiting (e.g. Redis sliding window) if you allow transient fail-open during outages.