Skip to content

Fix mutable default arguments bug in Communication class - #912

Open
l1ve709 wants to merge 1 commit into
threat9:masterfrom
l1ve709:fix/mutable-default-args
Open

Fix mutable default arguments bug in Communication class#912
l1ve709 wants to merge 1 commit into
threat9:masterfrom
l1ve709:fix/mutable-default-args

Conversation

@l1ve709

@l1ve709 l1ve709 commented Jul 26, 2026

Copy link
Copy Markdown

Description

This PR fixes a critical Python anti-pattern (B006: mutable default arguments) in the Communication class initialization (routersploit/core/exploit/shell.py).

Previously, wget_options and echo_options were initialized with an empty dictionary {}. Because default arguments in Python are evaluated once at function definition, multiple exploit module instances could end up sharing the exact same dictionary reference in memory. This can lead to state leakage across modules (where configuring an option for one target inadvertently affects another target).

This fix replaces the mutable {} defaults with None, and explicitly creates a fresh dictionary inside the constructor __init__ if no argument is passed, guaranteeing proper memory isolation for each instance.

Modules affected

  • routersploit/core/exploit/shell.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant