Webhook receiver hardening
What middleBrick covers
- Validate webhook signatures and reject unsigned requests
- Detect CORS wildcard and header manipulation risks
- Identify input validation and data exposure issues
- Probe SSRF via URL-accepting parameters and body fields
- Map findings to OWASP API Top 10 and compliance evidence
- Provide remediation guidance for each finding
What webhook receiver hardening means
A webhook receiver is a public endpoint that accepts POST requests from third parties. Hardening means validating and constraining every incoming request so that only expected senders and payloads are processed. This includes verifying signatures, restricting HTTP methods, enforcing idempotency, and rejecting malformed or unexpected data before it reaches application logic.
Common risks when skipping hardening
Without hardening, teams expose endpoints that can be invoked by any remote party. Common outcomes include unintended data modification, duplicate processing, resource exhaustion, server-side request forgery through forwarded URLs, and injection of malicious headers or payloads. Attackers can probe for weak validation and use compromised third-party integrations as a pivot into internal services.
A secure workflow for webhook receivers
Start with a strict allowlist: accept only signed requests from known sources and reject everything else. Validate the webhook signature using the algorithm and secret documented by the sender. Enforce idempotency with an event ID and server-side deduplication window. Use a schema to validate structure, deserialize only safe types, and reject extra fields. Return early for invalid requests with a 400-level status, and log minimal metadata for audit without exposing sensitive content.
Example validation in code:
const crypto = require('crypto');
function verifySignature(body, header, secret) {
const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(body).digest('hex');
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(header));
}
if (!verifySignature(req.body, req.headers['x-hub-signature-256'], webhookSecret)) {
res.status(401).send('Invalid signature');
return;
}
What middleBrick covers out of the box
middleBrick scans your webhook receiver URL as an API surface using read-only methods and text-only POST probes. It checks for authentication bypass around webhook secrets, host header manipulation, CORS wildcard usage, and exposure of sensitive data in error messages. Detection categories include input validation, security headers, data exposure, SSRF against URL-accepting parameters, and unsafe consumption surfaces such as excessive third-party targets. Findings map to OWASP API Top 10 and support audit evidence for SOC 2 Type II and PCI-DSS 4.0.
Limitations and complementary controls
middleBrick does not fix, patch, or block findings; it reports and provides guidance. It does not perform active SQL injection or command injection testing, and it cannot detect business logic flaws that require domain understanding. The scanner also does not assess off-channel signals or out-of-band blind SSRF. Use it as one layer in a broader strategy that includes code review, schema validation, rate limiting, and signature verification testing.