Skip to content

fix(config): require secure WEBHOOK_SECRET configuration - #163

Merged
Manuel1234477 merged 1 commit into
StellarGateLabs:mainfrom
whiteghost0001:fix/webhook-secret-validation
Jul 20, 2026
Merged

fix(config): require secure WEBHOOK_SECRET configuration#163
Manuel1234477 merged 1 commit into
StellarGateLabs:mainfrom
whiteghost0001:fix/webhook-secret-validation

Conversation

@whiteghost0001

@whiteghost0001 whiteghost0001 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary
This pull request addresses the security vulnerability where WEBHOOK_SECRET defaulted to a guessable, publicly-known literal value ("default-secret"). It removes the default fallback and implements a strict configuration validation flow at server startup. Additionally, this PR fixes a pre-existing compilation error in the payment rate limiter module.

Changes

  1. Removed Default Webhook Secret Fallback: Deleted the env_or helper function in src/config.rs and replaced it with explicit environment variables checks to prevent silently falling back to insecure or guessable defaults for sensitive configurations.
  2. Added Configuration Validation at Boot: Introduced the validate_webhook_secret helper to validate WEBHOOK_SECRET in Config::from_env(). Validation fails fast at boot if the secret:
    • Is missing/not set in the environment.
    • Is empty.
    • Contains only whitespace.
    • Equals the old guessable default ("default-secret").
    • Is shorter than 32 characters.
  3. Preserved Out-of-the-Box Local Dev Experience: Updated .env.example with a dummy value of 32+ characters (default-development-webhook-signing-secret-32-chars) so that developers copying the example template have a valid config out-of-the-box.
  4. Cleaned Up Rate-Limiter Compilation Issue: Removed a redundant and broken inner rate-limit middleware layer in src/api/mod.rs that referred to an undefined variable (rate_limit_rps) and a non-existent module (tower_http::util).

Security Impact
Enforcing strict, fail-fast validation at boot prevents server instances from running without a configured webhook secret or with weak, guessable secrets, closing a vulnerability that could allow attackers to forge webhook signatures.

Testing Performed

  • Appended a comprehensive suite of unit tests to the end of the tests module in src/config.rs, validating each validation constraint (missing, empty, whitespace, guessable default, short secret, valid long secret, production startup failure, and successful startup).
  • Verified that all unit, integration, and doc tests pass cleanly (cargo test).
  • Verified code quality and styling check out without issues (cargo fmt -- --check and cargo clippy --all-targets --all-features -- -D warnings).

closes #68

@Manuel1234477
Manuel1234477 merged commit 79bfcc7 into StellarGateLabs:main Jul 20, 2026
1 of 3 checks passed
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.

WEBHOOK_SECRET defaults to the guessable literal "default-secret"

2 participants