Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vulnerable_weak_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ def encrypt_data_des(data, key):
return encrypted

def encrypt_with_arc2(plaintext, key):
cipher = ARC2.new(key, ARC2.MODE_ECB)
return cipher.encrypt(plaintext)
from Crypto.Cipher import AES
cipher = AES.new(key, AES.MODE_GCM)
ciphertext, tag = cipher.encrypt_and_digest(plaintext)
return cipher.nonce + tag + ciphertext

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARC2 import now unused after removing its only usage

Low Severity

The ARC2 import on line 3 (from Crypto.Cipher import DES, ARC2, Blowfish) is now unused because encrypt_with_arc2 was the only consumer and this change replaced its internals with AES. The stale import of a weak cryptographic module partially undermines the intent of removing weak crypto usage from this function.

Fix in Cursor Fix in Web

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name falsely implies ARC2 but uses AES-GCM

Medium Severity

The function encrypt_with_arc2 now internally uses AES-GCM instead of ARC2, but the name was not updated. This is misleading — a developer writing a corresponding decryption function based on the name would assume ARC2/ECB and produce completely incompatible code. The return format also silently changed from raw ciphertext to nonce + tag + ciphertext, compounding the risk of misuse.

Fix in Cursor Fix in Web


def generate_token():
token = ""
Expand Down
Loading