Skip to content

Security: btc-vision/as-bignum

SECURITY.md

Security Policy

Verichains

Professionally Audited by Verichains

Audit Status

Package Auditor Status
@btc-vision/as-bignum Verichains Audited

Supported Versions

Version Supported
0.1.x
< 0.1.0 ⚠️ Upgrade recommended

Reporting a Vulnerability

We take security vulnerabilities seriously. If you discover a security issue, please report it responsibly.

How to Report

  1. DO NOT open a public GitHub issue for security vulnerabilities
  2. Use GitHub Security Advisories to report vulnerabilities privately
  3. Include detailed steps to reproduce the vulnerability
  4. Allow reasonable time for a fix before public disclosure

What to Include

  • Description of the vulnerability
  • Affected version(s)
  • Steps to reproduce
  • Potential impact
  • Suggested fix (if any)

Response Timeline

Action Timeframe
Initial response 48 hours
Vulnerability assessment 7 days
Patch development 14-30 days
Public disclosure After patch release

Security Scope

In Scope

  • Integer arithmetic operations (u128, u256, i128, i256)
  • Division and modulo operations
  • Bit manipulation operations
  • Type conversions
  • Memory safety
  • Buffer handling

Out of Scope

  • Third-party dependencies (report to respective maintainers)
  • User implementation errors
  • Development/test environment issues only

About the Audit

This library has undergone a comprehensive security audit by Verichains, a leading blockchain security firm with extensive experience in:

  • Smart contract security audits
  • Blockchain protocol assessments
  • Cryptographic implementation reviews
  • WebAssembly security analysis

Audit Scope

The security audit covered the following areas:

Integer Operations

  • Overflow/underflow detection in arithmetic operations
  • Division by zero handling
  • Modulo operation edge cases
  • Multiplication overflow scenarios
  • Power function boundary conditions

Bit Manipulation

  • Shift operation bounds checking
  • Rotate operations correctness
  • Bitwise AND/OR/XOR/NOT operations
  • Count leading/trailing zeros accuracy
  • Population count correctness

Type Conversions

  • Safe narrowing conversions (u256 -> u128 -> u64)
  • Sign extension correctness (signed types)
  • String parsing validation
  • Byte array serialization/deserialization

Memory Safety

  • Buffer bounds checking
  • Immutable constant protection
  • Clone operation integrity
  • No uninitialized memory access

Vulnerabilities Addressed

This fork addresses critical vulnerabilities found in the original as-bignum library.

Security Best Practices

When using this library, follow these guidelines:

Input Validation

// Always validate external input before conversion
if (inputString.length > 78) { // Max digits for u256
  throw new Error("Input too large");
}
let value = u256.fromString(inputString);

Division Safety

// Check for zero divisor
if (divisor.isZero()) {
  throw new Error("Division by zero");
}
let result = dividend / divisor;

Overflow Awareness

// Use muldiv for multiplication followed by division to avoid overflow
let result = u128.muldiv(a, b, c); // (a * b) / c without intermediate overflow

Immutable Constants

// Use immutable versions for read-only access
let zero = u128.immutableZero; // More efficient, guaranteed unchanged

Audit Report

The full audit report from Verichains is available in the AUDIT directory.

Contact


Security is a continuous process. This document will be updated as new audits are completed.

There aren't any published security advisories