| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
QHelp previews: javascript/ql/src/experimental/Security/CWE-340/TokenBuiltFromUUID.qhelpPredictable tokenGUIDs (often called UUIDs) are widely used in modern web applications. One common use for UUIDs is the generation of one-time-use tokens. These can used for password reset, and e-mail confirmation routines, for example. There are five versions of UUIDs defined in RFC 4122. Out of the five, four are generated in a predictable manner. This means it is possible for someone to predict future UUIDs based on a sample generated by the target application. Version four is the only UUID version expected to be randomly generated. Therefore, for situations where predictable tokens are not desired (e.g. password reset tokens), all other versions should be avoided. RecommendationWhen using GUIDs/UUIDs for generating tokens that should not be predictable, use version four. ExampleThis example shows a UUID v1 being used for a password reset routine. var uuid = require('uuid');
module.exports = function (app) {
app.use('/login', function (req, res) {
var username = req.body.username;
var password = req.body.password;
if (!username) {
res.status(400);
return;
}
if (!password) {
res.status(400);
return;
}
var newToken = {
userId: user._id,
token: uuid.v1(),
created: new Date(),
};
res.status(200).json({
token: newToken.token
});
});
};References
Predictable tokenGUIDs (often called UUIDs) are widely used in modern web applications. One common use for UUIDs is the generation of one-time-use tokens. These can used for password reset, and e-mail confirmation routines, for example. There are five versions of UUIDs defined in RFC 4122. Out of the five, four are generated in a predictable manner. This means it is possible for someone to predict future UUIDs based on a sample generated by the target application. Version four is the only UUID version expected to be randomly generated. Therefore, for situations where predictable tokens are not desired (e.g. password reset tokens), all other versions should be avoided. RecommendationWhen using GUIDs/UUIDs for generating tokens that should not be predictable, use version four. ExampleThis example shows a UUID v1 being used for a password reset routine. import uuid
class User:
def __init__(self):
self.token = None
def resetPassword(self):
self.token = uuid.uuid1().hex
user = User()
user.resetPassword()References |
Sorry, something went wrong.
|
The QHelp check is failing. You can see the error in the comment above. Have you checked out the SensitiveNode class in JS? I think that could be useful for this query. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you for your submission!
Overall, the Python bits look really solid to me. I have made a bunch of suggestions for improvements, mostly to help you learn how to use the Python QL libraries even more effectively.
Let me know if I need to elaborate on anything. 🙂
Sorry, something went wrong.
You are totally right! I just scanned the module's document and assumed it would implement it all. Pasting the documentation here for future reference https://docs.python.org/3/library/uuid.html?highlight=uuid#uuid.UUID. Co-authored-by: Taus <tausbn@github.com>
Co-authored-by: Taus <tausbn@github.com>
…UUID.ql Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
There was a problem hiding this comment.
JS parts look OK for an experimental query.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks again!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
A couple of queries based on Daniel Thatcher's work https://www.intruder.io/research/in-guid-we-trust to look for "tokens" and "codes" generated from predictable UUIDs.