Q1 2026 Security & Compliance Report44 incidents, $482M in losses, insights from 11 industry leaders.
Read the report

Audit name:

[dApp] Sundial | BTC Locker | Apr2026

Date:

May 15, 2026

Table of Content

Introduction
Audit Summary
System Overview
Findings
Appendix 1. Severity Definitions
Appendix 2. Scope
Appendix 3. Additional Valuables
Disclaimer

Want a comprehensive audit report like this?

Introduction

We express our gratitude to the Sundial team for the collaborative engagement that enabled the execution of this dApp Security Assessment.

Sundial Protocol is building Bitcoin-native yield infrastructure, enabling users to lock BTC into time-based escrow contracts and earn yield through a decentralized staking mechanism. The protocol leverages Bitcoin Script primitives (CLTV, CSV) to create trustless timelock and escrow outputs, allowing for non-custodial yield distribution without requiring wrapped tokens or cross-chain bridges.

Document

NamedApp Code Review and Security Analysis Report for Sundial
Audited ByAdedolapo Olayinka-Adeyemi
Approved ByEce Orsel
Websitesundialprotocol.com
Changelog30/01/2025 - Preliminary Report
PlatformBitcoin
LanguageTypescript
TagsWhite-box
Methodologyhttps://docs.hacken.io/methodologies/dapp-audit-methodology
  • Document

    Name
    dApp Code Review and Security Analysis Report for Sundial
    Audited By
    Adedolapo Olayinka-Adeyemi
    Approved By
    Ece Orsel
    Website
    sundialprotocol.com
    Changelog
    30/01/2025 - Preliminary Report
    Platform
    Bitcoin
    Language
    Typescript
    Tags
    White-box

Review Scope

Repositoryhttps://github.com/sundial-protocol/btc-locker
Commitdd1332516d9721b67fefdc219048527de066cbdc

Audit Summary

11Total Findings
11Resolved
0Accepted
0Mitigated

The system users should acknowledge all the risks summed up in the risks section of the report

{FindingsVulnSeverityStatusTable}

Documentation quality

  • Comprehensive top-level README.md with protocol overview, installation instructions, and usage examples

  • Detailed CLI.md documenting all command-line operations with flags and examples

Code quality

  • Strong TypeScript usage with strict typings, dedicated types.ts, and interface definitions for all transaction parameters

  • Clean modular architecture with single-responsibility separation (locker/scripts/, locker/transactions/, utils/)

System Overview

The BTC Locker core library lives in its own top-level /packages/core folder and is responsible for Bitcoin script generation, PSBT construction, transaction signing, and on-chain interaction with Bitcoin APIs. Inside there is:

A README.md and supporting documentation that explain overall setup, usage patterns, and integration guidance for the Sundial staking workflow.

src/ with several subdirectories and standalone modules:

  • locker/ — the primary module containing Bitcoin locking primitives:

    • core.ts which provides the BTCLockerCore base class handling ECC initialization, transaction signing, and PSBT finalization logic.

    • index.ts exposing the unified BTCLocker facade class that combines key generation, script management, and transaction building into a single interface.

    • keypair.ts for Bitcoin key pair generation (random and from existing private keys) using the secp256k1 curve.

    • script-manager.ts and transaction-manager.ts as thin facades delegating to specialized builders.

    • scripts/ subdirectory containing:

      • timelock.ts for absolute (CLTV) and relative (CSV) timelock script creation.

      • escrow.ts for dual-path escrow scripts with before/after deadline spending conditions.

    • transactions/ subdirectory containing:

      • deposit/ with deposit.ts, deposit-with-script.ts, and calculate.ts for Dawn Protocol staking transactions that split funds between escrow and timelock outputs.

      • withdraw.ts for combining escrow and timelock inputs into a single withdrawal transaction.

      • claim.ts for spending from escrow scripts using either the before-deadline or after-deadline path.

      • distribute.ts for yield distribution transactions back to timelock addresses.

      • generic.ts providing low-level spending and funding transaction primitives.

  • utils/ — shared utility modules:

    • scripts.ts with helpers for script validation, address generation, script parsing, and locktime extraction.

    • keys.ts for public/private key validation and ECPair creation.

    • fees.ts encapsulating fee estimation logic with priority levels (HIGH/MEDIUM/LOW) and dust threshold calculations.

    • transactions.ts for UTXO selection, witness input construction, and metadata output appending.

    • metadata.ts implementing the Sundial OP_RETURN metadata protocol (60-byte schema with magic bytes, version, transaction type, deposit ID, provider pubkey, flags, and CRC-32 checksum).

    • validation.ts with common parameter validation (locktime, amounts, protocol fees).

    • time.ts for timestamp/date conversions and duration calculations.

    • network.ts defining Bitcoin network configurations (mainnet, testnet, regtest).

  • bitcoin-api.ts — integration layer for external Bitcoin APIs (Mempool.space, Blockstream, BlockCypher) providing UTXO fetching, transaction broadcasting, fee estimation, and block height queries.

  • errors.ts defining custom error classes (BTCLockerError, ValidationError, TimelockError) for structured error handling.

  • types.ts and index.ts for TypeScript type definitions and public API exports.

