# Source: https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/php-security/avoid-backticks.md

---
title: Avoid executing shell commands with arbitrary input
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Avoid executing shell commands with arbitrary input
---

# Avoid executing shell commands with arbitrary input

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `php-security/avoid-backticks`

**Language:** PHP

**Severity:** Error

**Category:** Security

**CWE**: [94](https://cwe.mitre.org/data/definitions/94.html)

## Description{% #description %}

When you execute shell commands with user-defined inputs in PHP, it leaves your application open to shell injection attacks. In these attacks, a malicious user can manipulate the input to execute arbitrary shell commands, which can lead to unauthorized access, data leakage, or even system compromise.

To ensure the safety of your application, it's important to avoid using user-defined input directly in shell commands. Instead, use built-in PHP functions that can perform the required task without the need for executing shell commands. If there's a need to use shell commands, make sure to sanitize and validate the user input thoroughly before using it.

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```php
<?php
echo `ping -n 3 {$user_input}`;
```

## Compliant Code Examples{% #compliant-code-examples %}

```php
<?php
echo `ping -n 3 domain.tld`;
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}