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

track go/issues/21865: package to wipe/zero secrets. #125

Open
komuw opened this issue Sep 19, 2022 · 7 comments
Open

track go/issues/21865: package to wipe/zero secrets. #125

komuw opened this issue Sep 19, 2022 · 7 comments

Comments

@komuw
Copy link
Owner

komuw commented Sep 19, 2022

At this place;

ong/enc/enc.go

Line 91 in 2c4db06


we should zero(from memory) the derivedKey

func zero(key []byte) {
	if key == nil {
		return
	}

	for i := 0; i < len(key)+1; i++ {
		key[i] ^= key[i]
	}
}

or

// from: https://github.com/WireGuard/wireguard-go/blob/b51010ba13f0a3e59808fbdb1566cd2c6b834b95/device/noise-helpers.go#L72-L77
/* This function is not used as pervasively as it should because this is mostly impossible in Go at the moment */
func setZero(arr []byte) {
	for i := range arr {
		arr[i] = 0
	}
}

Note that golang/go#21865 has been accepted with the API at golang/go#21865 (comment), we should use that API when it becomes available.

@komuw komuw changed the title enc: zero derived encryption key enc: zero derived encryption key?? Sep 19, 2022
@komuw
Copy link
Owner Author

komuw commented Sep 19, 2022

check what cryptographers recommend.

@komuw
Copy link
Owner Author

komuw commented Sep 19, 2022

see: golang/go#21865

@komuw
Copy link
Owner Author

komuw commented Sep 19, 2022

@komuw
Copy link
Owner Author

komuw commented Sep 19, 2022

you can zero on GC right now with a finalizer:

type Secret struct {
    key [16]byte
}

s := &Secret{key: ...}
runtime.SetFinalizer(s, func(s *Secret) { s.key = [16]byte{} })

runtime.GC()

from golang/go#21865 (comment)

@komuw
Copy link
Owner Author

komuw commented Sep 19, 2022

Maybe we should not even do this at all. It sounds like security theatre without the security.
See:

@komuw komuw changed the title enc: zero derived encryption key?? enc: zero/wipe derived encryption key?? Sep 20, 2022
@komuw komuw changed the title enc: zero/wipe derived encryption key?? track go/issues/21865: package to wipe/zero secrets. Sep 20, 2022
@komuw
Copy link
Owner Author

komuw commented Sep 20, 2022

#127 was too much work and we don't know if it is even working.
We'll instead wait for golang/go#21865

This ticket now tracks that one.

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

Successfully merging a pull request may close this issue.

1 participant