
Understanding Code and Command Injection Vulnerabilities
Explore the dangers of code and command injection vulnerabilities, how attackers can exploit them to execute arbitrary commands, and ways to mitigate these risks in your applications.
Uploaded on | 1 Views
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
OWASP OWASP A1 INJECTION A1 INJECTION
Injection Injection Injection flaws allow attackers to relay malicious code through an application to another system * Code Injection * Command Injection
Code Injection Code Injection Attack type which consist of sending input to exploit the syntax of the targeted interpreter Ex: - Query injections (Sql, ldap, xpath, nosql, etc.) - xml parser Injection - Program arguments (ex: malicious parameter could modify actions taken by system calls - that normally retrieves current user's file - to access another user's file via canonical naming)
Command Injection Command Injection An attack in which the goal is execution of arbitrary commands on the host operating system via a vulnerable application. Usually executed with the privileges of the vulnerable application.
int main(char* argc, char** argv) { char cmd[CMD_MAX] = "/usr/bin/cat "; strcat(cmd, argv[1]); system(cmd); } Command Injection Example
int main(char* argc, char** argv) { char cmd[CMD_MAX] = "/usr/bin/cat "; strcat(cmd, argv[1]); system(cmd); } Exploit: "somefile.txt;rm -rf /" Command Injection Example
Code injection Code injection vs vs Command injection Command injection CODE INJECTION COMMAND INJECTION Attacker is only limited by the functionality of the injected language itself. Command injection consists of leveraging existing code to execute commands, usually within the context of a shell. i.e. If an attacker is able to inject PHP code into an application and have it executed, he is only limited by what PHP is capable of.
SQL Injection demo CODE INJECTION
LDAP Injection demo CODE INJECTION
XML Injection demo CODE INJECTION
Command Injection Demos Command Injection Demos
Mitigations Mitigations - For shell/system calls use language specific libraries to perform simple functions. - WHITELIST/SANITIZE/KNOW YOUR INPUTS! - Defense in depth (app liv - Don t give away hints/errs - Principle of least privilege (give db users least privs, run processed with restricted privs, restrict perms on dirs.) - Use prepared statements, parameterized queries - prepared statements are sent to the db as parameterized queries which the db parses and waits for parameters to be send . Once parameters are sent, they're filled in to the parse tree of the query.