Skip to content

Conversation

@esodot
Copy link

@esodot esodot commented Oct 8, 2025

  • Blockfrost webhook signature validation and verification functionality
  • Refactoring and dependency updates

esodot and others added 4 commits October 8, 2025 12:53
- Blockfrost webhook signature validation and verification functionality
- Refactoring and dependency updates
- Export the src/utils/blockfrost_signature_validator.dart
- Add own utils export file to control the exported files from utils folder.
- Use utils_exports.dart in main export file
- Add own utils export file to control the exported files from utils folder.
- Use utils_exports.dart in main export file
@slowbackspace
Copy link

slowbackspace commented Oct 8, 2025

Hi @esodot, thanks for the contribution!
Would you be interested to add usage examples to our doscs on
https://blockfrost.dev/start-building/webhooks/webhooks-signatures#using-sdk
and
https://blockfrost.dev/start-building/webhooks/using-webhooks#process-a-webhook-request

(there is a "Edit this page" button at the bottom)

There is a bounty of 100 ADA for the task blockfrost/blockfrost.dev#8 and you already did the hard part 🚀

@andro-devs
Copy link

Hi @slowbackspace, thank you. I'm currently preparing the usage examples for the dart SDK and will create a pull request there ASAP.

@andro-devs
Copy link

andro-devs commented Oct 8, 2025

@slowbackspace added PR into documentation repo: blockfrost/blockfrost.dev#60

Copy link

@slowbackspace slowbackspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Just a few changes required.
In general:

  • The API for the verification function should stay consistent across all SDKs (order of fn parameters, same amount of configurability, same defaults, errors on failure)
  • Instead of returning false, throw a custom error/exception in every failure case.

And don't forget to send your ADA address to receive the bounty once the PR is merged. Sadly there is a bounty is for the both sdk implementation and documentation so we can either send it to one address or split it between two.

import 'package:blockfrost_api/src/utils/signature_validator.dart';
import 'package:crypto/crypto.dart';

const int maxToleranceSeconds = 60;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make this configurable by using it as a fn param in BlockfrostSignatureValidator.validate with default of 600s. It should mimic TS/Python interface as closest as possible.

https://github.com/blockfrost/blockfrost-js/blob/master/src/utils/helpers.ts#L211

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

/// Adapter class which implements the validator interface to validate the blockfrost webhook signature.
class BlockfrostSignatureValidator implements SignatureValidator {
@override
bool validate({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

providedSignatures.any((sig) => sig == expectedSignature);

if (!signatureMatch) {
print('Verification Failed: Signatures do not match.');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaking the expected HMAC = leaking an auth token for that payload+timestamp.
If anyone with log access sees the expected signature for the payload, they can replay the request within the tolerance window by sending the same body with t and v1 values from the logs.

If possible throw an error similiar to python/node.js implementation with signature header and payload attached. Don't print expected signature.
https://github.com/blockfrost/blockfrost-js/blob/master/src/utils/helpers.ts#L285-L291

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

print("timeDifference: $timeDifference");

if (timeDifference > maxToleranceSeconds) {
print(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, please throw an error instead of using print fn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- Refactor print messages.
- Add SignatureValidationException.
- Use signature_validation_exception.dart in main export file.
@andro-devs
Copy link

andro-devs commented Oct 22, 2025

@slowbackspace Thank you for your review. I did the needed changes. Please review again. Also updated the PR in blockfrost.dev repo: blockfrost/blockfrost.dev#60

Regarding Bounty, please use this address:
addr1q9y86rykw0jdt0esf8g2y7y9dnp7hyp7tpwf4ez86jfzs4luw7nfzwm79hj9va6tek7nl5k2h4nu8urfvvc4wj0j5d2qq7u7ld
Thank you.

@esodot esodot requested a review from slowbackspace October 23, 2025 12:23
@andro-devs
Copy link

Hi @slowbackspace any updates?

Copy link

@slowbackspace slowbackspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. LGTM! The 100 ADA bounty will be paid shortly.

@andro-devs
Copy link

if its simpler for you use the ada handle: "adam.app"

@andro-devs
Copy link

Sorry for the delay. LGTM! The 100 ADA bounty will be paid shortly.

Any updates here?

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.

3 participants