cwe-77-command-injection

Remediate CWE-77 command injection vulnerabilities in Java code.

3|1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/DevelopersCoffee/java-cwe-security-skills --skill cwe-77-command-injection
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: cwe-77-command-injection
Source: https://github.com/DevelopersCoffee/java-cwe-security-skills/tree/main/cwe-77-command-injection
Command: npx skills add https://github.com/DevelopersCoffee/java-cwe-security-skills --skill cwe-77-command-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical security vulnerability of Command Injection (CWE-77) in Java applications, preventing unauthorized command execution on the server.

Core Features & Use Cases

  • Vulnerability Identification: Detects patterns where user input is directly incorporated into system commands.
  • Secure Code Transformation: Provides deterministic fixes to safely execute external commands.
  • Use Case: Secure a Java web application endpoint that uses user-provided input to construct a ping command, preventing attackers from executing arbitrary shell commands.

Quick Start

Use the cwe-77-command-injection skill to secure the Java code that executes system commands with user input.

Frequently Asked Questions about cwe-77-command-injection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent command injection in Java when using Runtime.exec?▼

Prevent command injection in Java by replacing direct string concatenation into Runtime.exec with parameterized command arrays and input validation. This ensures user input is treated as arguments rather than executable shell commands.

What is CWE-77 and how does it affect Java applications?▼

CWE-77 is the improper neutralization of special elements used in a command, allowing attackers to execute unauthorized shell commands on the server via manipulated user input in Java applications.

How do I secure ProcessBuilder against arbitrary command execution?▼

Secure ProcessBuilder against arbitrary command execution by constructing commands using parameterized arrays instead of concatenated strings, ensuring user input cannot inject malicious system commands.

Can I use SAST to detect CWE-77 command injection vulnerabilities in Java?▼

SAST tools can detect CWE-77 command injection vulnerabilities by identifying patterns where user input is directly incorporated into system commands executed via Runtime.exec or ProcessBuilder in Java.

What is the best way to remediate command injection vulnerabilities in Java?▼

The best way to remediate command injection vulnerabilities in Java is to utilize parameterized command arrays for Runtime.exec or ProcessBuilder and enforce strict input validation on user-provided data.

Why does concatenating user input into system commands cause security vulnerabilities?▼

Concatenating user input into system commands causes security vulnerabilities because attackers can use special characters to append unauthorized shell commands, leading to arbitrary command execution on the server.