www.acunetix.com Open in urlscan Pro
54.208.84.166  Public Scan

Submitted URL: https://go.acunetix.com/e/869541/blog-articles-code-injection-/5ckfhq/1163503885?h=cBIuUBoIQdxx2yu4XmLCb8SiLobO5pWRdwduz...
Effective URL: https://www.acunetix.com/blog/articles/code-injection/
Submission: On December 15 via api from US — Scanned from DE

Form analysis 2 forms found in the DOM

Name: mc-embedded-subscribe-formPOST //acunetix.us8.list-manage.com/subscribe/post?u=d7d847f8382b52d46a6547bcd&id=fbd39501d7

<form data-category="Form" data-action="Subscribe" data-label="Newsletter" data-value="" class="eventTracking" action="//acunetix.us8.list-manage.com/subscribe/post?u=d7d847f8382b52d46a6547bcd&amp;id=fbd39501d7" method="post"
  id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank" novalidate="">
  <div class="row">
    <div class="col-md-12">
      <input type="email" value="" name="EMAIL" id="mce-EMAIL" placeholder="Enter E-Mail" class="form-control input input-md mb15">
      <div style="position: absolute; left: -5000px;">
        <input type="text" name="b_d7d847f8382b52d46a6547bcd_fbd39501d7" tabindex="-1" value="">
      </div>
    </div>
    <div class="col-md-12">
      <input type="submit" value="Subscribe" class="btn btn btn-block btn-primary">
    </div>
  </div>
</form>

Name: mc-embedded-subscribe-formPOST //acunetix.us8.list-manage.com/subscribe/post?u=d7d847f8382b52d46a6547bcd&id=fbd39501d7

<form data-category="Form" data-action="Subscribe" data-label="Newsletter" data-value="" class="eventTracking" action="//acunetix.us8.list-manage.com/subscribe/post?u=d7d847f8382b52d46a6547bcd&amp;id=fbd39501d7" method="post"
  id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" target="_blank" novalidate"="">
  <div class="input-group">
    <input type="email" value="" name="EMAIL" id="mce-EMAIL" placeholder="Enter E-Mail" class="form-control">
    <span class="input-group-btn">
      <div style="position: absolute; left: -5000px;"><input type="text" name="b_d7d847f8382b52d46a6547bcd_fbd39501d7" tabindex="-1" value=""></div>
      <input type="submit" value="Subscribe" class="btn btn-default">
    </span>
  </div>
</form>

Text Content

Get a demo Toggle navigation Get a demo
 * Product
 * Why Acunetix?
   * Solutions
     * INDUSTRIES
       * IT & Telecom
       * Government
       * Financial Services
       * Education
       * Healthcare
     * ROLES
       * CTO & CISO
       * Engineering Manager
       * Security Engineer
       * DevSecOps
   * Case Studies
   * Customers
   * Testimonials
 * Pricing
 * About Us
   * Our story
   * In the news
   * Careers
   * Contact
 * Resources
   * Blog
   * Webinars
   * White papers
   * Buyer’s guide
   * Partners
   * Support
 * Get a demo

THE ACUNETIX BLOG Web Security Zone


WHAT IS CODE INJECTION (REMOTE CODE EXECUTION)

Ian Muscat | April 15, 2019


Code Injection or Remote Code Execution (RCE) enables the attacker to execute
malicious code as a result of an injection attack. Code Injection attacks are
different than Command Injection attacks. Attacker capabilities depend on the
limits of the server-side interpreter (for example, PHP, Python, and more). In
some cases, an attacker may be able to escalate from Code Injection to Command
Injection.

Typically, Code Injection occurs when an application evaluates code without
validating it first. The following is a source code of an example PHP
application with a Code Injection bug.

/**
* Get the code from a GET input
* Example - http://example.com/?code=phpinfo();
*/
$code = $_GET['code'];

/**
* Unsafely evaluate the code
* Example - phpinfo();
*/
eval("\$code;");

Base on the above example, an attacker could use the following construct to
execute arbitrary PHP code. As a result, the PHP info page would be displayed.

