Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pemkey save in clear text is insecure #66

Open
ghost opened this issue Nov 12, 2019 · 0 comments
Open

pemkey save in clear text is insecure #66

ghost opened this issue Nov 12, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Nov 12, 2019

in trueconsensus/fastchain/genkeys.go
WriteNewKeys function. (which called in pbftserverengine.go -> main() -> cfg.GenerateKeysToFile() -> WriteNewKeys(cfg.Network.NumKeys, cfg.Logistics.KD))

func WriteNewKeys(kcount int, kdir string) {
	for k := 0; k < kcount; k++ {
		privateKey, _ := ecdsa.GenerateKey(ethcrypto.S256(), rand.Reader)
		publicKey := &privateKey.PublicKey

		pemEncoded := hex.EncodeToString(ethcrypto.FromECDSA(privateKey))
		pemEncodedPub := hex.EncodeToString(ethcrypto.FromECDSAPub(publicKey))

		pemkeyFname := fmt.Sprintf("sign%v.pem", k)
		err1 := ioutil.WriteFile(path.Join(kdir, pemkeyFname), []byte(pemEncoded), 0600)
		common.CheckErr(err1)
		pubkeyFname := fmt.Sprintf("sign%v.pub", k)
		err2 := ioutil.WriteFile(path.Join(kdir, pubkeyFname), []byte(pemEncodedPub), 0644)
		common.CheckErr(err2)
	}
}

ethcrypto.FromECDSA just make privatekey to byte type.
function save the pemkey as pemEncoded which Unencrypted.

If some node be attacked, the attacker can steal pemkey of users with a malicious software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants