Fix command injection vulnerabilities in bonding.py and load_config.py#5010
Draft
Fix command injection vulnerabilities in bonding.py and load_config.py#5010
Conversation
Co-authored-by: andamasov <12631358+andamasov@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review current code for potential vulnerabilities
Fix command injection vulnerabilities in bonding.py and load_config.py
Feb 24, 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.
Two command injection vulnerabilities where user- or config-controlled input was interpolated into shell commands executed with
shell=True.src/op_mode/bonding.pyThe
interfaceparameter (user-supplied CLI input) was passed directly into a shell command via f-string withshell=True, allowing arbitrary command execution via crafted interface names (e.g.,bond0; rm -rf /).Replaced both
subprocess.runcalls with direct Python file I/O — no subprocess needed to read/proc/net/bonding/<iface>:Also removed the now-unused
subprocessimport.python/vyos/load_config.pyset_commands()passed config diff output intopopen()withshell=Truevia f-string. A malicious config file containing shell metacharacters in node values (e.g.,$(cmd),;cmd) could execute arbitrary commands during a config load.Replaced with a proper argument list (invoking
popenwithshell=False) and added validation that the operation subcommand contains only safe characters before constructing the binary path:🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.