Skip to content
Closed
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
2 changes: 2 additions & 0 deletions examples/codesec_action_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user_input = input("expr: ")
result = eval(user_input)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CodeSecAudit AI: CWE-94 Code Injection via eval()

Severity: Critical

Using eval(), exec(), or new Function() executes arbitrary code from strings. An attacker who controls any part of the evaluated string can execute arbitrary commands, leading to full compromise of the application.

Suggested fix: Replace eval()/exec() with a safe alternative:

  • For JSON: use JSON.parse() instead of eval().
  • For arithmetic: use a proper expression parser like expr-eval.
  • For dynamic property access: use bracket notation with an allowlist.
  • Never trust user input as executable code.

Loading