-
Notifications
You must be signed in to change notification settings - Fork 11
support different hash methods for final hash. #19
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -93,6 +93,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alg = res["alg"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| salt = res["salt"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nonce = res["nonce"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hash_method = res.get("hash-method", "md5") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Step2: Generate cipher text using openssl algorithm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if alg == 1: # MD5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -106,11 +107,18 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise ValueError("Router requested unsupported hashing algorithm") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise ValueError("Router requested unsupported hashing algorithm for cipher password") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Step3: Generate hash values for login | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data = f"{username}:{cipher_password}:{nonce}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hsh = hashlib.md5(data.encode()).hexdigest() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if hash_method == "md5": # MD5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hsh = hashlib.md5(data.encode()).hexdigest() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif hash_method == "sha256": # SHA-256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hsh = hashlib.sha256(data.encode()).hexdigest() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check failureCode scanning / CodeQL Use of a broken or weak cryptographic hashing algorithm on sensitive data High Sensitive data (password) Error loading related location Loading Sensitive data (password) Error loading related location Loading Sensitive data (password) Error loading related location Loading
Copilot AutofixAI 11 months ago To address this genuine issue, we should ensure the client never uses MD5 for hashing login data, and preferentially uses the strongest algorithm the router supports (SHA-512 > SHA-256 > MD5). We should raise a warning or error if the router requests MD5, and consider refusing login unless the router supports at least SHA-256. To implement this, edit the
Suggested changeset
1
gli4py/glinet.py
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif hash_method == "sha256": # SHA-512 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hsh = hashlib.sha512(data.encode()).hexdigest() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check failureCode scanning / CodeQL Use of a broken or weak cryptographic hashing algorithm on sensitive data High Sensitive data (password) Error loading related location Loading Sensitive data (password) Error loading related location Loading Sensitive data (password) Error loading related location Loading Copilot AutofixAI 11 months ago Copilot could not generate an autofix suggestion Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise ValueError("Router requested unsupported hashing algorithm for hash") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Step4: Get sid by login | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| res = await self._get_sid(username, hsh) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.