-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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
lib: add diagnostics_channel events to cipher and hashing algorithms #44356
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
Is this a common thing? |
@@ -62,6 +62,13 @@ const { normalizeEncoding } = require('internal/util'); | |||
|
|||
const { StringDecoder } = require('string_decoder'); | |||
|
|||
const dc = require('diagnostics_channel'); | |||
const onNewCipherChannel = dc.channel('crypto.cipher.new'); | |||
const onNewDecipherChannel = dc.channel('crypto.decipher.new'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cipher
and Decipher
should not be used; I don't think it is beneficial to introduce any sort of monitoring for these APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't very sure about it.
But as cipher
and decipher
are deprecated, createCipher
and createDecipher
methods are deprecated and defined like that, it is not easy to patch.
ObjectDefineProperties(module.exports, {
createCipher: {
__proto__: null,
enumerable: false,
value: deprecate(createCipher,
'crypto.createCipher is deprecated.', 'DEP0106')
}
But, if the rule is "not modify deprecated methods", I can delete this part of the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, if the rule is "not modify deprecated methods", I can delete this part of the code
There is no such rule; I just think adding complexity to a feature that nobody should be using might be the wrong approach.
Don't forget to add it to the docs here: https://nodejs.org/api/diagnostics_channel.html#built-in-channels |
For example, if the product want to detect the used cypher/hashing algorithms, for example, to detect the uses of the insecure |
f8ae06f
to
275a51d
Compare
That seems difficult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some lint errors due to missing semicolons, but other than that LGTM.
@tniessen yes, you are right, thanks |
Just to be clear, I am not saying that adding such events to all crypto operations is a good idea. I am just wondering what the goal is here. I assume that most cryptographic vulnerabilities arise from design issues or misuse of cryptographic APIs or mechanisms, not from selecting weak algorithms. |
Adding
crypto.cipher.new
,crypto.decipher.new
,crypto.cipheriv.new
,crypto.decipheriv.new
,crypto.hash.new
,crypto.hash.copy
,crypto.hmac.new
,crypto.sign.new
andcrypto.verify.new
diagnostics_channel events so APMs don't need to patch thecrypto
module to know when a particular crypto algorithm is used.