GCU vlanintf_validator builds os.system() from CONFIG_DB VLAN_INTERFACE key - #4764
Open
Bharath-cisco wants to merge 1 commit into
Open
GCU vlanintf_validator builds os.system() from CONFIG_DB VLAN_INTERFACE key#4764Bharath-cisco wants to merge 1 commit into
Bharath-cisco wants to merge 1 commit into
Conversation
…CE key Signed-off-by: Bharath <bdhanapa@cisco.com>
Collaborator
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
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.
What I did
vlanintf_validator()in the Generic Config Updater flushed ARP/neighborentries for deleted VLAN interfaces by formatting the raw
VLAN_INTERFACE|<iface>|<ip>key parts directly into a shell commandstring. Both parts come from a CONFIG_DB key, which untrusted local
processes can write, so a crafted key containing shell metacharacters
could execute arbitrary commands as root the next time an administrator
applied a config change touching
VLAN_INTERFACE(e.g.config rollback,config apply-patch). This is a command-injection vulnerability (CWE-78).How I did it
ifaceagainst the kernel interface-name pattern(
^[A-Za-z0-9_.-]{1,15}$) andiface_ipwithipaddress.ip_interface()before use; skip (without executing anything) any deleted key that fails
either check, logging the reason.
subprocess.run(["ip", "neigh", "flush", "dev", iface, iface_ip])—which never invokes a shell, instead of building a command string from
untrusted key parts.
How to verify it
python3 -m py_compile generic_config_updater/services_validator.py(Vlan100, 10.0.0.1/24)key andreject the reported PoC key containing shell metacharacters.
config apply-patchdeleting aVLAN_INTERFACEentry on a live testbedstill flushes the neighbor entry for a legitimate interface/IP.
Previous command output (if the output of a command-line utility has changed)
N/A
New command output (if the output of a command-line utility has changed)
N/A