Supporting files include package.json, TypeScript configurations (tsconfig.json, tsconfig.build.json), Vitest test suite under tests/, ESLint/Prettier configs, and webpack bundling configuration for browser distribution.

Findings

Code
Title
Status
Severity
F-2026-1609Spending PSBT Builder Omits Required Previous Output Data
fixed

Medium
F-2026-1609Incorrect PSBT Finalization Logic for Script-Based Spending
fixed

Medium
F-2026-1609Infinite Recursion in BTCLocker Facade Methods
fixed

Medium
F-2026-1609Claim and Withdraw Flows Assume P2SH While Address Uses SegWit-Like Form
fixed

Low
F-2026-1609Distribution Builder Uses Incorrect Input Script Fallback
fixed

Low
F-2026-1609Relative Timelock (CSV) Exposed but Not Fully Implemented
fixed

Low
F-2026-1609Inconsistent PSBT Encoding Across Public API
fixed

Low
F-2026-1611Transaction Amount Lacks Upper Bound Validation
fixed

Observation
F-2026-1611Keypair Object Serialization Exposes Internal ECPair Properties
fixed

Observation
F-2026-1611UTXO Selection Without Ordinal-Safe Controls
fixed

Observation
1-10 of 11 findings

Protect your dApp with insights like these.

Appendix 1. Severity Definitions

Findings are categorized based on their potential impact and assigned a severity level using the Common Vulnerability Scoring System (CVSS) version 4.0:

Severity

Description

Critical
These issues present a major security vulnerability that poses a severe risk to the system. They require immediate attention and must be resolved to prevent a potential security breach or other significant harm.

High
These issues present a significant risk to the system, but may not require immediate attention. They should be addressed in a timely manner to reduce the risk of the potential security breach.

Medium
These issues present a moderate risk to the system and cannot have a great impact on its function. They should be addressed in a reasonable time frame, but may not require immediate attention.

Low
These issues present no risk to the system and typically relate to the code quality problems or general recommendations. They do not require immediate attention and should be viewed as a minor recommendation.
  • Severity

    Critical

    Description

    These issues present a major security vulnerability that poses a severe risk to the system. They require immediate attention and must be resolved to prevent a potential security breach or other significant harm.

    Severity

    High

    Description

    These issues present a significant risk to the system, but may not require immediate attention. They should be addressed in a timely manner to reduce the risk of the potential security breach.

    Severity

    Medium

    Description

    These issues present a moderate risk to the system and cannot have a great impact on its function. They should be addressed in a reasonable time frame, but may not require immediate attention.

    Severity

    Low

    Description

    These issues present no risk to the system and typically relate to the code quality problems or general recommendations. They do not require immediate attention and should be viewed as a minor recommendation.

Appendix 2. Scope

The scope of the project includes the following:

Scope Details

Repositoryhttps://github.com/sundial-protocol/btc-locker
Commitdd1332516d9721b67fefdc219048527de066cbdc

Appendix 3. Additional Valuables

Frameworks and Methodologies

This security assessment was conducted in alignment with recognised penetration testing standards, methodologies and guidelines, including the NIST SP 800-115 – Technical Guide to Information Security Testing and Assessment , the Penetration Testing Execution Standard (PTES) , and the OWASP Testing Guide . These assets provide a structured foundation for planning, executing, and documenting technical evaluations such as vulnerability assessments, exploitation activities, and security code reviews. Hacken’s internal penetration testing methodology extends these principles to Web2 and Web3 environments to ensure consistency, repeatability, and verifiable outcomes.

Disclaimer