http://example.com/?code=phpinfo();


OS COMMAND EXECUTION

An attacker may be able to escalate a Code Injection vulnerability even further
by executing arbitrary operating system commands on the server. Based on the
example above, the attacker can execute the whoami shell command using the
system() function in PHP.

http://example.com/?code=system('whoami');

Once an attacker is able to execute OS commands, they could attempt to use a web
shell or install other malware. From there, an attacker may even attempt to
compromise other internal systems.


FINDING AND PREVENTING CODE INJECTION VULNERABILITIES

Fortunately, it’s easy to test if your website or web application is vulnerable
to code injection and other vulnerabilities by running an automated web scan
using the Acunetix vulnerability scanner. Take a demo and find out more about
running scans against your website or web application.

If you find Code Injection vulnerabilities, the most effective method to
eliminate them is to avoid code evaluation at all costs unless absolutely and
explicitly necessary (i.e. you cannot achieve the same result without code
evaluation). Generally, evaluating code that contains user input is a dangerous
way and you almost always get in trouble. There is even a common mantra for the
PHP eval function: “eval() is evil”. If code evaluation is necessary, you must
use strong user input validation. It requires as many restrictions for untrusted
data as possible. Remember that attackers may use many methods to go around
input validation conditions.

Note  – Some sources use the term code injection to refer to all types of
attacks that inject any kind of code into the web application. According to
those sources, there are many types of code injection attacks including SQL
Injection attacks, Cross-site Scripting (XSS) attacks (also called HTML script
injection or JavaScript injection), and even command injection attacks (also
called shell injection). Acunetix, like OWASP, uses the term code injection to
refer only to remote code execution (also called dynamic evaluation).

Get the latest content on web security
in your inbox each week.



SHARE THIS POST

THE AUTHOR

Ian Muscat


Ian Muscat used to be a technical resource and speaker for Acunetix. More
recently, his work centers around cloud security and phishing simulation.


RELATED POSTS:

 * Remote Code Execution in bootstrap-sass Ruby PackageRead more
   
   

 * Remote Code Execution Possible in DrupalRead more
   
   

 * Blind Out-of-band Remote Code Execution vulnerability testing added to
   AcuMonitorRead more
   
   


 * Older
 * Newer

SUBSCRIBE BY EMAIL

Get the latest content on web security in your inbox each week.



LEARN MORE

 * IIS Security
 * Apache Troubleshooting
 * Security Scanner
 * DAST vs SAST
 * Threats, Vulnerabilities, & Risks
 * Vulnerability Assessment vs Pen Testing
 * Server Security
 * Google Hacking

BLOG CATEGORIES

 * Articles
 * Web Security Zone
 * News
 * Events
 * Product Releases
 * Product Articles


Cognizant_Logo_Brand_Blue





PRODUCT INFORMATION


 * AcuSensor Technology
 * AcuMonitor Technology
 * Acunetix Integrations
 * Vulnerability Scanner
 * Support Plans

USE CASES


 * Penetration Testing Software
 * Website Security Scanner
 * External Vulnerability Scanner
 * Web Application Security
 * Vulnerability Management Software

WEBSITE SECURITY


 * Cross-site Scripting
 * SQL Injection
 * Reflected XSS
 * CSRF Attacks
 * Directory Traversal

LEARN MORE


 * White Papers
 * TLS Security
 * WordPress Security
 * Web Service Security
 * Prevent SQL Injection

COMPANY


 * About Us
 * Customers
 * Become a Partner
 * Careers
 * Contact

DOCUMENTATION


 * Case Studies
 * Support
 * Videos
 * Vulnerability Index
 * Webinars

 * Login
 * Subscription Services Agreement
 * Data Protection Policy
 * Information Security Policy
 * Privacy Policy
 * Sitemap

 * Find us on Facebook
 * Follow us on Twiter
 * Follow us on LinkedIn

© Acunetix 2021, by Invicti



By using this website you agree with our use of cookies to improve its
performance and enhance your experience. More information in our Cookie Policy.
OK