diff options
author | gary rong <garyrong0905@gmail.com> | 2019-04-04 19:03:10 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-04-04 19:03:10 +0800 |
commit | d5cae48bae81cd6072255150162b26a3653f176e (patch) | |
tree | e516341d29d6fbffbac0f389ef012fb273326c8b /internal | |
parent | 9b3601cfce4d61cd303f5e243813fa89426259d4 (diff) | |
download | go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.tar go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.tar.gz go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.tar.bz2 go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.tar.lz go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.tar.xz go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.tar.zst go-tangerine-d5cae48bae81cd6072255150162b26a3653f176e.zip |
accounts, cmd, internal: disable unlock account on open HTTP (#17037)
* cmd, accounts, internal, node, rpc, signer: insecure unlock protect
* all: strict unlock API by rpc
* cmd/geth: check before printing warning log
* accounts, cmd/geth, internal: tiny polishes
Diffstat (limited to 'internal')
-rw-r--r-- | internal/ethapi/api.go | 9 | ||||
-rw-r--r-- | internal/ethapi/backend.go | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index b6f01b753..e5a8124b1 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -317,7 +317,14 @@ func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (commo // UnlockAccount will unlock the account associated with the given address with // the given password for duration seconds. If duration is nil it will use a // default of 300 seconds. It returns an indication if the account was unlocked. -func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *uint64) (bool, error) { +func (s *PrivateAccountAPI) UnlockAccount(ctx context.Context, addr common.Address, password string, duration *uint64) (bool, error) { + // When the API is exposed by external RPC(http, ws etc), unless the user + // explicitly specifies to allow the insecure account unlocking, otherwise + // it is disabled. + if s.b.ExtRPCEnabled() && !s.b.AccountManager().Config().InsecureUnlockAllowed { + return false, errors.New("account unlock with HTTP access is forbidden") + } + const max = uint64(time.Duration(math.MaxInt64) / time.Second) var d time.Duration if duration == nil { diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index e23ee03b1..e88207f87 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -44,6 +44,7 @@ type Backend interface { ChainDb() ethdb.Database EventMux() *event.TypeMux AccountManager() *accounts.Manager + ExtRPCEnabled() bool // BlockChain API SetHead(number uint64) |