Ruby

Theory

Ruby scripting is a powerful tool used by system administrators and developers to automate tasks and streamline processes on Unix-like systems. However, like any software, ruby scripts can be vulnerable to various security issues, which, if exploited, can lead to privilege escalation and unauthorized access.

Practice

YAML Code Execution

Assume the ruby script can be executed as root with sudo rights. If it use the File.read() method and we controll its input, then the script is vulnerable to arbitrary code execution.

sudo -l
    (root): /usr/bin/ruby sample.rb

Check if we have control over the input of the vulnerable function

File.read(’sample.yml’)

References

Last updated