Skip to content

Solved Issue: Critical Security Vulnerability - Unauthenticated Webhook Endpoints #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ayushshrivastv
Copy link

Issue #167 Critical Security Vulnerability - Unauthenticated Webhook Endpoints

Webhook Endpoints Lack Authentication and Signature Verification. The generic webhook controller, which handles all user defined webhooks for triggering workflows, is configured with skipAuth: true. This makes the endpoints public. Furthermore, there is no signature verification mechanism to validate the authenticity of incoming requests.

The client sending the webhook must use the secret to create a signature. The controller must recalculate the signature on the server side and compare it to the one in the header. If the signature is missing or invalid, the request must be rejected.

Solution Implemented

This critical vulnerability has been comprehensively addressed through two key security enhancements. First, the insecure skipAuth: true configuration has been removed from WEBHOOK_PARAMS in webhook-controller.ts to eliminate public access to webhook endpoints. Second, a robust webhook signature verification system has been implemented, featuring a dedicated webhook-secret.service.ts for secret management and signature verification, webhook-secret.model.ts for shared type definitions, modifications to webhook.service.ts for proper webhook secret handling, and enhanced type definitions in fastify.d.ts to ensure comprehensive type safety across the entire webhook authentication system.

Security Changes

  • webhook-controller.ts: Removed skipAuth: true configuration and implemented signature verification checks. Modified request handling to validate webhook signatures before processing.

  • webhook-secret.service.ts: New service dedicated to managing webhook secrets and handling signature verification. Implements HMAC-SHA256 signature generation and timing-safe comparison to prevent timing attacks.

  • webhook-secret.model.ts: New shared type definitions for webhook secrets and signatures, ensuring consistent typing across backend and frontend components.

  • webhook.service.ts: Enhanced webhook service to integrate secret management and signature verification. Modified workflow trigger logic to require valid signatures.

  • fastify.d.ts: Added TypeScript type definitions for webhook authentication and signature verification to ensure type safety and better developer experience when working with webhook security features.

This modular approach separates concerns between authentication, secret management, and request handling, making the security implementation both robust and maintainable.

The webhook endpoints now require valid signatures for all requests, using HMAC-SHA256 for signature generation and timing safe comparison for verification. Requests without valid signatures are rejected with 401 Unauthorized responses.

This resolves a critical security vulnerability that could have led to unauthorized workflow executions and compromising the entire platform’s security and integrity.

Fixes #167

…ated Webhook Endpoints

The webhook controller was configured with skipAuth: true, allowing any user with a valid flowId to trigger workflows without authentication. Additionally, there was no signature verification mechanism to validate incoming webhook requests. This exposed the application to potential DoS attacks, unauthorized workflow executions, and data manipulation risks.

This vulnerability has been addressed by:
1. Removing skipAuth: true from WEBHOOK_PARAMS in webhook-controller.ts
2. Implementing a robust webhook signature verification system:
   - Added webhook-secret.service.ts for secret management and signature verification
   - Added webhook-secret.model.ts for shared type definitions
   - Modified webhook.service.ts to handle webhook secrets
   - Added proper type definitions in fastify.d.ts

The webhook endpoints now require valid signatures for all requests, using HMAC-SHA256 for signature generation and timing-safe comparison for verification. Requests without valid signatures are rejected with 401 Unauthorized responses.

This resolves a critical security vulnerability that could have led to unauthorized workflow executions and potential system compromise.

Fixes AIxBlock-2023#167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: Critical Security Vulnerability - Unauthenticated Webhook Endpoints
1 participant