Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #31

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Add files via upload #31

merged 1 commit into from
Sep 8, 2024

Conversation

jeff-cycode
Copy link
Contributor

No description provided.

}
else {
// *nix
$cmd = shell_exec( 'ping -c 4 ' . escapeshellarg($target) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cycode: SAST violation: 'Unsanitized user input in OS command'.

Severity: Critical

Description

Executing OS commands that include user-supplied data can lead to command injection vulnerabilities. This occurs when an application dynamically executes OS commands that an attacker can manipulate through user input.

Cycode Remediation Guideline

✅ Do


  • Do use a predefined set of commands instead of directly including user input, if user input has to influence the execution flow.
if ($_GET["action"] == "option1") {
  $command = "command1";
} else {
  $command = "command2";
}

exec($command);

❌ Don't


  • Do not directly include user input in commands to be executed by the OS. This can allow attackers to inject malicious commands.
exec($_GET["command"]); // unsafe

📋 References


}

// Feedback for the end user
$html .= "<pre>{$cmd}</pre>";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cycode: SAST violation: 'Unsanitized user input in raw HTML strings (XSS)'.

Severity: High

Description

Including unsanitized user input in HTML exposes your application to cross-site scripting (XSS) attacks. This vulnerability allows attackers to inject malicious scripts into web pages viewed by other users.

Cycode Remediation Guideline

✅ Do


  • Do use a templating language like Twig, and keep the template in a separate file. Templating languages automatically handle input sanitization, reducing the risk of XSS.
  • Do sanitize user input when HTML strings must be used, to prevent malicious code injection.
$html = "<h1>${htmlspecialchars($_GET["title"])}</h1>";

❌ Don't


  • Do not include user input directly in HTML strings. This practice can lead to XSS vulnerabilities.
$html = "<h1>{$_GET["title"]}</h1>"; // unsafe

📋 References


// Determine OS and execute the ping command.
if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
// Windows
$cmd = shell_exec( 'ping ' . escapeshellarg($target) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cycode: SAST violation: 'Unsanitized user input in OS command'.

Severity: Critical

Description

Executing OS commands that include user-supplied data can lead to command injection vulnerabilities. This occurs when an application dynamically executes OS commands that an attacker can manipulate through user input.

Cycode Remediation Guideline

✅ Do


  • Do use a predefined set of commands instead of directly including user input, if user input has to influence the execution flow.
if ($_GET["action"] == "option1") {
  $command = "command1";
} else {
  $command = "command2";
}

exec($command);

❌ Don't


  • Do not directly include user input in commands to be executed by the OS. This can allow attackers to inject malicious commands.
exec($_GET["command"]); // unsafe

📋 References


@jeff-cycode jeff-cycode merged commit 49e52a8 into main Sep 8, 2024
5 of 6 checks passed
@jeff-cycode jeff-cycode deleted the jeff-cycode-patch-13 branch September 8, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant