Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[device/quanta] Mitigation for security vulnerability #11867

Merged
merged 13 commits into from
Oct 19, 2022

Conversation

maipbui
Copy link
Contributor

@maipbui maipbui commented Aug 29, 2022

Signed-off-by: maipbui maibui@microsoft.com

Dependency: #12065

Why I did it

shell=True is dangerous because this call will spawn the command using a shell process
os - not secure against maliciously constructed input and dangerous if used to evaluate dynamic content.

How I did it

os - use with subprocess
Use shell=False with shell features

How to verify it

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: maipbui <maibui@microsoft.com>
@maipbui maipbui requested a review from qiluo-msft August 29, 2022 14:21
Signed-off-by: maipbui <maibui@microsoft.com>
Signed-off-by: maipbui <maibui@microsoft.com>
Signed-off-by: maipbui <maibui@microsoft.com>
@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Aug 30, 2022

def log_os_system(cmd, show):

def log_os_system(cmd1args, cmd2args, show):


In reply to: 1231957757


In reply to: 1231957757


In reply to: 1231957757


Refers to: device/quanta/x86_64-quanta_ix1b_rglbmc-r0/plugins/psuutil.py:47 in ab31cfe. [](commit_id = ab31cfe, deletion_comment = False)

Signed-off-by: maipbui <maibui@microsoft.com>
@maipbui maipbui requested a review from qiluo-msft August 31, 2022 04:26
Signed-off-by: maipbui <maibui@microsoft.com>
@yejianquan
Copy link
Contributor

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comments

Signed-off-by: maipbui <maibui@microsoft.com>
@maipbui maipbui requested a review from qiluo-msft September 2, 2022 22:56
@maipbui maipbui marked this pull request as ready for review September 7, 2022 14:19
Signed-off-by: maipbui <maibui@microsoft.com>
@maipbui
Copy link
Contributor Author

maipbui commented Sep 12, 2022

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@maipbui
Copy link
Contributor Author

maipbui commented Sep 13, 2022

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: maipbui <maibui@microsoft.com>
@maipbui maipbui requested a review from lguohan as a code owner September 19, 2022 16:50
@lgtm-com
Copy link

lgtm-com bot commented Sep 19, 2022

This pull request fixes 2 alerts when merging b2f432b into e662008 - view on LGTM.com

fixed alerts:

  • 2 for Unused import

Signed-off-by: maipbui <maibui@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented Sep 19, 2022

This pull request fixes 2 alerts when merging a6453a5 into e662008 - view on LGTM.com

fixed alerts:

  • 2 for Unused import

Signed-off-by: maipbui <maibui@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented Oct 5, 2022

This pull request introduces 7 alerts and fixes 2 when merging ba7a4be into 1f0699f - view on LGTM.com

new alerts:

  • 7 for Comparison using is when operands support `__eq__`

fixed alerts:

  • 2 for Unused import

@maipbui
Copy link
Contributor Author

maipbui commented Oct 7, 2022

@roberthong-qct @jonathantsai-qci Could you help review and verify?

@roberthong-qct
Copy link
Contributor

Hi @maipbui , thanks for the security enhancement.
However, after I build your branch and try "show platform firmware" and "show interfaces transceiver eeprom" on IX8A_BDE, the error messages show as below:
"ImportError: cannot import name 'getstatusoutput_noshell_pipe' from 'sonic_py_common.general' (/usr/local/lib/python3.9/dist-packages/sonic_py_common/general.py)- required module not found"

@maipbui
Copy link
Contributor Author

maipbui commented Oct 13, 2022

Hi @maipbui , thanks for the security enhancement. However, after I build your branch and try "show platform firmware" and "show interfaces transceiver eeprom" on IX8A_BDE, the error messages show as below: "ImportError: cannot import name 'getstatusoutput_noshell_pipe' from 'sonic_py_common.general' (/usr/local/lib/python3.9/dist-packages/sonic_py_common/general.py)- required module not found"

Hi @roberthong-qct, could you try install the latest sonic_py_common package first? The 'getstatusoutput_noshell_pipe' function is implemented in this PR #12065.

@maipbui
Copy link
Contributor Author

maipbui commented Oct 17, 2022

@roberthong-qct could you update on your verification?

Signed-off-by: maipbui <maibui@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented Oct 17, 2022

This pull request fixes 2 alerts when merging 62c4237 into a750930 - view on LGTM.com

fixed alerts:

  • 2 for Unused import

@roberthong-qct
Copy link
Contributor

roberthong-qct commented Oct 18, 2022

@roberthong-qct could you update on your verification?

_get_command_result_pipe() in component.py has a problem checking the return values of getstatusoutput_noshell_pipe()
,and there's a missing comma in comopent.py for IX7.
Please refer to the attachment for my modifications, thank you.
component_diff.txt

Signed-off-by: maipbui <maibui@microsoft.com>
@maipbui
Copy link
Contributor Author

maipbui commented Oct 18, 2022

@roberthong-qct could you update on your verification?

_get_command_result_pipe() in component.py has a problem checking the return values of getstatusoutput_noshell_pipe() ,and there's a missing comma in comopent.py for IX7. Please refer to the attachment for my modifications, thank you. component_diff.txt

Thanks @roberthong-qct ! I have fixed all issues based on your attachment. Is it good to merge?

@lgtm-com
Copy link

lgtm-com bot commented Oct 18, 2022

This pull request fixes 2 alerts when merging e521b22 into bc8ee7a - view on LGTM.com

fixed alerts:

  • 2 for Unused import

@roberthong-qct
Copy link
Contributor

roberthong-qct commented Oct 19, 2022

Thanks @roberthong-qct ! I have fixed all issues based on your attachment. Is it good to merge?

@maipbui Yes, relevant daemons and commands are running well.

@maipbui maipbui merged commit 6f67a3a into sonic-net:master Oct 19, 2022
@maipbui maipbui deleted the quanta_security branch October 19, 2022 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants