Skip to content

Files

Latest commit

 

History

History
34 lines (23 loc) · 1.19 KB

B111.md

File metadata and controls

34 lines (23 loc) · 1.19 KB

Pattern: Method call with run_as_root=True

Issue: -

Description

Running commands as root dramatically increase their potential risk. Running commands with restricted user privileges provides defense in depth against command injection attacks, or developer and configuration error. This rule checks for specific methods being called with a keyword parameter run_as_root set to True, a common OpenStack idiom:

  • ceilometer.utils.execute
  • cinder.utils.execute
  • neutron.agent.linux.utils.execute
  • nova.utils.execute
  • nova.utils.trycmd

Example of insecure code:

ceilometer_utils.execute('gcc --version', run_as_root=True)

Example of secure code:

ceilometer_utils.execute('gcc --version', run_as_root=False)

Further Reading