CVE-2021-32685: Improper Verification of Cryptographic Signature (CWE-347)
value: tEnvoy contains the PGP, NaCl, and PBKDF2 in node.js and the browser (hashing, random, encryption, decryption, signatures, conversions), used by TogaTech.org. In versions prior to 7.0.3, the `verifyWithMessage` method of `tEnvoyNaClSigningKey` always returns `true` for any signature that has a SHA-512 hash matching the SHA-512 hash of the message even if the signature was invalid. This issue is patched in version 7.0.3. As a workaround: In `tenvoy.js` under the `verifyWithMessage` method definition within the `tEnvoyNaClSigningKey` class, ensure that the return statement call to `this.verify` ends in `.verified`.
CWE description: The product does not verify, or incorrectly verifies, the cryptographic signature for data.
CVSS v3 base score: 9.8
Published: 2021-06-16T01:15Z
Repository: https://github.com/TogaTech/tEnvoy
Language: JavaScript
Files changed: node/tenvoy.js, tenvoy.js
Commit date: 2021-06-15 10:16:16 -0700
Commit message: Critical security fix in verifyWithMessage

Diff: diff --git a/node/tenvoy.js b/node/tenvoy.js
index 7b2d5816..2cf0a25f 100644
--- a/node/tenvoy.js
+++ b/node/tenvoy.js
@@ -2164,11 +2164,11 @@ function tEnvoyNaClSigningKey(key, type = "secret", password = null, passwordPro
 		}
 		if(signed.split("::").length != 2) {
 			throw "tEnvoyNaClSigningKey Fatal Error: Invalid signature.";
 		}
 		let hash = _tEnvoy.util.hexToBytes(signed.split("::")[0]);
-		return this.verify(signed, password) && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
+		return this.verify(signed, password).verified && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
 	}
 	
 	this.toPublic = (password = null) => {
 		return new tEnvoyNaClSigningKey(this.getPublic(password), "public", _getPassword(), _passwordProtected, _tEnvoy);
 	}
diff --git a/tenvoy.js b/tenvoy.js
index 52036f0e..b941c3a2 100644
--- a/tenvoy.js
+++ b/tenvoy.js
@@ -48181,11 +48181,11 @@ function tEnvoyNaClSigningKey(key, type = "secret", password = null, passwordPro
 		}
 		if(signed.split("::").length != 2) {
 			throw "tEnvoyNaClSigningKey Fatal Error: Invalid signature.";
 		}
 		let hash = _tEnvoy.util.hexToBytes(signed.split("::")[0]);
-		return this.verify(signed, password) && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
+		return this.verify(signed, password).verified && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
 	}
 	
 	this.toPublic = (password = null) => {
 		return new tEnvoyNaClSigningKey(this.getPublic(password), "public", _getPassword(), _passwordProtected, _tEnvoy);
 	}

Vulnerable code: 		return this.verify(signed, password) && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
		return this.verify(signed, password) && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
Fixed code: 		return this.verify(signed, password).verified && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);
		return this.verify(signed, password).verified && _tEnvoy.util.bytesToHex(_nacl.hash(_tEnvoy.util.pack(message))) == _tEnvoy.util.bytesToHex(hash);