Exploit database

GH-a840dff1ca596cc94a7de5dbc0f78558

drackyjr/cve-2020-15778-scp-command-injection-check

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2020-15778

6 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files3

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

scp_cve_check.sh

Shell · 2,319 bytes
#!/bin/bash

# CVE-2020-15778 - SCP Command Injection Check
# This script helps you check if your SCP command is vulnerable
# and shows what happens if someone uses dangerous arguments.

echo "Checking your system's SCP version..."

# Get the scp version string (e.g., 8.3p1)
scp_version_output=$(scp -V 2>&1)
version=$(echo "$scp_version_output" | grep -oP '[0-9]+\.[0-9]+p?[0-9]*')
echo "SCP version found: $version"

# This function turns the version into a number we can compare
# For example: 8.3p1 becomes 080301
convert_version() {
    echo "$1" | sed -E 's/p([0-9]+)/.\1/' | awk -F. '{ printf("%02d%02d%02d\n", $1,$2,$3); }'
}

# Use this to compare versions
current_version=$(convert_version "$version")
vulnerable_version=$(convert_version "8.3p1")

# Tell the user if their version is safe or not
if [ "$current_version" -le "$vulnerable_version" ]; then
    echo "Your SCP version is vulnerable to CVE-2020-15778."
    echo "You should update OpenSSH to version 8.4p1 or newer."
else
    echo "Your SCP version is safe from CVE-2020-15778."
fi

echo ""
echo "Now let's test a sample SCP destination input."

# Ask the user to type in a fake scp destination
read -p "Enter an SCP destination (e.g., user@host:\`touch /tmp/pwned\`/file.txt): " dest_arg

# This function checks for backticks
check_for_backticks() {
    if [[ "$1" == *\`* ]]; then
        echo ""
        echo "Warning: The destination contains backticks (\`), which can be dangerous."
        echo "If you are using a vulnerable version, the part inside the backticks could be executed as a shell command."
        echo "Example of risky part: $(echo "$1" | grep -oP '\`.*?\`')"
    else
        echo "No backticks found. This looks safe."
    fi
}

check_for_backticks "$dest_arg"

# Simple explanation
echo ""
echo "What is CVE-2020-15778?"
echo "It's a security bug in old versions of SCP (part of OpenSSH)."
echo "If you give it a destination with special shell characters like \`, it might run those commands by mistake."
echo ""
echo "How to stay safe:"
echo "- Update OpenSSH to version 8.4p1 or higher."
echo "- Never use scp with input you don't fully control."
echo "- Use safer tools like sftp or rsync if possible."
echo ""
echo "Done. This script didn't do anything harmful. It just showed how to check for the problem."

exit 0