{"action":"created","issue":{"url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube/issues/360","repository_url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube","labels_url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube/issues/360/labels{/name}","comments_url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube/issues/360/comments","events_url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube/issues/360/events","html_url":"https://github.com/DanielnetoDotCom/YouPHPTube/issues/360","id":296003166,"number":360,"title":"[Security] Use appropriate, secure hashing algorithm","user":{"login":"TheAssassin","id":4503202,"avatar_url":"https://avatars3.githubusercontent.com/u/4503202?v=4","gravatar_id":"","url":"https://api.github.com/users/TheAssassin","html_url":"https://github.com/TheAssassin","followers_url":"https://api.github.com/users/TheAssassin/followers","following_url":"https://api.github.com/users/TheAssassin/following{/other_user}","gists_url":"https://api.github.com/users/TheAssassin/gists{/gist_id}","starred_url":"https://api.github.com/users/TheAssassin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheAssassin/subscriptions","organizations_url":"https://api.github.com/users/TheAssassin/orgs","repos_url":"https://api.github.com/users/TheAssassin/repos","events_url":"https://api.github.com/users/TheAssassin/events{/privacy}","received_events_url":"https://api.github.com/users/TheAssassin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2018-02-09T20:33:32Z","updated_at":"2018-04-16T11:05:46Z","closed_at":null,"author_association":"NONE","body":"*Sorry for posting this without content at first.*\r\n\r\nThis application is using a very insecure password hashing method. It uses the MD5 algorithm without any salting or other security measures.\r\n\r\nNow, there's several issues with this hashing method. First of all MD5 is a very weak hashing algorithm. There's several known attacks on it, and it should not be used any more for any cryptographic work.\r\n\r\nThe next issue is there is no salting applied, hence equal passwords will yield the same results in the database. Now, looking at a database, you could easily check who else's using your password, etc., and an attacker could make those checks as well, if they had access to the database. MD5 being a really old and well known hashing algorithm, there's also a lot of so-called rainbow tables which you can feed with a given hash value to get the original text.\r\n\r\nSo, don't use MD5 for security stuff. Ever.\r\n\r\nTo mitigate some of those issues, so-called \"salting\" has been invented. Using salting prevents two equal passwords to result in the same hash value. It works like this: you add a column to the database, and fill it with random strings (you need a proper PRNG to get some appropriate entropy there, but as long as you're using a crypto library, this is the least issue to worry about). When hashing a password, you just combine that password and the salt, and feed that into your hashing algorithm. Now, if you have the same password twice, the probability that both salts differ is very high, so the results won't be the same either.\r\n\r\nYou should check out the OWASP (Open Web Application Security Project) Top 10 project. It's a list of the 10 most common security issues in web applications. See https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project#OWASP_Top_10_for_2013. The current version (2017) hasn't been released yet, as it's still being translated into several languages.\r\n\r\nFor this specific security issue, the points A6 (\"Sensitive Data Exposure\") and A9 (\"Using Known Vulnerable Components\") apply here.\r\n\r\nOf course, using a salt doesn't mean MD5 is safe to use again. You will have to replace that hashing algorithm as well.\r\n\r\nYou don't have to reinvent the wheel here in order to fix this security bug. There's a couple of really secure hashing issues, and the best part is, PHP supports them out of the box (in recent version, that is).\r\n\r\n### TL;DR\r\n\r\nPHP5.5+ provides a password hashing function called `password_hash` (to verify, use `password_verify`). See http://php.net/manual/function.password-hash.php for details. If you're unexperienced in security questions (and, no offense, I think you are), just use the default algorithm `PASSWORD_DEFAULT`. You should not provide a custom `salt` or `cost` either. Just use the default values, they're sane choices, and will be updated in the future. Also, as the page says, the password column should support a lot of characters (the page recommends `VARCHAR(255)` at the moment) to be ready for future changes in the algorithms. The returned string is in a standard, interoperable format, which is understood by other software as well. Don't modify that string, just put it in the database, and you're good to go.\r\n\r\n### General notes\r\n\r\nMake sure to check out [OWASP Password Storage Cheat Sheet](https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet) if you build web applications. It provides detailed explanations and up to date recommendations.\r\n\r\nMy personal recommendation is to use either PBKDF2 or bcrypt with a salt (applies to 2018 -- might change in the future) Usually, there's libraries available with a standard interoperable format which developers should use. For Python, e.g., use https://passlib.readthedocs.io/en/stable/."},"comment":{"url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube/issues/comments/381562766","html_url":"https://github.com/DanielnetoDotCom/YouPHPTube/issues/360#issuecomment-381562766","issue_url":"https://api.github.com/repos/DanielnetoDotCom/YouPHPTube/issues/360","id":381562766,"user":{"login":"DanielnetoDotCom","id":18009293,"avatar_url":"https://avatars0.githubusercontent.com/u/18009293?v=4","gravatar_id":"","url":"https://api.github.com/users/DanielnetoDotCom","html_url":"https://github.com/DanielnetoDotCom","followers_url":"https://api.github.com/users/DanielnetoDotCom/followers","following_url":"https://api.github.com/users/DanielnetoDotCom/following{/other_user}","gists_url":"https://api.github.com/users/DanielnetoDotCom/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielnetoDotCom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielnetoDotCom/subscriptions","organizations_url":"https://api.github.com/users/DanielnetoDotCom/orgs","repos_url":"https://api.github.com/users/DanielnetoDotCom/repos","events_url":"https://api.github.com/users/DanielnetoDotCom/events{/privacy}","received_events_url":"https://api.github.com/users/DanielnetoDotCom/received_events","type":"User","site_admin":false},"created_at":"2018-04-16T11:05:46Z","updated_at":"2018-04-16T11:05:46Z","author_association":"OWNER","body":"@TheAssassin thanks, I will not forget it. I just cant change it now. I still not find a solution to communicate encoder and mobile and streamer. but I am still looking for that;\r\n\r\nthe problem is...\r\n\r\nyou may send something to the encoder, and it goes to a queue and finish to encoder 24 hours later. encoder needs to be able to open an session on the server. I use the same user password hash for it, the salted hashes are different."}}
{"actor":{"display_login":"DanielnetoDotCom"}}