[Security] Fix CodeQL alert #19: Use of a broken or weak cryptographic algorithm#93
Open
colin-d-fried wants to merge 1 commit into
Open
[Security] Fix CodeQL alert #19: Use of a broken or weak cryptographic algorithm#93colin-d-fried wants to merge 1 commit into
colin-d-fried wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| from Crypto.Cipher import AES | ||
| cipher = AES.new(key, AES.MODE_GCM) | ||
| ciphertext, tag = cipher.encrypt_and_digest(data) | ||
| return cipher.nonce + tag + ciphertext |
There was a problem hiding this comment.
Function name misleadingly references DES despite using AES
Medium Severity
The function encrypt_data_des was changed to use AES.MODE_GCM internally, but the function name still says "des." This creates a misleading API contract — callers expect DES (8-byte key) but get AES (16/24/32-byte key), so any existing caller passing a DES-sized key will receive a runtime error. The return format also changed from raw ciphertext to nonce + tag + ciphertext with no update to the function name or signature to signal these breaking changes.
This was referenced Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fixes CodeQL alert #19: Use of a broken or weak cryptographic algorithm
vulnerable_weak_crypto.pyFix Applied
See the diff for the specific secure coding change applied.
Fixes #21
Note
Medium Risk
Changes cryptography behavior and the ciphertext output format, which may break any downstream consumers expecting raw DES-ECB blocks. Security risk is reduced, but integration/regression risk exists where this function’s output is parsed or stored.
Overview
Updates
encrypt_data_desinvulnerable_weak_crypto.pyto stop using DES in ECB mode and instead encrypt using AES-GCM withencrypt_and_digest.The function now returns a single byte string composed of
nonce + tag + ciphertext, changing both the algorithm and the serialized output format for callers.Written by Cursor Bugbot for commit 7ddb89d. This will update automatically on new commits. Configure here.