Code Monkey home page Code Monkey logo

speculos's Introduction

Speculos

codecov lgtm

screenshot btc nano s

The goal of this project is to emulate Ledger Nano S/S+, Nano X, Blue and Stax apps on standard desktop computers, without any hardware device. More information can be found here in the documentation website (or in the docs/ folder directly).

Usage example:

./speculos.py apps/btc.elf --model nanos
# ... and open a browser on http://127.0.0.1:5000

Bugs and contributions

Feel free to open issues and create pull requests on this GitHub repository.

The master branch is protected to disable force pushing. Contributions should be made through pull requests, which are reviewed by @LedgerHQ members before being merged to master:

  • @LedgerHQ members can create branches directly on the repository (if member of a team with write access to the repository)
  • External contributors should fork the repository

Limitations

There is absolutely no guarantee that apps will have the same behavior on hardware devices and Speculos, though the differences are limited.

Syscalls

The emulator handles only a few syscalls made by common apps. For instance, syscalls related to app install, firmware update or OS info can't be implemented.

Invalid syscall parameters might throw an exception on a real device while being ignored on Speculos. Notably, this is the case for application allowed derivation path and curve and application settings flags which are enforced by the device OS, but ignored by Speculos.

Memory alignment

Attempts to perform unaligned accesses when not allowed (eg. dereferencing a misaligned pointer) will cause an alignment fault on a Ledger Nano S device but not on Speculos. Note that such unaligned accesses are supported by other Ledger devices.

Following code crashes on LNS device, but not on Speculos nor on other devices.

uint8_t buffer[20];
for (int i = 0; i < 20; i++) {
    buffer[i] = i;
}
uint32_t display_value = *((uint32_t*) (buffer + 1));
PRINTF("display_value: %d\n", display_value);

Watchdog

NanoX and Stax devices use an internal watchdog enforcing usage of regular calls to io_seproxyhal_io_heartbeat();. This watchdog is not emulated on Speculos.

Security

Apps can make arbitrary Linux system calls (and use QEMU semihosting features), thus don't run Speculos on untrusted apps.

It's worth noting that the syscall implementation (src/) doesn't expect malicious input. By the way, in Speculos, there is no privilege separation between the app and the syscalls. This doesn't reflect the security of the firmware on hardware devices where app and OS isolation is enforced.

Speculos is not part of Ledger bug bounty program.

Are you developing a Nano App as an external developer?

For a smooth and quick integration:

speculos's People

Contributors

abonnaudet-ledger avatar agrojean-ledger avatar aguinet avatar aido avatar aiooss-ledger avatar apaillier-ledger avatar apollounicorn avatar bigspider avatar cbouvet-ledger avatar cfranceschi-ledger avatar dependabot[bot] avatar dmorais-ledger avatar ericson2314 avatar fbeutin-ledger avatar gbillou avatar greenknot avatar jibeee avatar jleni avatar kingofpayne avatar lpascal-ledger avatar macro-ss avatar ndedouhet-ledger avatar niooss-ledger avatar ogoulpeau-ledger avatar philippebonnaz avatar sgliner-ledger avatar srasoamiaramanana-ledger avatar tamtamhero avatar xchapron-ledger avatar yhql avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.